46 lines
1.2 KiB
GDScript
46 lines
1.2 KiB
GDScript
@tool
|
|
extends InspectableEntity
|
|
class_name WinCristal
|
|
|
|
var order = 0
|
|
@export_tool_button("Update", "Callable") var update_action = update
|
|
@export_tool_button("Spawn Anim", "Callable") var spawn_action = spawn_animation
|
|
@export var data : WinCristalData = WinCristalData.random() :
|
|
set(v):
|
|
data = v
|
|
update()
|
|
|
|
func _ready():
|
|
update()
|
|
|
|
func update():
|
|
if is_node_ready() and data:
|
|
for i in range(len(%Sprites.get_children())):
|
|
%Sprites.get_children()[i].visible = data.cristal_type == i
|
|
%Sprites.get_children()[i].flip_h = data.cristal_flip
|
|
|
|
func spawn_animation():
|
|
scale = Vector2.ZERO
|
|
|
|
match order:
|
|
0:
|
|
%CristalPlayer.play()
|
|
1:
|
|
%CristalPlayer2.play()
|
|
2:
|
|
%CristalPlayer3.play()
|
|
3:
|
|
%CristalPlayer4.play()
|
|
4:
|
|
%CristalPlayer5.play()
|
|
_:
|
|
%CristalPlayer6.play()
|
|
|
|
get_tree().create_tween().tween_property(self, "scale", Vector2.ONE, 0.3).set_trans(Tween.TRANS_BOUNCE)
|
|
|
|
func get_card_up_padding() -> float:
|
|
return Pointer.CARD_UP_PADDING * 2
|
|
|
|
func save() -> EntityData:
|
|
data.position = global_position
|
|
return data |