Final 2.0
This commit is contained in:
+16
-2
@@ -1,6 +1,8 @@
|
||||
import random
|
||||
import uuid
|
||||
from units import rat, bomb, mine, points
|
||||
from units import gas, rat, bomb, mine
|
||||
|
||||
|
||||
|
||||
class UnitManager:
|
||||
def count_rats(self):
|
||||
@@ -9,7 +11,16 @@ class UnitManager:
|
||||
if isinstance(unit, rat.Rat):
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
def spawn_gas(self, parent_id=None):
|
||||
if self.map.is_wall(self.pointer[0], self.pointer[1]):
|
||||
return
|
||||
if self.ammo["gas"]["count"] <= 0:
|
||||
return
|
||||
self.ammo["gas"]["count"] -= 1
|
||||
self.render_engine.play_sound("GAS.WAV")
|
||||
self.spawn_unit(gas.Gas, self.pointer, parent_id=parent_id)
|
||||
|
||||
def spawn_rat(self, position=None):
|
||||
if position is None:
|
||||
position = self.choose_start()
|
||||
@@ -57,3 +68,6 @@ class UnitManager:
|
||||
if self.map.matrix[y][x]
|
||||
]
|
||||
return random.choice(self._valid_positions)
|
||||
|
||||
def get_unit_by_id(self, id):
|
||||
return self.units.get(id) or None
|
||||
|
||||
Reference in New Issue
Block a user