Permalink
Browse files

Protection towers now need energy to function.

  • Loading branch information...
dfloer committed Nov 8, 2018
1 parent bebaace commit 56fca634cc7d58e8a1d3de0da72a9e139e2ea53b
Showing with 16 additions and 2 deletions.
  1. +16 −2 cocos2d.py
View
@@ -385,7 +385,7 @@ def plop_building(self, cell, building):
if cell not in terrain_map.buildings.keys():
network_layer.plop_network(cell, "sink")
terrain_map.add_building(cell, building)
if building.building_id == 3:
if building.building_id == 3 and network_map.network[cell]["powered"]:
terrain_map.add_safe_area(cell, 2, 3)
overlay_layer.draw_safe()
self.draw_buildings()
@@ -408,7 +408,7 @@ def remove_building(self, cell):
terrain_map.remove_building(cell)
self.buildings_batch.remove(name)
self.draw_buildings()
if building_id == 3:
if building_id == 3 and network_map.network[cell]["powered"]:
terrain_map.add_safe_area(cell, -2, 3)
overlay_layer.draw_safe()
@@ -484,10 +484,24 @@ def update_powered(self):
"""
powered = self.find_all_connected(Hexagon(0, 0, 0))
for n in self.network:
previous_powered = self.network[n]["powered"]
if n in powered:
self.network[n]["powered"] = True
else:
self.network[n]["powered"] = False
try:
if terrain_map.buildings[n].building_id == 3:
p = 0
# This tile is making the transition from unpowered to powered
if self.network[n]["powered"] and not previous_powered:
p = 2
# This tile was previously powered but isn't anymore.
elif not self.network[n]["powered"] and previous_powered:
p = -2
terrain_map.add_safe_area(n, p, 3)
overlay_layer.draw_safe()
except KeyError:
pass
def find_connected(self, cell_source, cell_destination):

0 comments on commit 56fca63

Please sign in to comment.