diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-11-26 17:13:40 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-11-26 17:13:40 +0100 |
commit | cb9bb9d1c757b53707c741a3c8c218b513ffb5ec (patch) | |
tree | 1e3741a70672504d71685db98b22f7fe61e0e6cb /Stages/Wintermaul/wintermaul.gd | |
parent | 72863ffa31e27f4c6be862d80472cfb897fccaea (diff) |
next commit
Diffstat (limited to 'Stages/Wintermaul/wintermaul.gd')
-rw-r--r-- | Stages/Wintermaul/wintermaul.gd | 93 |
1 files changed, 41 insertions, 52 deletions
diff --git a/Stages/Wintermaul/wintermaul.gd b/Stages/Wintermaul/wintermaul.gd index 82170c7..0de2cdb 100644 --- a/Stages/Wintermaul/wintermaul.gd +++ b/Stages/Wintermaul/wintermaul.gd @@ -9,6 +9,7 @@ class Teams extends Resource: var bottom := Team.new() func list() -> Array[Team]: return [top, bottom] + func names() -> Array[String]: return ["top", "bottom"] class Team extends Resource: var lives := 0 @@ -18,45 +19,39 @@ var teams := Teams.new() var income_frequency := 15.0 -var price_map = { - "tower": { - "cost": 5, - "attack_range": func(attack_range: int, number_of_towers: int = 1): - return (attack_range / 8.0) * 10 * number_of_towers - , - "attack_power": func(attack_power: int, number_of_towers: int = 1): - return attack_power * 10 * number_of_towers - , - "attack_speed": func(attack_speed: int, number_of_towers: int = 1): - return attack_speed * 10 * number_of_towers - , - }, - - "unit": { - "tiers": [ - { - "cost": 5, - "income": 1, - }, - { - "cost": 10, - "income": 3, - }, - { - "cost": 15, - "income": 5, - }, - { - "cost": 20, - "income": 7, - }, - ], - }, -} +class PriceMapTower: + static var cost: int = 5 + + static func component_range(number_of_towers: int = 1): + return 100 * number_of_towers + static func component_range_level(component: TowerComponent, number_of_towers: int = 1): + return pow(5, component.level) * number_of_towers + + static func component_attack(number_of_towers: int = 1): + return 100 * number_of_towers + static func component_attack_level(component: TowerComponent, number_of_towers: int = 1): + return 10 * component.level * number_of_towers + + static func component_frost(number_of_towers: int = 1): + return 100 * number_of_towers + static func component_frost_level(component: TowerComponent, number_of_towers: int = 1): + return 10 * component.level * number_of_towers + + static func component_burn(number_of_towers: int = 1): + return 100 * number_of_towers + static func component_burn_level(component: TowerComponent, number_of_towers: int = 1): + return 10 * component.level * number_of_towers + + static func component_poison(number_of_towers: int = 1): + return 100 * number_of_towers + static func component_poison_level(component: TowerComponent, number_of_towers: int = 1): + return 10 * component.level * number_of_towers var starting_lives := 10 var starting_money := 50 var starting_income := 5 +var use_premade_teams := false +var premade_teams := {} func _init(): @@ -88,8 +83,13 @@ func _ready(): # add players to teams Network.player_joined.connect(add_player) - for id in Network.get_ordered_player_ids(): - add_player(Network.get_player(id)) + if use_premade_teams: + for team_name in premade_teams: + for id in premade_teams[team_name]: + teams[team_name].players.append(Network.get_player(id)) + else: + for id in Network.get_ordered_player_ids(): + add_player(Network.get_player(id)) # set camera for local player if get_team(Client.player) == teams.top: @@ -122,7 +122,7 @@ func place_tower(remote_data: Dictionary): var player = Network.get_player(tower.owner_id) player.towers[tower.global_position] = tower - player.money -= price_map.tower.cost + player.money -= PriceMapTower.cost Network.players_changed.emit() _place_tower(%Towers, tower) @@ -137,17 +137,6 @@ func spawn_unit(remote_data: Dictionary): var player = Network.get_player(unit.owner_id) player.units.append(unit) - # TODO: make better. create WintermaulUnit? instead of additional_data. - # TODO: potentially better price map as well with better idx access - #var tier_idx := 0 - #for idx in price_map.unit.tiers.size(): - #var tier = price_map.unit.tiers[idx] - #if tier.cost == unit.additional_data["cost"]: - #tier_idx = idx - #break - - #player.money -= price_map.unit.tiers[tier_idx].cost - #player.income += price_map.unit.tiers[tier_idx].income player.money -= unit.unit_resource.cost player.income += unit.unit_resource.income Network.players_changed.emit() @@ -165,14 +154,14 @@ func spawn_unit(remote_data: Dictionary): func can_place_tower(): - if Client.player.money < price_map.tower.cost: + if Client.player.money < PriceMapTower.cost: add_status_message("Not enough money to build tower") return false return true -func can_spawn_unit(tier_idx: int = 0): - if Client.player.money < price_map.unit.tiers[tier_idx].cost: +func can_spawn_unit(unit: Unit): + if Client.player.money < unit.unit_resource.cost: add_status_message("Not enough money to spawn unit") return false |