-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArcherSpawner.py
60 lines (37 loc) · 1.7 KB
/
ArcherSpawner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'''
Created on Oct 23, 2010
@author: lucas
'''
from Building import Building
from Archer import Archer
from Paintable import loadImage
from Constants import *
class ArcherSpawner(Building):
def __init__(self, x, y, terrain, team):
Building.__init__(self, x,y,terrain, BUILDING_LIFE, BUILDING_REGENERATION, team, "art/building1.png")
if team == 0:
self.image = loadImage('art/armory.png', (255,255,255))
else:
self.image = loadImage('art/egyptian_armory.png', (255,255,255))
self.archers = []
self.numArchers = 0
self.maxNumberArchers = MAX_NUMBER_ARCHERS
self.spawTime = ARCHER_SPAWN_TIME
self.timer = 0
def process(self, terrain, population):
self.timer += TIME_QUANTUM
if(self.numArchers < self.maxNumberArchers):
if(self.timer > self.spawTime):
archer = Archer(self.x - 1, self.y - 1, self.team)
if(population.addCreature(self.x - 1, self.y - 1, archer, terrain)):
self.timer = 0
self.numArchers += 1
self.archers.append(archer)
else:
pass
else:
for i in range(self.numArchers):
if(self.archers[i].isAlive() == False):
self.archers.remove(self.archers[i])
self.numArchers -= 1
return