From 6f17d6c1d458275e8744d57a7f433cc3eb5434d7 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 6 Nov 2024 12:27:51 +0100 Subject: next commit --- Game/States/Build/BuilderElement.gd | 2 + Stages/Stage.gd | 8 ++++ Stages/Wintermaul/HUD.gd | 2 +- Stages/Wintermaul/HUD.tscn | 80 +++++++++++++++++++++---------------- Stages/Wintermaul/hud_tower.gd | 71 ++++++++++++++++++++++++++++++++ Stages/Wintermaul/hud_tower.tscn | 12 ++++++ Stages/Wintermaul/wintermaul.gd | 31 +++++++------- UI/spawn_button.gd | 6 +++ UI/tower_configuration.gd | 6 +++ Units/Unit.gd | 12 +++--- 10 files changed, 173 insertions(+), 57 deletions(-) diff --git a/Game/States/Build/BuilderElement.gd b/Game/States/Build/BuilderElement.gd index cc9c051..b564379 100644 --- a/Game/States/Build/BuilderElement.gd +++ b/Game/States/Build/BuilderElement.gd @@ -79,9 +79,11 @@ func _process(_delta): func can_build(): for area in collision_areas: if area.get_overlapping_areas().size() > 0: + Client.current_stage.add_status_message("Can't build there") return false if area.get_overlapping_bodies().size() > 0: + Client.current_stage.add_status_message("Can't build there") return false #if Client.current_stage.has_method("can_build"): diff --git a/Stages/Stage.gd b/Stages/Stage.gd index 5b218d6..7cdd2f8 100644 --- a/Stages/Stage.gd +++ b/Stages/Stage.gd @@ -106,6 +106,14 @@ func set_player_script(script: Script): player[property] = previous_values[property] +func add_status_message(message: String): + var label = Label.new() + label.text = message + $HUD.get_node("%StatusMessages").add_child(label) + await get_tree().create_timer(3.0).timeout + label.queue_free() + + ## get spawn node func get_spawn(): pass diff --git a/Stages/Wintermaul/HUD.gd b/Stages/Wintermaul/HUD.gd index 8457ab2..5567f77 100644 --- a/Stages/Wintermaul/HUD.gd +++ b/Stages/Wintermaul/HUD.gd @@ -135,7 +135,7 @@ func _input(event: InputEvent): team_top.visible = not team_top.visible team_bottom.visible = not team_bottom.visible - if %MultiSelectionContainer.visible and event.is_action_pressed("selection_cycle"): + if event.is_action_pressed("selection_cycle") and %MultiSelectionContainer.visible: var keys = get_ordered_group_keys() var current_idx = keys.find(selected_group) selected_group = keys[(current_idx + 1) % keys.size()] diff --git a/Stages/Wintermaul/HUD.tscn b/Stages/Wintermaul/HUD.tscn index 9c8a575..3290c84 100644 --- a/Stages/Wintermaul/HUD.tscn +++ b/Stages/Wintermaul/HUD.tscn @@ -229,72 +229,82 @@ theme_override_constants/margin_top = 4 theme_override_constants/margin_right = 4 theme_override_constants/margin_bottom = 4 -[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] layout_mode = 2 -[node name="TowerConfigurationsContainer" type="PanelContainer" parent="MarginContainer/HBoxContainer"] +[node name="HBoxContainerTop" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="StatusMessages" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainerTop"] +unique_name_in_owner = true +layout_mode = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="TowerConfigurationsContainer" type="PanelContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 size_flags_stretch_ratio = 100.0 mouse_filter = 1 -[node name="PanelBackgroundBlue" parent="MarginContainer/HBoxContainer/TowerConfigurationsContainer" instance=ExtResource("4_x1gx8")] +[node name="PanelBackgroundBlue" parent="MarginContainer/VBoxContainer/HBoxContainer/TowerConfigurationsContainer" instance=ExtResource("4_x1gx8")] layout_mode = 2 texture = ExtResource("6_ru5yo") -[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer/TowerConfigurationsContainer"] +[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/HBoxContainer/TowerConfigurationsContainer"] layout_mode = 2 theme_override_constants/margin_left = 16 theme_override_constants/margin_top = 16 theme_override_constants/margin_right = 16 theme_override_constants/margin_bottom = 24 -[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/HBoxContainer/TowerConfigurationsContainer/MarginContainer"] +[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer/HBoxContainer/TowerConfigurationsContainer/MarginContainer"] layout_mode = 2 vertical_scroll_mode = 0 -[node name="TowerConfigurations" type="HBoxContainer" parent="MarginContainer/HBoxContainer/TowerConfigurationsContainer/MarginContainer/ScrollContainer"] +[node name="TowerConfigurations" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer/TowerConfigurationsContainer/MarginContainer/ScrollContainer"] layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="TextureRect" parent="MarginContainer/HBoxContainer/TowerConfigurationsContainer/MarginContainer/ScrollContainer/TowerConfigurations" instance=ExtResource("17_1c5dq")] +[node name="TextureRect" parent="MarginContainer/VBoxContainer/HBoxContainer/TowerConfigurationsContainer/MarginContainer/ScrollContainer/TowerConfigurations" instance=ExtResource("17_1c5dq")] layout_mode = 2 -[node name="MultiSelectionContainer" type="PanelContainer" parent="MarginContainer/HBoxContainer"] +[node name="MultiSelectionContainer" type="PanelContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"] unique_name_in_owner = true custom_minimum_size = Vector2(200, 0) layout_mode = 2 size_flags_horizontal = 3 size_flags_stretch_ratio = 100.0 -[node name="PanelBackgroundBlue" parent="MarginContainer/HBoxContainer/MultiSelectionContainer" instance=ExtResource("4_x1gx8")] +[node name="PanelBackgroundBlue" parent="MarginContainer/VBoxContainer/HBoxContainer/MultiSelectionContainer" instance=ExtResource("4_x1gx8")] layout_mode = 2 -[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer/MultiSelectionContainer"] +[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/HBoxContainer/MultiSelectionContainer"] layout_mode = 2 theme_override_constants/margin_left = 16 theme_override_constants/margin_top = 8 theme_override_constants/margin_right = 16 theme_override_constants/margin_bottom = 4 -[node name="MultiSelectionList" type="HFlowContainer" parent="MarginContainer/HBoxContainer/MultiSelectionContainer/MarginContainer"] +[node name="MultiSelectionList" type="HFlowContainer" parent="MarginContainer/VBoxContainer/HBoxContainer/MultiSelectionContainer/MarginContainer"] unique_name_in_owner = true layout_mode = 2 last_wrap_alignment = 1 -[node name="SelectionContainer" type="PanelContainer" parent="MarginContainer/HBoxContainer"] +[node name="SelectionContainer" type="PanelContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"] unique_name_in_owner = true custom_minimum_size = Vector2(200, 0) layout_mode = 2 size_flags_horizontal = 10 size_flags_stretch_ratio = 2.0 -[node name="PanelBackgroundBlue" parent="MarginContainer/HBoxContainer/SelectionContainer" instance=ExtResource("4_x1gx8")] +[node name="PanelBackgroundBlue" parent="MarginContainer/VBoxContainer/HBoxContainer/SelectionContainer" instance=ExtResource("4_x1gx8")] layout_mode = 2 -[node name="SelectionData" type="MarginContainer" parent="MarginContainer/HBoxContainer/SelectionContainer"] +[node name="SelectionData" type="MarginContainer" parent="MarginContainer/VBoxContainer/HBoxContainer/SelectionContainer"] unique_name_in_owner = true layout_mode = 2 theme_override_constants/margin_left = 16 @@ -302,11 +312,11 @@ theme_override_constants/margin_top = 16 theme_override_constants/margin_right = 16 theme_override_constants/margin_bottom = 24 -[node name="TowerData" parent="MarginContainer/HBoxContainer/SelectionContainer/SelectionData" instance=ExtResource("5_hbytm")] +[node name="TowerData" parent="MarginContainer/VBoxContainer/HBoxContainer/SelectionContainer/SelectionData" instance=ExtResource("5_hbytm")] unique_name_in_owner = true layout_mode = 2 -[node name="SpawnBox" type="PanelContainer" parent="MarginContainer/HBoxContainer"] +[node name="SpawnBox" type="PanelContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 10 @@ -314,23 +324,23 @@ size_flags_vertical = 8 size_flags_stretch_ratio = 0.0 theme = ExtResource("5_121ry") -[node name="PanelBackgroundBlue" parent="MarginContainer/HBoxContainer/SpawnBox" instance=ExtResource("4_x1gx8")] +[node name="PanelBackgroundBlue" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox" instance=ExtResource("4_x1gx8")] layout_mode = 2 -[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer/SpawnBox"] +[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox"] layout_mode = 2 theme_override_constants/margin_left = 16 theme_override_constants/margin_top = 16 theme_override_constants/margin_right = 16 theme_override_constants/margin_bottom = 16 -[node name="GridContainer" type="GridContainer" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer"] +[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer"] layout_mode = 2 theme_override_constants/h_separation = 0 theme_override_constants/v_separation = 0 columns = 4 -[node name="SpawnButton" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 theme = ExtResource("5_121ry") texture_normal = ExtResource("10_ad8mc") @@ -339,7 +349,7 @@ texture_hover = ExtResource("12_540qu") texture = ExtResource("7_ba5tw") sprite_sheet = ExtResource("14_0x0h2") -[node name="SpawnButton2" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton2" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 shortcut = SubResource("Shortcut_i6rmj") texture_normal = ExtResource("15_7yrxb") @@ -348,7 +358,7 @@ texture_hover = ExtResource("17_k5kqo") texture = ExtResource("9_nmd8t") sprite_sheet = ExtResource("17_hp6oc") -[node name="SpawnButton3" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton3" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("20_xigo6") texture_pressed = ExtResource("21_4fyiv") @@ -356,7 +366,7 @@ texture_hover = ExtResource("22_471yj") texture = ExtResource("11_yxcwt") sprite_sheet = ExtResource("20_xc6s7") -[node name="SpawnButton4" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton4" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("25_vpb52") texture_pressed = ExtResource("26_tgyag") @@ -364,73 +374,73 @@ texture_hover = ExtResource("27_5tp6y") texture = ExtResource("13_iq5a7") sprite_sheet = ExtResource("29_p4pru") -[node name="SpawnButton5" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton5" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("14_t3qlu") texture_pressed = ExtResource("5_xcxr8") texture_hover = ExtResource("6_4go2d") -[node name="SpawnButton6" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton6" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("14_t3qlu") texture_pressed = ExtResource("5_xcxr8") texture_hover = ExtResource("6_4go2d") -[node name="SpawnButton7" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton7" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("14_t3qlu") texture_pressed = ExtResource("5_xcxr8") texture_hover = ExtResource("6_4go2d") -[node name="SpawnButton8" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton8" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("14_t3qlu") texture_pressed = ExtResource("5_xcxr8") texture_hover = ExtResource("6_4go2d") -[node name="SpawnButton9" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton9" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("14_t3qlu") texture_pressed = ExtResource("5_xcxr8") texture_hover = ExtResource("6_4go2d") -[node name="SpawnButton10" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton10" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("14_t3qlu") texture_pressed = ExtResource("5_xcxr8") texture_hover = ExtResource("6_4go2d") -[node name="SpawnButton11" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton11" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("14_t3qlu") texture_pressed = ExtResource("5_xcxr8") texture_hover = ExtResource("6_4go2d") -[node name="SpawnButton12" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton12" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("14_t3qlu") texture_pressed = ExtResource("5_xcxr8") texture_hover = ExtResource("6_4go2d") -[node name="SpawnButton13" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton13" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("14_t3qlu") texture_pressed = ExtResource("5_xcxr8") texture_hover = ExtResource("6_4go2d") -[node name="SpawnButton14" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton14" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("14_t3qlu") texture_pressed = ExtResource("5_xcxr8") texture_hover = ExtResource("6_4go2d") -[node name="SpawnButton15" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton15" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("14_t3qlu") texture_pressed = ExtResource("5_xcxr8") texture_hover = ExtResource("6_4go2d") -[node name="SpawnButton16" parent="MarginContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] +[node name="SpawnButton16" parent="MarginContainer/VBoxContainer/HBoxContainer/SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")] layout_mode = 2 texture_normal = ExtResource("14_t3qlu") texture_pressed = ExtResource("5_xcxr8") diff --git a/Stages/Wintermaul/hud_tower.gd b/Stages/Wintermaul/hud_tower.gd index 9d2ca1b..ab23441 100644 --- a/Stages/Wintermaul/hud_tower.gd +++ b/Stages/Wintermaul/hud_tower.gd @@ -40,11 +40,22 @@ func get_selected_towers() -> Array: return hud.selection_groups[hud.selected_group].duplicate() +func get_component(tower: Tower, component_name: String): + var component: TowerComponent + for idx in range(tower.components.size()): + if tower.components[idx].name == component_name: + component = tower.components[idx] + break + + return component + + func _on_range_plus_pressed() -> void: var towers = get_selected_towers() var cost = Client.current_stage.price_map.tower.attack_range.call(current_tower.attack_range, towers.size()) if Client.player.money < cost: + Client.current_stage.add_status_message("Not enough money to upgrade") return for tower: Tower in towers: @@ -66,6 +77,7 @@ func _on_power_plus_pressed() -> void: var cost = Client.current_stage.price_map.tower.attack_power.call(current_tower.attack_power, towers.size()) if Client.player.money < cost: + Client.current_stage.add_status_message("Not enough money to upgrade") return for tower: Tower in towers: @@ -87,6 +99,7 @@ func _on_speed_plus_pressed() -> void: var cost = Client.current_stage.price_map.tower.attack_speed.call(current_tower.attack_speed, towers.size()) if Client.player.money < cost: + Client.current_stage.add_status_message("Not enough money to upgrade") return for tower: Tower in towers: @@ -107,10 +120,15 @@ func _on_frost_gui_input(event: InputEvent) -> void: if event.is_action_pressed("select"): get_viewport().set_input_as_handled() + if get_component(current_tower, "Frost"): + 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: @@ -136,10 +154,15 @@ func _on_burn_gui_input(event: InputEvent) -> void: if event.is_action_pressed("select"): get_viewport().set_input_as_handled() + if get_component(current_tower, "Burn"): + 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: @@ -175,6 +198,7 @@ func _on_frost_level_up_pressed() -> void: 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: @@ -207,6 +231,7 @@ func _on_burn_level_up_pressed() -> void: 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: @@ -223,3 +248,49 @@ func _on_burn_level_up_pressed() -> void: 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()) + %RangePlus.tooltip_text = "Cost: " + str(cost) + +func _on_power_plus_mouse_entered() -> void: + var towers = get_selected_towers() + var cost = Client.current_stage.price_map.tower.attack_power.call(current_tower.attack_power, towers.size()) + %PowerPlus.tooltip_text = "Cost: " + str(cost) + +func _on_speed_plus_mouse_entered() -> void: + var towers = get_selected_towers() + var cost = Client.current_stage.price_map.tower.attack_speed.call(current_tower.attack_speed, towers.size()) + %SpeedPlus.tooltip_text = "Cost: " + str(cost) + +func _on_frost_mouse_entered() -> void: + var towers = get_selected_towers() + var cost = 100 * towers.size() + $Components/Frost.tooltip_text = "Cost: " + str(cost) + +func _on_frost_level_up_mouse_entered() -> void: + var component = get_component(current_tower, "Frost") + if not component: + $Components/Frost/FrostLevelUp.tooltip_text = "" + return + + var towers = get_selected_towers() + var cost = 10 * component.level * towers.size() + $Components/Frost/FrostLevelUp.tooltip_text = "Cost: " + str(cost) + +func _on_burn_mouse_entered() -> void: + var towers = get_selected_towers() + var cost = 100 * towers.size() + $Components/Burn.tooltip_text = "Cost: " + str(cost) + +func _on_burn_level_up_mouse_entered() -> void: + var component = get_component(current_tower, "Burn") + if not component: + $Components/Burn/BurnLevelUp.tooltip_text = "" + return + + var towers = get_selected_towers() + var cost = 10 * component.level * towers.size() + $Components/Burn/BurnLevelUp.tooltip_text = "Cost: " + str(cost) diff --git a/Stages/Wintermaul/hud_tower.tscn b/Stages/Wintermaul/hud_tower.tscn index ce9ebf9..533c6b9 100644 --- a/Stages/Wintermaul/hud_tower.tscn +++ b/Stages/Wintermaul/hud_tower.tscn @@ -21,16 +21,19 @@ layout_mode = 2 [node name="RangePlus" type="Button" parent="HBoxContainer"] unique_name_in_owner = true layout_mode = 2 +mouse_default_cursor_shape = 2 text = "+Range" [node name="PowerPlus" type="Button" parent="HBoxContainer"] unique_name_in_owner = true layout_mode = 2 +mouse_default_cursor_shape = 2 text = "+Power" [node name="SpeedPlus" type="Button" parent="HBoxContainer"] unique_name_in_owner = true layout_mode = 2 +mouse_default_cursor_shape = 2 text = "+Speed" [node name="Components" type="VBoxContainer" parent="."] @@ -57,6 +60,7 @@ text = ": 1" [node name="FrostLevelUp" type="Button" parent="Components/Frost"] layout_mode = 2 +mouse_default_cursor_shape = 2 text = "+Level" [node name="Burn" type="HBoxContainer" parent="Components"] @@ -79,12 +83,20 @@ text = ": 1" [node name="BurnLevelUp" type="Button" parent="Components/Burn"] layout_mode = 2 +mouse_default_cursor_shape = 2 text = "+Level" +[connection signal="mouse_entered" from="HBoxContainer/RangePlus" to="." method="_on_range_plus_mouse_entered"] [connection signal="pressed" from="HBoxContainer/RangePlus" to="." method="_on_range_plus_pressed"] +[connection signal="mouse_entered" from="HBoxContainer/PowerPlus" to="." method="_on_power_plus_mouse_entered"] [connection signal="pressed" from="HBoxContainer/PowerPlus" to="." method="_on_power_plus_pressed"] +[connection signal="mouse_entered" from="HBoxContainer/SpeedPlus" to="." method="_on_speed_plus_mouse_entered"] [connection signal="pressed" from="HBoxContainer/SpeedPlus" to="." method="_on_speed_plus_pressed"] [connection signal="gui_input" from="Components/Frost" to="." method="_on_frost_gui_input"] +[connection signal="mouse_entered" from="Components/Frost" to="." method="_on_frost_mouse_entered"] +[connection signal="mouse_entered" from="Components/Frost/FrostLevelUp" to="." method="_on_frost_level_up_mouse_entered"] [connection signal="pressed" from="Components/Frost/FrostLevelUp" to="." method="_on_frost_level_up_pressed"] [connection signal="gui_input" from="Components/Burn" to="." method="_on_burn_gui_input"] +[connection signal="mouse_entered" from="Components/Burn" to="." method="_on_burn_mouse_entered"] +[connection signal="mouse_entered" from="Components/Burn/BurnLevelUp" to="." method="_on_burn_level_up_mouse_entered"] [connection signal="pressed" from="Components/Burn/BurnLevelUp" to="." method="_on_burn_level_up_pressed"] diff --git a/Stages/Wintermaul/wintermaul.gd b/Stages/Wintermaul/wintermaul.gd index 081d18a..95d914a 100644 --- a/Stages/Wintermaul/wintermaul.gd +++ b/Stages/Wintermaul/wintermaul.gd @@ -105,9 +105,8 @@ func place_tower(remote_data: Dictionary): var player = Network.get_player(tower.owner_id) player.towers[tower.global_position] = tower - player.money -= 5 + player.money -= price_map.tower.cost Network.players_changed.emit() - #Network.update_player.rpc(player.id, {"money": -5}) _place_tower(%Towers, tower) Client.placed_tower.emit(tower) @@ -121,6 +120,10 @@ func spawn_unit(remote_data: Dictionary): var player = Network.get_player(unit.owner_id) player.units.append(unit) + player.money -= price_map.unit.tiers[0].cost + player.income += price_map.unit.tiers[0].income + Network.players_changed.emit() + if multiplayer.is_server(): unit.reached_goal.connect(func(): var team = get_team(player) @@ -129,28 +132,20 @@ func spawn_unit(remote_data: Dictionary): elif team == teams.bottom: update_lives.rpc("top", -1) ) - - #Network.update_player.rpc(player.id, { - #"money": -5, - #"income": 1, - #}) - player.money -= 5 - player.income += 1 - Network.players_changed.emit() _spawn_unit(%Towers, unit) func can_place_tower(): - if Client.player.money < 5: - print("Not enough money to build tower") + if Client.player.money < price_map.tower.cost: + add_status_message("Not enough money to build tower") return false return true -func can_spawn_unit(): - if Client.player.money < 5: - print("Not enough money to spawn unit") +func can_spawn_unit(tier_idx: int = 0): + if Client.player.money < price_map.unit.tiers[tier_idx].cost: + add_status_message("Not enough money to spawn unit") return false return true @@ -210,3 +205,9 @@ func reset_timer(): func update_lives(team: String, lives: int): teams[team].lives += lives lives_changed.emit() + + if lives < 0: + add_status_message("Team " + team + " lost " + str(abs(lives)) + " life") + + if teams[team].lives <= 0: + add_status_message("Team " + team + " lost the game") diff --git a/UI/spawn_button.gd b/UI/spawn_button.gd index a773406..3051dfb 100644 --- a/UI/spawn_button.gd +++ b/UI/spawn_button.gd @@ -4,6 +4,12 @@ extends TextureButton @export var texture: Texture2D @export var sprite_sheet: SpriteFrames +@export var cost := 5 + + +func _ready(): + tooltip_text = "Cost: " + str(cost) + func _on_pressed() -> void: var unit = preload("res://Units/Unit.tscn").instantiate() as Unit diff --git a/UI/tower_configuration.gd b/UI/tower_configuration.gd index 7031de5..302a0ac 100644 --- a/UI/tower_configuration.gd +++ b/UI/tower_configuration.gd @@ -3,6 +3,12 @@ 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 diff --git a/Units/Unit.gd b/Units/Unit.gd index f5bb6a6..b575e01 100644 --- a/Units/Unit.gd +++ b/Units/Unit.gd @@ -334,10 +334,10 @@ func to_network_data() -> NetworkData: data.target_path = target.get_path() - #data.hp = hp + data.hp = hp - #data.base_speed = base_speed - #data.speed = speed + data.base_speed = base_speed + data.speed = speed #data.texture_path = sprite.texture.resource_path data.sprite_frames_path = sprite.sprite_frames.resource_path @@ -373,10 +373,10 @@ static func from_network_data(data: NetworkData) -> Unit: #unit.target = unit.get_tree().current_scene.get_node(data.target_path) unit.target_path = data.target_path - #unit.hp = data.hp + unit.hp = data.hp - #unit.base_speed = data.base_speed - #unit.speed = data.speed + unit.base_speed = data.base_speed + unit.speed = data.speed #unit.sprite.texture = load(data.texture_path) unit.sprite.sprite_frames = load(data.sprite_frames_path) -- cgit v1.2.3