-
Notifications
You must be signed in to change notification settings - Fork 0
/
characters.py
245 lines (204 loc) · 8.18 KB
/
characters.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
from config import *
from utils import *
import factory
import attack
import weapons
import AI
import inventory
import particles
defaultAI = AI.DmgAvoiderAttacker
# defaultAI = AI.Basic
class SoldierFactory(factory.GameObjectFactory):
def __init__(self):
super(SoldierFactory, self).__init__()
self.values['width'] = 1.0
self.values['height'] = 1.0
self.values['artWidth'] = 1.0
self.values['artHeight'] = 1.5
self.values['mass'] = 100.0 # kg
self.values['pixelWidth'] = 16 # size of the sprite image, depends on image size, shouldn't change
self.values['pixelHeight'] = 24 # size of the sprite image, depends on image size, shouldn't change
self.values['max_velocity'] = 2.0 #m/s
self.values['objectType'] = 'Soldier'
self.values['type'] = "character"
self.values['team_id'] = 1
self.values['hitSoundFX'] = 'grunt1'
self.values['deathSoundFX'] = 'death1'
self.values['damage_objects'] = ['Explosion']
self.values['death_objects'] = ['Blood1', 'Ghost1']
self.values['weapon'] = weapons.soldierWeapon1FCT
self.ai_class = defaultAI
def create(self, x, y):
self.values['attacker'] = attack.Attacker(self.values['weapon']) # want unique instance
object = super().create(x, y)
# set health
if 'health' in self.values: object.attacker.set_health(self.values['health'])
# set AI type
object.AI = self.ai_class(object)
# object.AI = AI.Basic(object)
# callbacks
getattr(object, 'callbacks')['attack'] = object.attacker.attack
# setup
object.setSpriteStatus(visible=True, has_sprite=True)
indices = np.array(4*[[0,0,1,1,2,2,1,1,0,0,3,3,4,4,3,3]])
indices[0] += 10
indices[2] += 5
for i in range(4):
object.animation.register_indices(i, indices[i])
return object
class PlayerFactory(SoldierFactory):
def __init__(self):
super(PlayerFactory, self).__init__()
self.values['max_velocity'] = 4.0 #m/s
self.values['artWidth'] = 1.0
self.values['artHeight'] = 1.5
self.values['team_id'] = 0
self.values['weapon'] = weapons.playerWeapon1FCT
def create(self, x, y):
# self.values['attacker'] = attack.Attacker(weapons.playerWeapon1FCT) # want unique instance
self.values['attacker'] = attack.Attacker(self.values['weapon']) # want unique instance
object = super().create(x, y)
# set health
object.attacker.set_health(200.0)
object.attacker.mana_regen = 10.0 # mana per second
# give an inventory
object.inventory = inventory.Inventory(object)
# give 5 small health potions
potion = inventory.Potion(50.0)
potion.count = 5
object.inventory.add_item(potion)
# callbacks
getattr(object, 'callbacks')['attack'] = object.attacker.attack
# setup
object.setSpriteStatus(visible=True, has_sprite=True)
indices = np.array(4*[[0,0,1,1,2,2,1,1,0,0,3,3,4,4,3,3]])
indices[0] += 10
indices[2] += 5
for i in range(4):
object.animation.register_indices(i, indices[i])
return object
class MiniSoldierFactory(SoldierFactory):
def __init__(self):
super().__init__()
factor = 0.75
self.values['width'] *= factor
self.values['height'] *= factor
self.values['artWidth'] *= factor
self.values['artHeight'] *= factor
self.values['mass'] = 100.0 # kg
self.values['max_velocity'] = 3.0 / factor #m/s
self.values['objectType'] = 'MiniSoldier'
self.ai_class = defaultAI
class MegaSoldierFactory(SoldierFactory):
factor = 4.0
def __init__(self):
super().__init__()
self.values['width'] *= self.factor
self.values['height'] *= self.factor
self.values['artWidth'] *= self.factor
self.values['artHeight'] *= self.factor
self.values['mass'] = 100.0 * self.factor # kg
self.values['max_velocity'] = 3.0 / self.factor #m/s
self.values['objectType'] = 'MegaSoldier'
self.values['death_objects'] = ['BigBlood1', 'BigGhost1']
self.ai_class = defaultAI
class BigGhostParticleFactory(factory.GhostParticleFactory):
def __init__(self):
super().__init__()
self.values['objectType'] = 'BigGhost1' # for drawing purposes
self.values['width'] = 1.0 * MegaSoldierFactory.factor
self.values['height'] = 1.0 * MegaSoldierFactory.factor
self.values['artWidth'] = 1.0 * MegaSoldierFactory.factor
self.values['artHeight'] = 1.0 * MegaSoldierFactory.factor
class BigBloodParticleFactory(factory.BloodParticleFactory):
def __init__(self):
super().__init__()
self.values['objectType'] = 'BigBlood1' # for drawing purposes
self.values['width'] = 1.0 * MegaSoldierFactory.factor
self.values['height'] = 1.0 * MegaSoldierFactory.factor
self.values['artWidth'] = 1.0 * MegaSoldierFactory.factor
self.values['artHeight'] = 1.0 * MegaSoldierFactory.factor
class ArcherFactory(factory.GameObjectFactory):
def __init__(self):
super().__init__()
self.values['width'] = 1.0
self.values['height'] = 1.0
self.values['artWidth'] = 1.0
self.values['artHeight'] = 1.5
self.values['mass'] = 100.0 # kg
self.values['pixelWidth'] = 16 # size of the sprite image, depends on image size, shouldn't change
self.values['pixelHeight'] = 24 # size of the sprite image, depends on image size, shouldn't change
self.values['max_velocity'] = 3.0 #m/s
self.values['objectType'] = 'Archer' # for drawing purposes
self.values['type'] = "character"
self.values['team_id'] = 1
self.values['weapon'] = weapons.arrow5FCT
self.values['hitSoundFX'] = 'grunt1'
self.values['deathSoundFX'] = 'death1'
self.values['damage_objects'] = ['Explosion']
self.values['death_objects'] = ['Blood1', 'Ghost1']
self.ai_class = defaultAI
def create(self, x, y):
self.values['attacker'] = attack.Attacker(self.values['weapon']) # want unique instance
object = super().create(x, y)
# set health
if 'health' in self.values: object.attacker.set_health(self.values['health'])
# set AI type
object.AI = self.ai_class(object)
object.AI.dist_threshold = 5.5
# object.AI = AI.Basic(object)
# callbacks
getattr(object, 'callbacks')['attack'] = object.attacker.attack
# setup
object.setSpriteStatus(visible=True, has_sprite=True)
indices = np.array(4*[[0, 1, 2, 1, 0, 3, 4, 3]])
indices[0] += 10
indices[2] += 5
for i in range(4):
object.animation.register_indices(i, indices[i])
return object
class Archer2Factory(ArcherFactory):
def __init__(self):
super().__init__()
self.values['objectType'] = 'Archer2' # for drawing purposes
class Archer3Factory(ArcherFactory):
def __init__(self):
super().__init__()
self.values['objectType'] = 'Archer3' # for drawing purposes
class Archer4Factory(ArcherFactory):
def __init__(self):
super().__init__()
self.values['objectType'] = 'Archer4' # for drawing purposes
class BallOnChainGuyFactory(ArcherFactory):
def __init__(self):
super().__init__()
self.values['objectType'] = 'Soldier' # for drawing purposes
self.values['weapon'] = weapons.ballOnChain2FCT
self.values['health'] = 100.0
self.values['max_velocity'] = 1.0
self.values['armor'] = ["projectile"]
class Boss1(MegaSoldierFactory):
def __init__(self):
super().__init__()
self.values['weapon'] = weapons.ballOnChainFCT
self.values['health'] = 300.0
self.values['max_velocity'] = 1.0
self.values['armor'] = ["projectile"]
self.ai_class = AI.Boss1Meta
def create(self, x, y):
self.values['attacker'] = attack.Attacker(self.values['weapon']) # want unique instance
object = super(SoldierFactory, self).create(x, y)
# set health
if 'health' in self.values: object.attacker.set_health(self.values['health'])
# give an inventory
object.inventory = inventory.Inventory(object)
object.inventory.add_item(inventory.Boss1Weapon1())
object.inventory.add_item(inventory.Boss1Weapon2())
# set AI type
object.AI = self.ai_class(object)
# object.AI = AI.Basic(object)
# callbacks
getattr(object, 'callbacks')['attack'] = object.attacker.attack
# setup
object.setSpriteStatus(visible=True, has_sprite=True)
return object