summaryrefslogtreecommitdiff
path: root/Stages/Wintermaul/hud_tower.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-11-19 15:24:50 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-11-19 15:24:50 +0100
commit72863ffa31e27f4c6be862d80472cfb897fccaea (patch)
treece04be8d77b10c797c8ff854c8ff1a219eb1af46 /Stages/Wintermaul/hud_tower.gd
parent63d2a59042fb9d90a586ad85d8364de7c38aea8e (diff)
next commitHEADmain
Diffstat (limited to 'Stages/Wintermaul/hud_tower.gd')
-rw-r--r--Stages/Wintermaul/hud_tower.gd73
1 files changed, 71 insertions, 2 deletions
diff --git a/Stages/Wintermaul/hud_tower.gd b/Stages/Wintermaul/hud_tower.gd
index 99d9e62..2c92a11 100644
--- a/Stages/Wintermaul/hud_tower.gd
+++ b/Stages/Wintermaul/hud_tower.gd
@@ -218,6 +218,31 @@ func _on_burn_gui_input(event: InputEvent) -> void:
})
+func _on_poison_gui_input(event: InputEvent) -> void:
+ if event.is_action_pressed("select"):
+ get_viewport().set_input_as_handled()
+
+ if current_tower.components.has(TowerComponent.ComponentType.Poison):
+ Client.current_stage.add_status_message("Component already added")
+ return
+
+ var towers = get_selected_towers()
+
+ var cost = 100 * towers.size()
+ if Client.player.money < cost:
+ Client.current_stage.add_status_message("Not enough money to add component")
+ return
+
+ for tower: Tower in towers:
+ tower.add_component(preload("res://Towers/Components/PoisonComponent.tscn").instantiate())
+
+ Client.update_tower(tower.get_path(), tower.to_network_data())
+
+ Network.update_player.rpc(Client.player.id, {
+ "money": -cost,
+ })
+
+
func _on_range_level_up_pressed() -> void:
var towers = get_selected_towers()
@@ -333,6 +358,31 @@ func _on_burn_level_up_pressed() -> void:
})
+func _on_poison_level_up_pressed() -> void:
+ var towers = get_selected_towers()
+
+ var component: TowerComponent = current_tower.components.get(TowerComponent.ComponentType.Poison)
+ if not component:
+ return
+
+ var cost = 10 * component.level * towers.size()
+ if Client.player.money < cost:
+ Client.current_stage.add_status_message("Not enough money to level up")
+ return
+
+ for tower: Tower in towers:
+ var tower_component: TowerComponent = tower.components.get(TowerComponent.ComponentType.Poison)
+
+ tower_component.level += 1
+ tower.components_changed.emit()
+
+ Client.update_tower(tower.get_path(), tower.to_network_data())
+
+ Network.update_player.rpc(Client.player.id, {
+ "money": -cost,
+ })
+
+
#func _on_range_plus_mouse_entered() -> void:
#var towers = get_selected_towers()
#var cost = Client.current_stage.price_map.tower.attack_range.call(current_tower.attack_range, towers.size())
@@ -369,7 +419,7 @@ func _on_range_level_up_mouse_entered() -> void:
func _on_attack_mouse_entered() -> void:
if current_tower.components.has(TowerComponent.ComponentType.Attack):
- $Components/Range.tooltip_text = ""
+ $Components/Attack.tooltip_text = ""
return
var towers = get_selected_towers()
@@ -388,7 +438,7 @@ func _on_attack_level_up_mouse_entered() -> void:
func _on_frost_mouse_entered() -> void:
if current_tower.components.has(TowerComponent.ComponentType.Frost):
- $Components/Range.tooltip_text = ""
+ $Components/Frost.tooltip_text = ""
return
var towers = get_selected_towers()
@@ -423,3 +473,22 @@ func _on_burn_level_up_mouse_entered() -> void:
var towers = get_selected_towers()
var cost = 10 * component.level * towers.size()
$Components/Burn/BurnLevelUp.tooltip_text = "Cost: " + str(cost)
+
+func _on_poison_mouse_entered() -> void:
+ if current_tower.components.has(TowerComponent.ComponentType.Poison):
+ $Components/Poison.tooltip_text = ""
+ return
+
+ var towers = get_selected_towers()
+ var cost = 100 * towers.size()
+ $Components/Poison.tooltip_text = "Cost: " + str(cost)
+
+func _on_poison_level_up_mouse_entered() -> void:
+ var component = current_tower.components.get(TowerComponent.ComponentType.Poison)
+ if not component:
+ $Components/Poison/PoisonLevelUp.tooltip_text = ""
+ return
+
+ var towers = get_selected_towers()
+ var cost = 10 * component.level * towers.size()
+ $Components/Poison/PoisonLevelUp.tooltip_text = "Cost: " + str(cost)