/
CollectibleTypes.py
95 lines (77 loc) · 2.52 KB
/
CollectibleTypes.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
import random
from pandac.PandaModules import (
# AmbientLight,
# DirectionalLight,
PointLight,
NodePath,
Vec3,
# Vec4,
Point3,
# Quat,
OdeUtil,
# OdeWorld,
# OdeHashSpace,
# OdeJointGroup,
OdeMass,
OdeBody,
OdeSphereGeom,
OdeBoxGeom,
BitMask32
# TextNode
)
from Collectible import Collectible
class Pallo(Collectible):
# COLLECTIBLE_TYPE = 'PointBall'
# VALUE = 1
# DRAIN = 20
def __init__(self, game, color, value = 1, drain = 20):
self.game = game
self.VALUE = value
self.DRAIN = drain
#self.idnumber = id
self.visualNode = NodePath('Visual node')
self.visualNode.reparentTo(render)
model = loader.loadModel('Ball2.egg')
model.setScale(2.5)
model.reparentTo(self.visualNode)
plight = PointLight('plight')
plight.setPoint( Point3(0, 0, 3) )
plight.setColor( color )
plight.setAttenuation( Vec3(0.05, 0.01, 0.01) )
self.plightNodePath = model.attachNewNode(plight)
model.setLight(self.plightNodePath)
self.body = OdeBody(game.physicsWorld)
self.mass = OdeMass()
self.mass.setBox(10,1,1,1)
self.body.setMass(self.mass)
self.body.setGravityMode(True)
#self.body.setGravityMode(False)
#self.juttu = OdeUtil()
self.collGeom = OdeSphereGeom( self.game.physicsSpace, 3.5)
self.collGeom.setBody(self.body)
self.collGeom.setCategoryBits( BitMask32(0xffffffff) )
self.collGeom.setCollideBits( BitMask32(0xffffffff) )
def getValue(self):
return self.VALUE
def hitShips(self, shipList):
for ship in shipList:
if OdeUtil.areConnected(ship.body, self.body) and not ship.hasBall():
self.PowerUpEffect(ship)
def PowerUpEffect(self, ship):
# ship.mass.add(self.mass)
ship.addPower(-(self.DRAIN))
ship.gotBall(self)
self.hideObject()
ship.visualNode.setLight(self.plightNodePath)
#print player
print ship.SHIP_TYPE + " lost " + str(self.DRAIN) + " power!!"
def Restore(self, ship):
# ship.mass.add(self.mass)
ship.addPower(self.DRAIN)
self.showObject()
ship.visualNode.clearLight(self.plightNodePath)
#self.setPos( Vec3(random.randrange(30), random.randrange(40), 0))
#ship.dropBall()
#print player
print ship.getShipType() + " regained 20 power!!"
# def releaseForces(self, ship):