-
Notifications
You must be signed in to change notification settings - Fork 0
/
boss.py
87 lines (70 loc) · 2.58 KB
/
boss.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
#======================================================================#
#
# Team:
# Hunter Quant
# Edward Pryor
# Nick Marasco
# Shane Peterson
# Brandon Williams
# Jeremy Rose
#
# Last modification: 12/5/14 by: Brandon
# Description: Stuff needed for the boss
#
#======================================================================#
from enemy import Enemy
from weapons import ChargeCannon
from direct.actor.Actor import Actor
from panda3d.ai import AIWorld, AICharacter
from panda3d.core import CollisionNode, CollisionSphere, CollisionTube, NodePath
from panda3d.core import CollisionTraverser, CollisionHandlerEvent
from direct.task import Task
class Boss(Enemy):
#Spawns boss enemy
def __init__(self, model, ident):
Enemy.__init__(self, model, ident)
self.enemy = Actor(model)
self.enemy.reparentTo(self.enemyNode)
self.enemy.setScale(5)
self.health = 200
self.damage = 20
self.weapon = ChargeCannon(base.camera, self.enemy)
#configure hit tube
self.cs = CollisionTube(0, 0, 0, 0, 0, 0, 1.5)
#init cnode
self.cnodepath = self.enemy.attachNewNode(CollisionNode('cnode'+str(id)))
self.cnodepath.setTag('objectTag', str(id))
self.cnodepath.node().addSolid(self.cs)
#so we can walk into the enimies
self.chand = CollisionHandlerEvent()
# must be same cTrav that was set in player, global collider thing
base.cTrav.addCollider(self.cnodepath, self.chand)
self.accept('cnode'+str(id), self.hit)
#Fires boss projectile
def fire(self):
base.taskMgr.add(self.weapon.fire, "boss fire")
#Adds boss AI
def setAI(self):
self.AIChar = AICharacter("boss", self.enemy, 100, .05, 25)
self.AIWorld.addAiChar(self.AIChar)
self.AIbehaviors = self.AIChar.getAiBehaviors()
self.AIbehaviors.pursue(base.camera)
base.taskMgr.add(self.AIUpdate, "Boss AI Update")
#Updates boss AI
def AIUpdate(self,task):
if not self.deadFlag:
if not self.pauseFlag:
self.AIbehaviors.resumeAi("pursue")
self.fireDelta+=1
if self.fireDelta >= 90:
self.fireDelta = 0
self.fire()
self.pickuppos = self.enemy.getPos()
self.AIWorld.update()
return Task.cont
def pause(self):
self.AIbehaviors.pauseAi("pursue")
self.pauseFlag = True
def resume(self):
#self.AIbehaviors.resumeAi("puruse")
self.pauseFlag = False