summaryrefslogtreecommitdiff
path: root/UI/hud.gd
blob: 21bd2bc4ab4614f1a8fa6d4d4915df99560086cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
extends CanvasLayer


var selected_button: TextureRect :
	set(value):
		if selected_button:
			(selected_button.material as ShaderMaterial).set_shader_parameter("adjust", 0.0)
		
		selected_button = value
		(selected_button.material as ShaderMaterial).set_shader_parameter("adjust", -1.0)


func _ready() -> void:
	Game.score_changed.connect(func():
		%Score.text = str(Game.score)
	)
	
	Game.speed_changed.connect(func():
		%Speed.text = str(Game.speed).pad_decimals(1) + "x"
	)


func _on_button_blocker_gui_input(event: InputEvent) -> void:
	if event.is_action_pressed("select"):
		Game.selected_unit_type = preload("res://Units/Blocker.tscn")
		selected_button = %ButtonBlocker

func _on_button_digger_gui_input(event: InputEvent) -> void:
	if event.is_action_pressed("select"):
		Game.selected_unit_type = preload("res://Units/Digger.tscn")
		selected_button = %ButtonDigger

func _on_button_miner_gui_input(event: InputEvent) -> void:
	if event.is_action_pressed("select"):
		Game.selected_unit_type = preload("res://Units/Miner.tscn")
		selected_button = %ButtonMiner

func _on_button_basher_gui_input(event: InputEvent) -> void:
	if event.is_action_pressed("select"):
		Game.selected_unit_type = preload("res://Units/Basher.tscn")
		selected_button = %ButtonBasher

func _on_button_floater_gui_input(event: InputEvent) -> void:
	if event.is_action_pressed("select"):
		#Game.selected_unit_type = preload("res://Units/Floater.tscn")
		selected_button = %ButtonFloater

func _on_button_builder_gui_input(event: InputEvent) -> void:
	if event.is_action_pressed("select"):
		#Game.selected_unit_type = preload("res://Units/Builder.tscn")
		selected_button = %ButtonBuilder

func _on_button_climber_gui_input(event: InputEvent) -> void:
	if event.is_action_pressed("select"):
		Game.selected_unit_type = preload("res://Units/Climber.tscn")
		selected_button = %ButtonClimber



func _on_button_plus_gui_input(event: InputEvent) -> void:
	if event.is_action_pressed("select"):
		Game.speed = min(Game.speed + 0.5, 5)

func _on_button_minus_gui_input(event: InputEvent) -> void:
	if event.is_action_pressed("select"):
		Game.speed = max(Game.speed - 0.5, 0.5)