summaryrefslogtreecommitdiff
path: root/UI/tower_configuration.gd
blob: 302a0ac6c7031c5bc0724d517e269d37ad028aca (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
extends PanelContainer


var is_hovered = false

@export var cost := 5


func _ready() -> void:
	tooltip_text = "Cost: " + str(cost)


func _on_mouse_entered() -> void:
	is_hovered = true
	
	var stylebox := StyleBoxFlat.new()
	stylebox.bg_color = Color(1.0, 1.0, 1.0, 0.25)
	add_theme_stylebox_override("panel", stylebox)

func _on_mouse_exited() -> void:
	is_hovered = false
	
	remove_theme_stylebox_override("panel")


func _on_texture_rect_gui_input(event: InputEvent) -> void:
	var state: StateBuild = get_tree().current_scene.get_node("StateManager/StateBuild")
	if event.is_action_pressed("select") and not state.current_builder_element:
		var builder_element_scene = preload("res://Game/States/Build/BuilderElement.tscn")
		var builder_element = builder_element_scene.instantiate()
		
		builder_element.element = preload("res://Towers/Tower.tscn")
		get_tree().current_scene.add_child(builder_element)
		state.current_builder_element = builder_element