diff options
Diffstat (limited to 'Stages')
-rw-r--r-- | Stages/Stage.gd | 2 | ||||
-rw-r--r-- | Stages/Wintermaul/HUD.gd | 13 | ||||
-rw-r--r-- | Stages/Wintermaul/hud_tower.gd | 380 | ||||
-rw-r--r-- | Stages/Wintermaul/hud_tower.tscn | 60 | ||||
-rw-r--r-- | Stages/Wintermaul/wintermaul.gd | 2 |
5 files changed, 316 insertions, 141 deletions
diff --git a/Stages/Stage.gd b/Stages/Stage.gd index 7cdd2f8..9484305 100644 --- a/Stages/Stage.gd +++ b/Stages/Stage.gd @@ -42,7 +42,7 @@ func place_tower(_remote_data: Dictionary) -> void: func _place_tower(parent: Node2D, tower: Tower): var player: Player = Network.get_player(tower.owner_id) tower.get_node("AnimatedSprite2D").modulate = player.get_color() - tower.get_node("ComponentsAnchor").modulate = player.get_color() + tower.get_node("%ComponentsAnchor").modulate = player.get_color() fill_tower_region(tower, true) diff --git a/Stages/Wintermaul/HUD.gd b/Stages/Wintermaul/HUD.gd index 5567f77..be2dacb 100644 --- a/Stages/Wintermaul/HUD.gd +++ b/Stages/Wintermaul/HUD.gd @@ -180,12 +180,15 @@ func get_ordered_group_keys() -> Array: var group_b = selection_groups[b] var node_a = group_a[0] var node_b = group_b[0] + var level_a = 0 + var level_b = 0 - return ( - (node_a.attack_range / 8) + node_a.attack_power + node_a.attack_speed - > - (node_b.attack_range / 8) + node_b.attack_power + node_b.attack_speed - ) + for component in node_a.components.values(): + level_a += component.level + for component in node_b.components.values(): + level_b += component.level + + return level_a > level_b ) keys.sort_custom(func(a, b): var group_a = selection_groups[a] diff --git a/Stages/Wintermaul/hud_tower.gd b/Stages/Wintermaul/hud_tower.gd index ab23441..24a7a8d 100644 --- a/Stages/Wintermaul/hud_tower.gd +++ b/Stages/Wintermaul/hud_tower.gd @@ -17,9 +17,9 @@ func set_current_tower(tower: Tower): redraw_components() current_tower.components_changed.connect(redraw_components) - %Data.text = "Range: %s - Power: %s - Speed: %s" % [ - current_tower.attack_range, current_tower.attack_power, current_tower.attack_speed - ] + #%Data.text = "Range: %s - Power: %s - Speed: %s" % [ + #current_tower.attack_range, current_tower.attack_power, current_tower.attack_speed + #] func redraw_components(): @@ -27,10 +27,9 @@ func redraw_components(): node.modulate = Color(1.0, 1.0, 1.0, 0.5) node.get_node("Level").text = str(0) - for idx in range(current_tower.components.size()): - var component = current_tower.components[idx] - %Components.get_node(component.name).modulate = Color(1.0, 1.0, 1.0, 1.0) - %Components.get_node(component.name).get_node("Level").text = ": %s" % [component.level] + for component: TowerComponent in current_tower.components.values(): + %Components.get_node(component.id).modulate = Color(1.0, 1.0, 1.0, 1.0) + %Components.get_node(component.id).get_node("Level").text = ": %s" % [component.level] func get_selected_towers() -> Array: @@ -40,87 +39,137 @@ 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: - tower.attack_range += 8 - tower.selection_group_id = tower.get_group_id() - Client.update_tower(tower.get_path(), tower.to_network_data()) - - Network.update_player.rpc(Client.player.id, { - "money": -cost, - }) - - %Data.text = "Range: %s - Power: %s - Speed: %s" % [ - current_tower.attack_range, current_tower.attack_power, current_tower.attack_speed - ] - - -func _on_power_plus_pressed() -> void: - var towers = get_selected_towers() - - 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: - tower.attack_power += 1 - tower.selection_group_id = tower.get_group_id() - Client.update_tower(tower.get_path(), tower.to_network_data()) - - Network.update_player.rpc(Client.player.id, { - "money": -cost, - }) - - %Data.text = "Range: %s - Power: %s - Speed: %s" % [ - current_tower.attack_range, current_tower.attack_power, current_tower.attack_speed - ] +#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: + #tower.attack_range += 8 + #tower.selection_group_id = tower.get_group_id() + #Client.update_tower(tower.get_path(), tower.to_network_data()) + # + #Network.update_player.rpc(Client.player.id, { + #"money": -cost, + #}) + # + ##%Data.text = "Range: %s - Power: %s - Speed: %s" % [ + ##current_tower.attack_range, current_tower.attack_power, current_tower.attack_speed + ##] +# +# +#func _on_power_plus_pressed() -> void: + #var towers = get_selected_towers() + # + #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: + #tower.attack_power += 1 + #tower.selection_group_id = tower.get_group_id() + #Client.update_tower(tower.get_path(), tower.to_network_data()) + # + #Network.update_player.rpc(Client.player.id, { + #"money": -cost, + #}) + # + ##%Data.text = "Range: %s - Power: %s - Speed: %s" % [ + ##current_tower.attack_range, current_tower.attack_power, current_tower.attack_speed + ##] +# +# +#func _on_speed_plus_pressed() -> void: + #var towers = get_selected_towers() + # + #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: + #tower.attack_speed += 1 + #tower.selection_group_id = tower.get_group_id() + #Client.update_tower(tower.get_path(), tower.to_network_data()) + # + #Network.update_player.rpc(Client.player.id, { + #"money": -cost, + #}) + # + ##%Data.text = "Range: %s - Power: %s - Speed: %s" % [ + ##current_tower.attack_range, current_tower.attack_power, current_tower.attack_speed + ##] + + +func _on_range_gui_input(event: InputEvent) -> void: + if event.is_action_pressed("select"): + get_viewport().set_input_as_handled() + + if current_tower.components.has(TowerComponent.ComponentType.Range): + 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/RangeComponent.gd").new()) + + Client.update_tower(tower.get_path(), tower.to_network_data()) + + Network.update_player.rpc(Client.player.id, { + "money": -cost, + }) -func _on_speed_plus_pressed() -> void: - var towers = get_selected_towers() - - 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: - tower.attack_speed += 1 - tower.selection_group_id = tower.get_group_id() - Client.update_tower(tower.get_path(), tower.to_network_data()) - - Network.update_player.rpc(Client.player.id, { - "money": -cost, - }) - - %Data.text = "Range: %s - Power: %s - Speed: %s" % [ - current_tower.attack_range, current_tower.attack_power, current_tower.attack_speed - ] +func _on_attack_gui_input(event: InputEvent) -> void: + if event.is_action_pressed("select"): + get_viewport().set_input_as_handled() + + if current_tower.components.has(TowerComponent.ComponentType.Attack): + 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/AttackComponent.gd").new()) + + Client.update_tower(tower.get_path(), tower.to_network_data()) + + Network.update_player.rpc(Client.player.id, { + "money": -cost, + }) 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"): + if current_tower.components.has(TowerComponent.ComponentType.Frost): Client.current_stage.add_status_message("Component already added") return @@ -132,16 +181,7 @@ func _on_frost_gui_input(event: InputEvent) -> void: return for tower: Tower in towers: - var found = false - for idx in range(tower.components.size()): - var component = tower.components[idx] - if component.name == "Frost": - found = true - tower.remove_component(component.name) - break - - if not found: - tower.add_component(preload("res://Towers/Components/FrostComponent.gd").new()) + tower.add_component(preload("res://Towers/Components/FrostComponent.gd").new()) Client.update_tower(tower.get_path(), tower.to_network_data()) @@ -154,7 +194,7 @@ 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"): + if current_tower.components.has(TowerComponent.ComponentType.Burn): Client.current_stage.add_status_message("Component already added") return @@ -166,16 +206,7 @@ func _on_burn_gui_input(event: InputEvent) -> void: return for tower: Tower in towers: - var found = false - for idx in range(tower.components.size()): - var component = tower.components[idx] - if component.name == "Burn": - found = true - tower.remove_component(component.name) - break - - if not found: - tower.add_component(preload("res://Towers/Components/BurnComponent.gd").new()) + tower.add_component(preload("res://Towers/Components/BurnComponent.gd").new()) Client.update_tower(tower.get_path(), tower.to_network_data()) @@ -184,14 +215,62 @@ func _on_burn_gui_input(event: InputEvent) -> void: }) +func _on_range_level_up_pressed() -> void: + var towers = get_selected_towers() + + var component: TowerComponent = current_tower.components.get(TowerComponent.ComponentType.Range) + + if not component: + return + + var cost = 25 * 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.Range) + + 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_attack_level_up_pressed() -> void: + var towers = get_selected_towers() + + var component: TowerComponent = current_tower.components.get(TowerComponent.ComponentType.Attack) + + 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.Attack) + + 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_frost_level_up_pressed() -> void: var towers = get_selected_towers() - var component: TowerComponent - for idx in range(current_tower.components.size()): - component = current_tower.components[idx] - if component.name == "Frost": - break + var component: TowerComponent = current_tower.components.get(TowerComponent.ComponentType.Frost) if not component: return @@ -202,14 +281,11 @@ func _on_frost_level_up_pressed() -> void: return for tower: Tower in towers: - var tower_component: TowerComponent - for idx in range(tower.components.size()): - tower_component = tower.components[idx] - if tower_component.name == "Frost": - break + var tower_component: TowerComponent = tower.components.get(TowerComponent.ComponentType.Frost) 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, { @@ -220,12 +296,7 @@ func _on_frost_level_up_pressed() -> void: func _on_burn_level_up_pressed() -> void: var towers = get_selected_towers() - var component: TowerComponent - for idx in range(current_tower.components.size()): - component = current_tower.components[idx] - if component.name == "Burn": - break - + var component: TowerComponent = current_tower.components.get(TowerComponent.ComponentType.Burn) if not component: return @@ -235,14 +306,11 @@ func _on_burn_level_up_pressed() -> void: return for tower: Tower in towers: - var tower_component: TowerComponent - for idx in range(tower.components.size()): - tower_component = tower.components[idx] - if tower_component.name == "Burn": - break + var tower_component: TowerComponent = tower.components.get(TowerComponent.ComponentType.Burn) 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, { @@ -250,28 +318,70 @@ func _on_burn_level_up_pressed() -> void: }) -func _on_range_plus_mouse_entered() -> void: +#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_range_mouse_entered() -> void: + if current_tower.components.has(TowerComponent.ComponentType.Range): + $Components/Range.tooltip_text = "" + return + 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) + var cost = 100 * towers.size() + $Components/Range.tooltip_text = "Cost: " + str(cost) -func _on_power_plus_mouse_entered() -> void: +func _on_range_level_up_mouse_entered() -> void: + var component = current_tower.components.get(TowerComponent.ComponentType.Range) + if not component: + $Components/Range/RangeLevelUp.tooltip_text = "" + return + + var towers = get_selected_towers() + var cost = 25 * component.level * towers.size() + $Components/Range/RangeLevelUp.tooltip_text = "Cost: " + str(cost) + +func _on_attack_mouse_entered() -> void: + if current_tower.components.has(TowerComponent.ComponentType.Attack): + $Components/Range.tooltip_text = "" + return + 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) + var cost = 100 * towers.size() + $Components/Attack.tooltip_text = "Cost: " + str(cost) -func _on_speed_plus_mouse_entered() -> void: +func _on_attack_level_up_mouse_entered() -> void: + var component = current_tower.components.get(TowerComponent.ComponentType.Attack) + if not component: + $Components/Attack/AttackLevelUp.tooltip_text = "" + return + 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) + var cost = 10 * component.level * towers.size() + $Components/Attack/AttackLevelUp.tooltip_text = "Cost: " + str(cost) func _on_frost_mouse_entered() -> void: + if current_tower.components.has(TowerComponent.ComponentType.Frost): + $Components/Range.tooltip_text = "" + return + 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") + var component = current_tower.components.get(TowerComponent.ComponentType.Frost) if not component: $Components/Frost/FrostLevelUp.tooltip_text = "" return @@ -281,12 +391,16 @@ func _on_frost_level_up_mouse_entered() -> void: $Components/Frost/FrostLevelUp.tooltip_text = "Cost: " + str(cost) func _on_burn_mouse_entered() -> void: + if current_tower.components.has(TowerComponent.ComponentType.Burn): + $Components/Range.tooltip_text = "" + return + 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") + var component = current_tower.components.get(TowerComponent.ComponentType.Burn) if not component: $Components/Burn/BurnLevelUp.tooltip_text = "" return diff --git a/Stages/Wintermaul/hud_tower.tscn b/Stages/Wintermaul/hud_tower.tscn index 533c6b9..4a23f10 100644 --- a/Stages/Wintermaul/hud_tower.tscn +++ b/Stages/Wintermaul/hud_tower.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=4 format=3 uid="uid://ei0ai7om3mkw"] +[gd_scene load_steps=6 format=3 uid="uid://ei0ai7om3mkw"] [ext_resource type="Texture2D" uid="uid://ba3dmlce1wv2p" path="res://Towers/Components/Assets/frost-component.png" id="1_1rlop"] [ext_resource type="Script" path="res://Stages/Wintermaul/hud_tower.gd" id="1_aog4m"] +[ext_resource type="Texture2D" uid="uid://dx07y4scyi5a1" path="res://Towers/Components/Assets/range-component.png" id="2_epopi"] [ext_resource type="Texture2D" uid="uid://2djpswd6sgng" path="res://Towers/Components/Assets/burn-component.png" id="2_gcd2r"] +[ext_resource type="Texture2D" uid="uid://gbknvb38euuq" path="res://Towers/Components/Assets/attack-component.png" id="3_xygpi"] [node name="HUDTower" type="VBoxContainer"] offset_left = 64.0 @@ -12,10 +14,12 @@ script = ExtResource("1_aog4m") [node name="Data" type="Label" parent="."] unique_name_in_owner = true +visible = false layout_mode = 2 text = "Data" [node name="HBoxContainer" type="HBoxContainer" parent="."] +visible = false layout_mode = 2 [node name="RangePlus" type="Button" parent="HBoxContainer"] @@ -40,6 +44,52 @@ text = "+Speed" unique_name_in_owner = true layout_mode = 2 +[node name="Range" type="HBoxContainer" parent="Components"] +layout_mode = 2 +mouse_default_cursor_shape = 2 + +[node name="TextureRect" type="TextureRect" parent="Components/Range"] +custom_minimum_size = Vector2(32, 0) +layout_mode = 2 +texture = ExtResource("2_epopi") +stretch_mode = 5 + +[node name="Label" type="Label" parent="Components/Range"] +layout_mode = 2 +text = "Range" + +[node name="Level" type="Label" parent="Components/Range"] +layout_mode = 2 +text = ": 1" + +[node name="RangeLevelUp" type="Button" parent="Components/Range"] +layout_mode = 2 +mouse_default_cursor_shape = 2 +text = "+Level" + +[node name="Attack" type="HBoxContainer" parent="Components"] +layout_mode = 2 +mouse_default_cursor_shape = 2 + +[node name="TextureRect" type="TextureRect" parent="Components/Attack"] +custom_minimum_size = Vector2(32, 0) +layout_mode = 2 +texture = ExtResource("3_xygpi") +stretch_mode = 5 + +[node name="Label" type="Label" parent="Components/Attack"] +layout_mode = 2 +text = "Attack" + +[node name="Level" type="Label" parent="Components/Attack"] +layout_mode = 2 +text = ": 1" + +[node name="AttackLevelUp" type="Button" parent="Components/Attack"] +layout_mode = 2 +mouse_default_cursor_shape = 2 +text = "+Level" + [node name="Frost" type="HBoxContainer" parent="Components"] layout_mode = 2 mouse_default_cursor_shape = 2 @@ -92,6 +142,14 @@ text = "+Level" [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/Range" to="." method="_on_range_gui_input"] +[connection signal="mouse_entered" from="Components/Range" to="." method="_on_range_mouse_entered"] +[connection signal="mouse_entered" from="Components/Range/RangeLevelUp" to="." method="_on_range_level_up_mouse_entered"] +[connection signal="pressed" from="Components/Range/RangeLevelUp" to="." method="_on_range_level_up_pressed"] +[connection signal="gui_input" from="Components/Attack" to="." method="_on_attack_gui_input"] +[connection signal="mouse_entered" from="Components/Attack" to="." method="_on_attack_mouse_entered"] +[connection signal="mouse_entered" from="Components/Attack/AttackLevelUp" to="." method="_on_attack_level_up_mouse_entered"] +[connection signal="pressed" from="Components/Attack/AttackLevelUp" to="." method="_on_attack_level_up_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"] diff --git a/Stages/Wintermaul/wintermaul.gd b/Stages/Wintermaul/wintermaul.gd index 95d914a..90abf6b 100644 --- a/Stages/Wintermaul/wintermaul.gd +++ b/Stages/Wintermaul/wintermaul.gd @@ -59,7 +59,7 @@ func _ready(): if multiplayer.is_server(): for player in Network.get_players(): Network.update_player.rpc(player.id, { - "money": 50, + "money": 50 * 10000, "income": 5, }) |