extends Control class_name FightScene var user:FightCharacterCard ##角色节点的引用队列 var character_arr:Array[FightCharacterCard]=[] var enermy_arr:Array[FightEnermyCard]=[] var extract_card_arr:Array=[] var hand_card_arr:Array=[] var left_card_arr:Array=[] var extract_num:int=5 const FIGHT_CHARACTER_CARD = preload("res://scene/fight_character_card.tscn") const FIGHT_ENERMY_CARD = preload("res://scene/fight_enermy_card.tscn") # Called when the node enters the scene tree for the first time. func _ready() -> void: Global.now_fight_scene=self extract_card_arr=Global.get_all_card() extract_card(extract_num) add_user(Global.get_character_data("test_character_01")) add_character(Global.get_character_data("test_character_01")) add_enermy(Global.get_character_data("test_character_01")) add_enermy(Global.get_character_data("test_character_02")) pass # Replace with function body. ##抽牌 func extract_card(num:int): if extract_card_arr.size() void: pass ##释放队列决定后开始回合 func start_turn(): left_card_arr.append_array(hand_card_arr.duplicate()) hand_card_arr.clear() var sort_unit=get_sort_all_unit() for i in sort_unit: if i[0]!=user: await i[0].atk() else: await %card_machine.exe_queue() extract_card(extract_num) %end_select.show() pass ##添加友方角色(非玩家) func add_character(character_data:Dictionary): var new_character=FIGHT_CHARACTER_CARD.instantiate() %character_card_add_pos.add_child(new_character) new_character.set_data(character_data) character_arr.append(new_character) pass ##添加敌方角色 func add_enermy(character_data:Dictionary): var new_character=FIGHT_ENERMY_CARD.instantiate() %enermy_card_add_pos.add_child(new_character) new_character.set_data(character_data) enermy_arr.append(new_character) pass ##设置玩家 func add_user(character_data:Dictionary): if user!=null: if is_instance_valid(user): user.queue_free() user=null var new_character=FIGHT_CHARACTER_CARD.instantiate() %character_card_add_pos.add_child(new_character) new_character.set_data(character_data) user=new_character func _on_tool_button_pressed() -> void: pass # Replace with function body. func _on_end_select_pressed() -> void: %card_machine.clear_card() %end_select.hide() start_turn() pass # Replace with function body. func get_all_character(): return character_arr.duplicate() func get_all_enermy(): return enermy_arr.duplicate() func get_all_unit(): var unit_arr:Array=[] unit_arr.append_array(get_all_character()) unit_arr.append_array(get_all_enermy()) unit_arr.append(user) return unit_arr func sort(a,b)->bool: if a[1] void: win() pass # Replace with function body.