challenge-editor/scene/fight.gd

52 lines
1.4 KiB
GDScript3
Raw Normal View History

2024-09-24 17:26:44 +08:00
extends Control
2024-09-25 18:04:02 +08:00
class_name FightScene
##角色节点的引用队列
2024-09-24 17:26:44 +08:00
2024-09-25 18:04:02 +08:00
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
2024-09-24 17:26:44 +08:00
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
2024-09-25 18:04:02 +08:00
extract_card_arr=Global.get_all_card()
extract_card(extract_num)
2024-09-24 17:26:44 +08:00
pass # Replace with function body.
2024-09-25 18:04:02 +08:00
func extract_card(num:int):
if extract_card_arr.size()<num:
refresh_card()
for i in num:
if extract_card_arr.size()==0:
break
var rand:int=randi()%extract_card_arr.size()
var id=extract_card_arr[rand]
extract_card_arr.pop_at(rand)
hand_card_arr.append(id)
%card_machine.add_card(id,1)
pass
func refresh_card():
extract_card_arr.append_array(left_card_arr.duplicate())
left_card_arr.clear()
2024-09-24 17:26:44 +08:00
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
2024-09-25 18:04:02 +08:00
func start_turn():
left_card_arr.append_array(hand_card_arr.duplicate())
hand_card_arr.clear()
await %card_machine.exe_queue()
extract_card(extract_num)
%end_select.show()
pass
2024-09-24 17:26:44 +08:00
func _on_tool_button_pressed() -> void:
2024-09-25 18:04:02 +08:00
pass # Replace with function body.
func _on_end_select_pressed() -> void:
%card_machine.clear_card()
%end_select.hide()
start_turn()
2024-09-24 17:26:44 +08:00
pass # Replace with function body.