extends Control class_name Card @onready var state_machine: StateMachine = $state_machine @onready var fight_card: TextureRect = $fight_card @onready var arrow: card_arrow = $arrow var target_queue:int=-1 var scale_multiple:float=1.1 signal queue 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): var d=Global.get_card_data(id) if d!=null: data=d fight_card.set_data(d) if data.has("target_queue"): target_queue=data["target_queue"] arrow.set_select_queue(target_queue) pass ##该卡牌是否需要选择目标 func need_target(): return target_queue!=-1 ##获取该卡牌的目标 func get_target()->int: return target_queue 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 signal move_finished_sig func move_finished(): state_machine.send_message("move_finished") move_finished_sig.emit() pass func up(): z_index=basic_index+10 scale_to(scale_multiple) var basic_index:int=0: set(val): basic_index=val down() pass func down(): z_index=basic_index scale_to(1) func show_big(): z_index=basic_index+10 scale_to(1.5) 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_machine().get_card_index(self)) func get_queue_position(): return get_machine().get_queue_pos() func get_exe_position(): return get_machine().get_exe_position() func request_resize(): state_machine.send_message("resize") func open_arrow(): arrow.start() func close_arrow(): arrow.stop() func set_arrow_queue(q:int): arrow.set_select_queue(q) func get_select_result(): return arrow.get_target() func clear(): state_machine.change_state("discard",0) #执行目标 var target func exe(): print("exe") move_to(self.position,get_exe_position()) await move_finished_sig show_big() await get_tree().create_timer(0.2).timeout Global.use_card(data,target) await get_tree().create_timer(0.2).timeout down() print("执行完毕") state_machine.change_state("discard",0) return 0