OK
This commit is contained in:
+23
-4
@@ -17,19 +17,38 @@ class UnitManager:
|
||||
self.spawn_unit(rat_class, position)
|
||||
|
||||
def spawn_bomb(self, position):
|
||||
if self.ammo["bomb"]["count"] <= 0:
|
||||
return
|
||||
self.render_engine.play_sound("PUTDOWN.WAV")
|
||||
self.spawn_unit(bomb.Timer, position)
|
||||
self.ammo["bomb"]["count"] -= 1
|
||||
|
||||
def spawn_nuclear_bomb(self, position):
|
||||
"""Spawn a nuclear bomb at the specified position"""
|
||||
if self.ammo["nuclear"]["count"] <= 0:
|
||||
return
|
||||
if self.map.is_wall(position[0], position[1]):
|
||||
return
|
||||
self.render_engine.play_sound("NUCLEAR.WAV")
|
||||
self.ammo["nuclear"]["count"] -= 1
|
||||
self.spawn_unit(bomb.NuclearBomb, position)
|
||||
|
||||
def spawn_mine(self, position):
|
||||
if self.ammo["mine"]["count"] <= 0:
|
||||
return
|
||||
if self.map.is_wall(position[0], position[1]):
|
||||
return
|
||||
self.render_engine.play_sound("PUTDOWN.WAV")
|
||||
self.spawn_unit(mine.Mine, position)
|
||||
self.ammo["mine"]["count"] -= 1
|
||||
self.spawn_unit(mine.Mine, position, on_bottom=True)
|
||||
|
||||
def spawn_unit(self, unit, position, **kwargs):
|
||||
def spawn_unit(self, unit, position, on_bottom=False, **kwargs):
|
||||
id = uuid.uuid4()
|
||||
self.units[id] = unit(self, position, id, **kwargs)
|
||||
|
||||
if on_bottom:
|
||||
self.units = {id: unit(self, position, id, **kwargs), **self.units}
|
||||
else:
|
||||
self.units[id] = unit(self, position, id, **kwargs)
|
||||
|
||||
def choose_start(self):
|
||||
if not hasattr(self, '_valid_positions'):
|
||||
self._valid_positions = [
|
||||
|
||||
Reference in New Issue
Block a user