oldschool-toontown/toontown/safezone/DistributedEFlyingTreasure.py

43 lines
1.5 KiB
Python
Raw Normal View History

2019-11-02 17:27:54 -05:00
from pandac.PandaModules import *
from toontown.toonbase.ToonBaseGlobal import *
from . import DistributedSZTreasure
2019-11-02 17:27:54 -05:00
from direct.task.Task import Task
import math
import random
class DistributedEFlyingTreasure(DistributedSZTreasure.DistributedSZTreasure):
def __init__(self, cr):
DistributedSZTreasure.DistributedSZTreasure.__init__(self, cr)
self.modelPath = 'phase_5.5/models/props/popsicle_treasure'
2020-01-14 13:28:52 -06:00
self.grabSoundPath = 'phase_4/audio/sfx/SZ_DD_treasure.ogg'
2019-11-02 17:27:54 -05:00
self.scale = 2
self.delT = math.pi * 2.0 * random.random()
self.shadow = 0
def disable(self):
DistributedSZTreasure.DistributedSZTreasure.disable(self)
taskMgr.remove(self.taskName('flying-treasure'))
def generateInit(self):
DistributedSZTreasure.DistributedSZTreasure.generateInit(self)
def setPosition(self, x, y, z):
DistributedSZTreasure.DistributedSZTreasure.setPosition(self, x, y, z)
self.initPos = self.nodePath.getPos()
self.pos = self.nodePath.getPos()
def startAnimation(self):
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)
dY = 2.0 * math.cos(t + self.delT)
self.nodePath.setPos(pos[0], pos[1], pos[2] + dZ)
if self.pos:
del self.pos
self.pos = self.nodePath.getPos()
return Task.cont