From 6f17d6c1d458275e8744d57a7f433cc3eb5434d7 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 6 Nov 2024 12:27:51 +0100 Subject: next commit --- Stages/Wintermaul/wintermaul.gd | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'Stages/Wintermaul/wintermaul.gd') 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") -- cgit v1.2.3