2015-08-10 08:33:28 -05:00
|
|
|
from DistributedTreasure import DistributedTreasure
|
|
|
|
import math, random
|
2015-03-03 16:10:12 -06:00
|
|
|
|
2015-08-10 08:33:28 -05:00
|
|
|
class DistributedEFlyingTreasure(DistributedTreasure):
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
def __init__(self, cr):
|
2015-08-10 08:33:28 -05:00
|
|
|
DistributedTreasure.__init__(self, cr)
|
2015-03-03 16:10:12 -06:00
|
|
|
self.scale = 2
|
|
|
|
self.delT = math.pi * 2.0 * random.random()
|
|
|
|
self.shadow = 0
|
|
|
|
|
|
|
|
def disable(self):
|
2015-08-10 08:33:28 -05:00
|
|
|
DistributedTreasure.disable(self)
|
2015-03-03 16:10:12 -06:00
|
|
|
taskMgr.remove(self.taskName('flying-treasure'))
|
|
|
|
|
|
|
|
def setPosition(self, x, y, z):
|
2015-08-10 08:33:28 -05:00
|
|
|
DistributedTreasure.setPosition(self, x, y, z)
|
2015-03-03 16:10:12 -06:00
|
|
|
self.initPos = self.nodePath.getPos()
|
|
|
|
taskMgr.add(self.animateTask, self.taskName('flying-treasure'))
|
|
|
|
|
|
|
|
def animateTask(self, task):
|
|
|
|
pos = self.initPos
|
|
|
|
t = 0.5 * math.pi * globalClock.getFrameTime()
|
|
|
|
dZ = 5.0 * math.sin(t + self.delT)
|
|
|
|
self.nodePath.setPos(pos[0], pos[1], pos[2] + dZ)
|
2015-08-10 08:33:28 -05:00
|
|
|
return task.cont
|