2021-12-06 23:10:39 +01:00
|
|
|
extends Node
|
|
|
|
|
2021-12-13 23:38:36 +01:00
|
|
|
signal state_completed
|
2021-12-06 23:10:39 +01:00
|
|
|
|
2021-12-12 23:21:03 +01:00
|
|
|
var state_stack = []
|
2021-12-06 23:10:39 +01:00
|
|
|
|
2021-12-13 23:38:36 +01:00
|
|
|
onready var deck = $Deck
|
|
|
|
onready var tween = $Tween
|
|
|
|
|
2021-12-06 23:10:39 +01:00
|
|
|
func _ready():
|
2021-12-12 23:21:03 +01:00
|
|
|
state_stack.push_back(funcref(self, "update_game"))
|
|
|
|
state_stack.push_back(funcref(self, "update_oya"))
|
|
|
|
|
|
|
|
func _process(delta):
|
2021-12-13 23:38:36 +01:00
|
|
|
# print("Main::_process()")
|
2021-12-12 23:21:03 +01:00
|
|
|
if state_stack.empty():
|
|
|
|
return
|
|
|
|
|
|
|
|
var state = state_stack.pop_back()
|
2021-12-13 23:38:36 +01:00
|
|
|
# print(state)
|
2021-12-12 23:21:03 +01:00
|
|
|
if state == null:
|
|
|
|
return
|
2021-12-13 23:38:36 +01:00
|
|
|
|
|
|
|
state.call_func()
|
|
|
|
yield(self, "state_completed")
|
|
|
|
# state_stack.pop_back()
|
2021-12-06 23:10:39 +01:00
|
|
|
|
2021-12-12 23:21:03 +01:00
|
|
|
func update_oya():
|
2021-12-13 23:38:36 +01:00
|
|
|
var card_1 = $Deck.card($Deck.draw_card())
|
|
|
|
card_1.show()
|
|
|
|
|
|
|
|
tween.start()
|
|
|
|
|
|
|
|
tween.interpolate_property(card_1, "position",
|
|
|
|
Vector2(0, 0), Vector2(100, 100), 3,
|
|
|
|
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
|
|
|
|
|
|
|
|
yield(tween, "tween_all_completed")
|
|
|
|
yield(tween, "tween_completed")
|
|
|
|
|
|
|
|
# var card_2 = $Deck.card($Deck.draw_card())
|
|
|
|
# card_2.show()
|
|
|
|
# tween.interpolate_property(card_2, "position",
|
|
|
|
# Vector2(0, 0), Vector2(-100, 100), 0.4,
|
|
|
|
# Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
|
|
|
|
#
|
|
|
|
# yield(tween, "tween_all_completed")
|
|
|
|
|
2021-12-12 23:21:03 +01:00
|
|
|
print("update oya")
|
2021-12-13 23:38:36 +01:00
|
|
|
emit_signal("state_completed")
|
2021-12-06 23:10:39 +01:00
|
|
|
|
2021-12-12 23:21:03 +01:00
|
|
|
func update_game():
|
|
|
|
print("update game")
|
2021-12-13 23:38:36 +01:00
|
|
|
emit_signal("state_completed")
|