From 14538d486de312af41ce012836861468b8fb7897 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Sun, 5 Jun 2022 14:09:41 -0600 Subject: finish all necessary for playability --- src/ui/hud/actions/scripts/actions_hud.gd | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/ui/hud/actions/scripts/actions_hud.gd (limited to 'src/ui/hud/actions/scripts/actions_hud.gd') diff --git a/src/ui/hud/actions/scripts/actions_hud.gd b/src/ui/hud/actions/scripts/actions_hud.gd new file mode 100644 index 0000000..b45acb5 --- /dev/null +++ b/src/ui/hud/actions/scripts/actions_hud.gd @@ -0,0 +1,37 @@ +extends MarginContainer + +onready var w: TextureButton = $VBox/WHBox/W +onready var s: TextureButton = $VBox/SHBox/S +onready var space: TextureButton = $VBox/SpaceHBox/Space + +var stats: Stats = SaveData.get_stats() + + +func _ready(): + Event.connect("snake_started_dash", self, "_on_snake_started_dash") + Event.connect("snake_started_slow", self, "_on_snake_started_slow") + Event.connect("snake_started_jump", self, "_on_snake_started_jump") + if stats.trait_dash: + w.disabled = false + if stats.trait_slow: + s.disabled = false + if stats.trait_jump: + space.disabled = false + + +func _on_snake_started_dash() -> void: + w.disabled = true + yield(get_tree().create_timer(Global.SNAKE_DASH_COOLDOWN), "timeout") + w.disabled = false + + +func _on_snake_started_slow() -> void: + s.disabled = true + yield(get_tree().create_timer(Global.SNAKE_SLOW_COOLDOWN), "timeout") + s.disabled = false + + +func _on_snake_started_jump() -> void: + space.disabled = true + yield(get_tree().create_timer(Global.SNAKE_JUMP_COOLDOWN), "timeout") + space.disabled = false -- cgit v1.2.3-54-g00ecf