replace states with simple function
This commit is contained in:
parent
c1d63c214a
commit
a4ca3c3a34
46
Main.gd
46
Main.gd
|
@ -1,54 +1,26 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
signal state_completed
|
|
||||||
|
|
||||||
var state_stack = []
|
|
||||||
|
|
||||||
onready var deck = $Deck
|
onready var deck = $Deck
|
||||||
onready var tween = $Tween
|
onready var tween = $Tween
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
state_stack.push_back(funcref(self, "update_game"))
|
var dealer = oya()
|
||||||
state_stack.push_back(funcref(self, "update_oya"))
|
|
||||||
|
|
||||||
func _process(delta):
|
func oya():
|
||||||
# print("Main::_process()")
|
tween.start()
|
||||||
if state_stack.empty():
|
|
||||||
return
|
|
||||||
|
|
||||||
var state = state_stack.pop_back()
|
|
||||||
# print(state)
|
|
||||||
if state == null:
|
|
||||||
return
|
|
||||||
|
|
||||||
state.call_func()
|
|
||||||
yield(self, "state_completed")
|
|
||||||
# state_stack.pop_back()
|
|
||||||
|
|
||||||
func update_oya():
|
|
||||||
var card_1 = $Deck.card($Deck.draw_card())
|
var card_1 = $Deck.card($Deck.draw_card())
|
||||||
card_1.show()
|
card_1.show()
|
||||||
|
|
||||||
tween.start()
|
|
||||||
|
|
||||||
tween.interpolate_property(card_1, "position",
|
tween.interpolate_property(card_1, "position",
|
||||||
Vector2(0, 0), Vector2(100, 100), 3,
|
Vector2(0, 0), Vector2(100, 100), 3,
|
||||||
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
|
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
|
||||||
|
|
||||||
yield(tween, "tween_all_completed")
|
var card_2 = $Deck.card($Deck.draw_card())
|
||||||
yield(tween, "tween_completed")
|
card_2.show()
|
||||||
|
tween.interpolate_property(card_2, "position",
|
||||||
|
Vector2(0, 0), Vector2(-100, 100), 0.4,
|
||||||
|
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
|
||||||
|
|
||||||
# var card_2 = $Deck.card($Deck.draw_card())
|
yield(tween, "tween_all_completed")
|
||||||
# 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")
|
|
||||||
|
|
||||||
print("update oya")
|
print("update oya")
|
||||||
emit_signal("state_completed")
|
|
||||||
|
|
||||||
func update_game():
|
|
||||||
print("update game")
|
|
||||||
emit_signal("state_completed")
|
|
||||||
|
|
Loading…
Reference in a new issue