challenge-editor/scene/card.gd
2024-09-24 17:26:44 +08:00

57 lines
1.4 KiB
GDScript

extends Control
class_name Card
@onready var state_machine: StateMachine = $state_machine
@onready var fight_card: TextureRect = $fight_card
var scale_multiple:float=1.1
func _ready() -> void:
state_machine.launch()
func _on_fight_card_mouse_entered() -> void:
state_machine.send_message("mouse_enter")
pass # Replace with function body.
func _on_fight_card_mouse_exited() -> void:
state_machine.send_message("mouse_exit")
pass # Replace with function body.
var data:Dictionary
func set_data(id:String):
pass
var last_move_tween:Tween
func move_to(from_pos:Vector2,to_pos:Vector2,time:float=0.5):
if last_move_tween!=null:
last_move_tween.kill()
self.position=from_pos
var tween=create_tween()
tween.set_trans(Tween.TRANS_QUAD)
tween.tween_property(self,"position",to_pos,time)
tween.tween_callback(move_finished)
last_move_tween=tween
func move_finished():
state_machine.send_message("move_finished")
pass
func up():
z_index=1
scale_to(scale_multiple)
func down():
z_index=0
scale_to(1)
var last_scale_tween:Tween
func scale_to(sc:float):
if last_scale_tween!=null:
last_scale_tween.kill()
last_scale_tween=create_tween()
last_scale_tween.tween_property(fight_card,"scale",Vector2(sc,sc),0.1)
func get_machine()->CardMachine:
return get_parent()
func get_self_index_position():
return get_machine().get_index_position(get_index())
func request_resize():
state_machine.send_message("resize")