blob: d2fb39d722e0cced53aa831567d43f2b2d70b2e0 (
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
|
class_name StateBuild
extends State
static var current_builder_element: BuilderElement
func _state_enter():
%BuildGrid.visible = true
func _state_exit():
%BuildGrid.visible = false
func _state_input(event: InputEvent):
if event.is_action_pressed("builder_tower_select"):
if current_builder_element and current_builder_element.can_build():
var placed_tower = current_builder_element.element.duplicate() as Tower
Client.place_tower(placed_tower, current_builder_element.global_position)
placed_tower.selected.connect(func():
Client.stage.hud.tower.text = "Range: %s - Power: %s - Speed: %s" % [
placed_tower.attack_range, placed_tower.attack_power, placed_tower.attack_speed
]
)
if not Input.is_action_pressed("builder_tower_place_keep"):
current_builder_element.queue_free()
current_builder_element = null
if event.is_action_pressed("build_mode_start"):
get_viewport().set_input_as_handled()
if current_builder_element:
current_builder_element.queue_free()
current_builder_element = null
set_state("StateDefault")
|