コード例 #1
0
class DGPlayground(Playground.Playground):
    notify = directNotify.newCategory("DGPlayground")

    def __init__(self, loader, parentFSM, doneEvent):
        Playground.Playground.__init__(self, loader, parentFSM, doneEvent)
        self.birdSfx = None

    def enter(self, requestStatus):
        Playground.Playground.enter(self, requestStatus)
        self.startBirds()

    def startBirds(self):
        taskMgr.add(self.birdTask, "DGPlayground-birdTask")

    def stopBirds(self):
        taskMgr.remove("DGPlayground-birdTask")
        if self.birdSfx:
            self.birdSfx.finish()
            self.birdSfx = None

    def birdTask(self, task):
        noiseFile = random.choice(self.loader.birdNoises)
        noise = base.loadSfx(noiseFile)
        if self.birdSfx:
            self.birdSfx.finish()
            self.birdSfx = None
        self.birdSfx = SoundInterval(noise)
        self.birdSfx.start()
        task.delayTime = random.random() * 20 + 1
        return task.again

    def exit(self):
        self.stopBirds()
        Playground.Playground.exit(self)
コード例 #2
0
ファイル: VineBat.py プロジェクト: ghost4499/toontown-online
 def __init__(self, batIndex, timeToTraverseField):
     NodePath.__init__(self, 'VineBat')
     DirectObject.__init__(self)
     pos = Point3(0, 0, 0)
     serialNum = 0
     gameId = 0
     self.serialNum = serialNum
     self.batIndex = batIndex
     self.timeToTraverseField = timeToTraverseField
     gameAssets = loader.loadModel('phase_4/models/minigames/vine_game')
     bat3 = gameAssets.find('**/bat3')
     bat2 = gameAssets.find('**/bat2')
     bat1 = gameAssets.find('**/bat__1')
     seqNode = SequenceNode.SequenceNode('bat')
     seqNode.addChild(bat1.node())
     seqNode.addChild(bat2.node())
     seqNode.addChild(bat3.node())
     seqNode.setFrameRate(12)
     seqNode.pingpong(False)
     self.batModel = self.attachNewNode(seqNode)
     self.batModel.reparentTo(self)
     gameAssets.removeNode()
     self.batModelIcon = self.attachNewNode('batIcon')
     self.batModel.copyTo(self.batModelIcon)
     regularCamMask = BitMask32.bit(0)
     self.batModelIcon.hide(regularCamMask)
     self.batModelIcon.show(VineGameGlobals.RadarCameraBitmask)
     self.batModelIcon.setScale(0.55)
     self.batModel.setScale(0.15)
     self.setPos(-100, 0, 0)
     center = Point3(0, 0, 0)
     self.sphereName = 'batSphere-%s-%s' % (gameId, self.serialNum)
     self.collSphere = CollisionSphere(center[0], center[1], center[2],
                                       self.RADIUS)
     self.collSphere.setTangible(0)
     self.collNode = CollisionNode(self.sphereName)
     self.collNode.setIntoCollideMask(VineGameGlobals.SpiderBitmask)
     self.collNode.addSolid(self.collSphere)
     self.collNodePath = self.attachNewNode(self.collNode)
     self.collNodePath.hide()
     self.accept('enter' + self.sphereName, self.__handleEnterSphere)
     self.screechSfx = base.loadSfx(
         'phase_4/audio/sfx/MG_sfx_vine_game_bat_shriek_3.mp3')
     self.flySfx = base.loadSfx(
         'phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.wav')
     self.oldCutoffDistance = base.sfxPlayer.getCutoffDistance()
     base.sfxPlayer.setCutoffDistance(240)
     self.soundInterval = SoundInterval(self.flySfx,
                                        node=self,
                                        listenerNode=base.localAvatar,
                                        seamlessLoop=True,
                                        volume=0.5,
                                        cutOff=240)
     self.reparentTo(render)
     self.startedFlying = False
     self.warnedForThisLap = False
     startX = VineGameGlobals.VineXIncrement * VineGameGlobals.NumVines
     endX = -VineGameGlobals.VineXIncrement
     self.velocity = float(startX - endX) / self.timeToTraverseField
     self.warnDistance = 35
コード例 #3
0
 def enterReload(self):
     self.gui.deleteNoAmmoLabel()
     if self.weaponName == "pistol":
         self.track = Parallel(Sequence(Wait(0.3), Func(self.reload.play), Func(self.resetAmmo)),
             ActorInterval(self.v_model, 'preload', playRate = 1.5), name = 'reloadTrack')
     elif self.weaponName == "shotgun":
         self.track = Sequence(Func(self.draw.play), LerpQuatInterval(self.v_model, duration = 0.5,
             quat = (70, -50, 0), startHpr = (0, 0, 0), blendType = 'easeIn'),
             SoundInterval(self.cockBack),
             SoundInterval(self.cockFwd),
             Func(self.resetAmmo),
             Func(self.draw.play),
             LerpQuatInterval(self.v_model, duration = 0.5, quat = (0, 0, 0), startHpr = (70, -50, 0),
                 blendType = 'easeOut'), name = 'reloadTrack')
     elif self.weaponName == "sniper":
         self.track = Sequence(Func(self.draw.play), LerpQuatInterval(self.v_model, duration = 0.5,
             quat = (70, -50, 0), startHpr = (0, 0, 0), blendType = 'easeIn'),
             SoundInterval(self.cockBack),
             SoundInterval(self.cockFwd),
             Func(self.resetAmmo),
             Func(self.draw.play),
             LerpQuatInterval(self.v_model, duration = 0.5, quat = (0, 0, 0), startHpr = (70, -50, 0),
                 blendType = 'easeOut'), name = 'reloadTrack')
     self.track.setDoneEvent('reloadTrack')
     self.acceptOnce(self.track.getDoneEvent(), self.aliveFSM.request, ['idle'])
     self.track.start()
コード例 #4
0
class DDPlayground(Playground.Playground):
    def __init__(self, loader, parentFSM, doneEvent):
        Playground.Playground.__init__(self, loader, parentFSM, doneEvent)
        self.birdSfx = None
        return

    def enter(self, requestStatus):
        Playground.Playground.enter(self, requestStatus)
        self.startBirds()

    def startBirds(self):
        taskMgr.add(self.birdTask, 'DDPlayground-birdTask')

    def stopBirds(self):
        taskMgr.remove('DDPlayground-birdTask')
        if self.birdSfx:
            self.birdSfx.finish()
            self.birdSfx = None
        return

    def birdTask(self, task):
        noiseFile = self.loader.birdNoise
        noise = base.loadSfx(noiseFile)
        if self.birdSfx:
            self.birdSfx.finish()
            self.birdSfx = None
        self.birdSfx = SoundInterval(noise)
        self.birdSfx.start()
        task.delayTime = random.random() * 20 + 1
        return task.again

    def exit(self):
        self.stopBirds()
        Playground.Playground.exit(self)
コード例 #5
0
ファイル: DDPlayground.py プロジェクト: coginvasion/src
class DDPlayground(Playground.Playground):

    def __init__(self, loader, parentFSM, doneEvent):
        Playground.Playground.__init__(self, loader, parentFSM, doneEvent)
        self.birdSfx = None
        return

    def enter(self, requestStatus):
        Playground.Playground.enter(self, requestStatus)
        self.startBirds()

    def startBirds(self):
        taskMgr.add(self.birdTask, 'DDPlayground-birdTask')

    def stopBirds(self):
        taskMgr.remove('DDPlayground-birdTask')
        if self.birdSfx:
            self.birdSfx.finish()
            self.birdSfx = None
        return

    def birdTask(self, task):
        noiseFile = self.loader.birdNoise
        noise = base.loadSfx(noiseFile)
        if self.birdSfx:
            self.birdSfx.finish()
            self.birdSfx = None
        self.birdSfx = SoundInterval(noise)
        self.birdSfx.start()
        task.delayTime = random.random() * 20 + 1
        return task.again

    def exit(self):
        self.stopBirds()
        Playground.Playground.exit(self)
コード例 #6
0
 def birdTask(self, task):
     noiseFile = random.choice(self.loader.birdNoises)
     noise = base.loadSfx(noiseFile)
     if self.birdSfx:
         self.birdSfx.finish()
         self.birdSfx = None
     self.birdSfx = SoundInterval(noise)
     self.birdSfx.start()
     task.delayTime = random.random() * 20 + 1
     return task.again
コード例 #7
0
class TTPlayground(Playground.Playground):
    notify = directNotify.newCategory('TTPlayground')

    def __init__(self, loader, parentFSM, doneEvent):
        Playground.Playground.__init__(self, loader, parentFSM, doneEvent)
        self.birdSfx = None
        self.christmasTree = None
        return

    def load(self):
        Playground.Playground.load(self)
        if base.cr.holidayManager.getHoliday() == HolidayType.CHRISTMAS:
            self.christmasTree = loader.loadModel(
                'phase_4/models/props/winter_tree_Christmas.bam')
            self.christmasTree.reparentTo(self.loader.geom)
            self.christmasTree.setPos(0.651558, 23.0954, 0.00864142)
            self.christmasTree.setH(-183.108)
            winterTxt = loader.loadTexture('winter/maps/tt_winter_ground.png')
            self.loader.geom.find('**/ground_center').setTexture(winterTxt, 1)

    def unload(self):
        Playground.Playground.unload(self)
        if self.christmasTree:
            self.christmasTree.removeNode()
            self.christmasTree = None
        return

    def enter(self, requestStatus):
        Playground.Playground.enter(self, requestStatus)
        self.startBirds()

    def startBirds(self):
        taskMgr.add(self.birdTask, 'TTPlayground-birdTask')

    def stopBirds(self):
        taskMgr.remove('TTPlayground-birdTask')
        if self.birdSfx:
            self.birdSfx.finish()
            self.birdSfx = None
        return

    def birdTask(self, task):
        noiseFile = random.choice(self.loader.birdNoises)
        noise = base.loadSfx(noiseFile)
        if self.birdSfx:
            self.birdSfx.finish()
            self.birdSfx = None
        self.birdSfx = SoundInterval(noise)
        self.birdSfx.start()
        task.delayTime = random.random() * 20 + 1
        return task.again

    def exit(self):
        self.stopBirds()
        Playground.Playground.exit(self)
コード例 #8
0
    def clientCommonObject(self, type, commonId, pos, hpr, sizeX, sizeY, moveDistance):
        data = self.createCommonObject(type, commonId, pos, hpr, sizeX, sizeY, moveDistance)
        index = data[1]
        if type == 3:
            cross = self.commonObjectDict[commonId][2]
            for pair in self.odePandaRelationList:
                pandaNodePathGeom = pair[0]
                odeBody = pair[1]
                if odeBody == cross:
                    base.sfxPlayer.setCutoffDistance(240)
                    self.notify.debug('nodePath = %s' % pandaNodePathGeom)
                    windmillSfx = loader.loadSfx('phase_6/audio/sfx/Golf_Windmill_Loop.ogg')
                    windMillSoundInterval = SoundInterval(windmillSfx, node=pandaNodePathGeom, listenerNode=base.camera, seamlessLoop=True, volume=0.5)
                    windMillSoundInterval.loop()
                    self.physicsSfxDict[index] = (windmillSfx, windMillSoundInterval)
                    break

        else:
            if type == 4:
                box = self.commonObjectDict[commonId][2]
                for pair in self.odePandaRelationList:
                    pandaNodePathGeom = pair[0]
                    odeBody = pair[1]
                    if odeBody == box:
                        self.notify.debug('nodePath = %s' % pandaNodePathGeom)
                        moverSfx = loader.loadSfx('phase_6/audio/sfx/Golf_Moving_Barrier.ogg')
                        moverSoundInterval = SoundInterval(moverSfx, node=pandaNodePathGeom, listenerNode=base.camera, seamlessLoop=True, volume=0.5)
                        moverSoundInterval.start()
                        self.physicsSfxDict[index] = (moverSfx, moverSoundInterval, index)
                        break
コード例 #9
0
 def enterDown(self):
     if self.oldState == 'Off':
         downAnimControl = self.actor.getAnimControl('down')
         self.actor.pose('down', downAnimControl.getNumFrames() - 1)
         return
     self.clearHitInterval()
     startScale = self.hole.getScale()
     endScale = Point3(5, 5, 5)
     self.hitInterval = Sequence(
         LerpFunc(self.setAlongSpline,
                  duration=1.0,
                  fromData=self.currentT,
                  toData=0.0),
         LerpScaleInterval(self.hole,
                           duration=0.175,
                           scale=endScale,
                           startScale=startScale,
                           blendType='easeIn'),
         Parallel(
             SoundInterval(self.upSound,
                           volume=0.6,
                           node=self.actor,
                           cutOff=PartyGlobals.PARTY_COG_CUTOFF),
             ActorInterval(self.actor, 'down', loop=0)),
         LerpScaleInterval(self.hole,
                           duration=0.175,
                           scale=Point3(3, 3, 3),
                           startScale=endScale,
                           blendType='easeOut'))
     self.hitInterval.start()
コード例 #10
0
 def exitDown(self):
     self.root.setR(0.0)
     self.root.setH(0.0)
     self.targetDistance = 0.0
     self.targetFacing = 0.0
     self.currentT = 0.0
     self.setAlongSpline(0.0)
     self.clearHitInterval()
     startScale = self.hole.getScale()
     endScale = Point3(5, 5, 5)
     self.hitInterval = Sequence(
         LerpScaleInterval(self.hole,
                           duration=0.175,
                           scale=endScale,
                           startScale=startScale,
                           blendType='easeIn'),
         Parallel(
             SoundInterval(self.upSound,
                           volume=0.6,
                           node=self.actor,
                           cutOff=PartyGlobals.PARTY_COG_CUTOFF),
             ActorInterval(self.actor, 'up', loop=0)),
         Func(self.actor.loop, 'idle'),
         LerpScaleInterval(self.hole,
                           duration=0.175,
                           scale=Point3(3, 3, 3),
                           startScale=endScale,
                           blendType='easeOut'))
     self.hitInterval.start()
コード例 #11
0
    def getTossPieInterval(self, toon, x, y, z, h, p, r, power, beginFlyIval = Sequence()):
        ToontownBattleGlobals = ToontownBattleGlobals
        import toontown.toonbase
        BattleProps = BattleProps
        import toontown.battle
        pie = toon.getPieModel()
        pie.setScale(0.5)
        flyPie = pie.copyTo(NodePath('a'))
        pieName = ToontownBattleGlobals.pieNames[toon.pieType]
        pieType = BattleProps.globalPropPool.getPropType(pieName)
        animPie = Sequence()
        if pieType == 'actor':
            animPie = ActorInterval(pie, pieName, startFrame = 48)
        
        sound = loader.loadSfx('phase_3.5/audio/sfx/AA_pie_throw_only.mp3')
        t = power / 100.0
        dist = lerp(PartyGlobals.CogActivityPieMinDist, PartyGlobals.CogActivityPieMaxDist, t)
        time = lerp(1.0, 1.5, t)
        proj = ProjectileInterval(None, startPos = Point3(0, 0, 0), endPos = Point3(0, dist, 0), duration = time)
        relVel = proj.startVel
        
        def getVelocity(toon = toon, relVel = relVel):
            return render.getRelativeVector(toon, relVel) * 0.59999999999999998

        
        def _PartyCogActivity__safeSetAnimState(toon = toon, state = 'Happy'):
            if toon and hasattr(toon, 'animFSM'):
                toon.setAnimState('Happy')
            else:
                self.notify.warning('The toon is being destroyed. No attribute animState.')

        toss = Track((0, Sequence(Func(toon.setPosHpr, x, y, z, h, p, r), Func(pie.reparentTo, toon.rightHand), Func(pie.setPosHpr, 0, 0, 0, 0, 0, 0), animPie, Parallel(ActorInterval(toon, 'throw', startFrame = 48, playRate = 1.5, partName = 'torso'), animPie), Func(_PartyCogActivity__safeSetAnimState, toon, 'Happy'))), (16.0 / 24.0, Func(pie.detachNode)))
        fly = Track((14.0 / 24.0, SoundInterval(sound, node = toon, cutOff = PartyGlobals.PARTY_COG_CUTOFF)), (16.0 / 24.0, Sequence(Func(flyPie.reparentTo, render), Func(flyPie.setPosHpr, toon, 0.52000000000000002, 0.96999999999999997, 2.2400000000000002, 0, -45, 0), beginFlyIval, ProjectileInterval(flyPie, startVel = getVelocity, duration = 6), Func(flyPie.detachNode))))
        return (toss, fly, flyPie)
コード例 #12
0
    def __showSplat(self, position, direction, hot=False):
        if self.kaboomTrack is not None and self.kaboomTrack.isPlaying():
            self.kaboomTrack.finish()
        self.clearHitInterval()
        splatName = 'splat-creampie'
        self.splat = globalPropPool.getProp(splatName)
        self.splat.setBillboardPointEye()
        self.splat.reparentTo(render)
        self.splat.setPos(self.root, position)
        self.splat.setAlphaScale(1.0)
        if not direction == 1.0:
            self.splat.setColorScale(PartyGlobals.CogActivitySplatColors[0])
            if self.currentFacing > 0.0:
                facing = 'HitFront'
            else:
                facing = 'HitBack'
        else:
            self.splat.setColorScale(PartyGlobals.CogActivitySplatColors[1])
            if self.currentFacing > 0.0:
                facing = 'HitBack'
            else:
                facing = 'HitFront'
        if hot:
            targetscale = 0.75
            part = 'head'
        else:
            targetscale = 0.5
            part = 'body'

        def setSplatAlpha(amount):
            self.splat.setAlphaScale(amount)

        self.hitInterval = Sequence(
            ActorInterval(self.actor, part + facing, loop=0),
            Func(self.actor.loop, 'idle'))
        self.hitInterval.start()
        self.kaboomTrack = Parallel(
            SoundInterval(self.pieHitSound,
                          volume=1.0,
                          node=self.actor,
                          cutOff=PartyGlobals.PARTY_COG_CUTOFF),
            Sequence(
                Func(self.splat.showThrough),
                Parallel(
                    Sequence(
                        LerpScaleInterval(self.splat,
                                          duration=0.175,
                                          scale=targetscale,
                                          startScale=Point3(0.1, 0.1, 0.1),
                                          blendType='easeOut'), Wait(0.175)),
                    Sequence(
                        Wait(0.1),
                        LerpFunc(setSplatAlpha,
                                 duration=1.0,
                                 fromData=1.0,
                                 toData=0.0,
                                 blendType='easeOut'))),
                Func(self.splat.cleanup), Func(self.splat.removeNode)))
        self.kaboomTrack.start()
        return
コード例 #13
0
ファイル: CogdoGameExit.py プロジェクト: project-storm/src
 def close(self, animate=True):
     if not self._open:
         return
     if animate:
         self._finishIval()
         self._ival = Sequence(
             Parallel(
                 SoundInterval(self._closeSfx),
                 self._leftDoor.posInterval(
                     self.getOpenCloseDuration(),
                     ElevatorUtils.getLeftClosePoint(
                         ElevatorConstants.ELEVATOR_NORMAL),
                     startPos=ElevatorUtils.getLeftOpenPoint(
                         ElevatorConstants.ELEVATOR_NORMAL),
                     blendType='easeIn'),
                 self._rightDoor.posInterval(
                     self.getOpenCloseDuration(),
                     ElevatorUtils.getRightClosePoint(
                         ElevatorConstants.ELEVATOR_NORMAL),
                     startPos=ElevatorUtils.getRightOpenPoint(
                         ElevatorConstants.ELEVATOR_NORMAL),
                     blendType='easeIn')))
         self._ival.start()
     else:
         ElevatorUtils.closeDoors(self._leftDoor,
                                  self._rightDoor,
                                  type=ElevatorConstants.ELEVATOR_NORMAL)
     self._open = False
コード例 #14
0
	def createSystemMessage(self, message, important = 1):
		try:
			taskMgr.remove("clearSystemMessage-" + self.taskName)
			self.bubble.remove_node()
			self.bubble = None
		except:
			pass
		self.taskName = str(random.uniform(0, 10101010100))
		msg_color = (0.8, 0.3, 0.6, 0.6)
		sysmsg_data = [[Point3(0.075, 0, -0.2), base.a2dLeftCenter],
			[Point3(-0.6, 0, -0.7), base.a2dRightCenter],
			[Point3(-0.6, 0, -0.2), base.a2dRightCenter],
			[Point3(0.075, 0, -0.7), base.a2dLeftCenter],
			[Point3(0.35, 0, 0.2), base.a2dBottomCenter],
			[Point3(-0.2, 0, 0.2), base.a2dBottomCenter],
			[Point3(-0.8, 0, 0.2), base.a2dBottomCenter]]
		data = random.choice(sysmsg_data)
		sfx = loader.loadSfx("phase_3.5/audio/sfx/GUI_whisper_3.ogg")
		SoundInterval(sfx).start()
		length = math.sqrt(len(message)) / self.LENGTH_FACTOR
		self.bubble = ChatBalloon(loader.loadModel("phase_3/models/props/chatbox_noarrow.bam")).generate(message, CIGlobals.getToonFont(), balloonColor=msg_color)
		self.bubble.reparent_to(data[1])
		self.bubble.set_pos(data[0])
		self.bubble.set_scale(0.05)

		taskMgr.doMethodLater(length, self.clearSystemMessage, "clearSystemMessage-" + self.taskName)
コード例 #15
0
 def __init__(self):
     ShowBase.__init__(self)
     getModelPath().appendDirectory("data")
     self.AST_INIT_VEL = 0.6
     self.score = 0
     self.lives = 5
     self.BULLET_LIFE = 1.5
     self.BULLET_SPEED = 15
     self.BULLET_REPEAT = .2
     self.AST_VEL_SCALE = 1.2
     self.disableMouse()
     #self.ss = OnscreenText(text="0", parent=base.a2dTopLeft, pos=(0.07, -.06 * 1 - 0.1),fg=(1, 1, 1, 1), align=TextNode.ALeft, shadow=(0, 0, 0, 0.5), scale=.12)
     self.ss = OnscreenText(text="0",
                            parent=base.a2dTopLeft,
                            pos=(0.2, -0.1),
                            scale=0.08,
                            fg=(1, 1, 1, 1))
     # self.ll = OnscreenText(text="5", parent=base.a2dTopLeft, pos=(2.4, -1.76 * 1 - 0.1),fg=(1, 1, 1, 1), align=TextNode.ALeft, shadow=(0, 0, 0, 0.5), scale=.12)
     self.ll = OnscreenText(text="5",
                            parent=base.a2dTopLeft,
                            pos=(2.5, -1.95),
                            scale=0.08,
                            fg=(1, 1, 1, 1))
     self.setBackgroundColor((0, 0, 0, 1))
     self.bg = loadObject("stars.png",
                          scale=146,
                          depth=200,
                          transparency=False)
     self.ship = loadObject("ship.png")
     self.setVelocity(self.ship, LVector3.zero())
     self.ship.hide()
     self.keys = {"turnLeft": 0, "turnRight": 0, "accel": 0, "fire": 0}
     self.accept("escape", sys.exit)
     self.accept("arrow_left", self.setKey, ["turnLeft", 1])
     self.accept("arrow_left-up", self.setKey, ["turnLeft", 0])
     self.accept("arrow_right", self.setKey, ["turnRight", 1])
     self.accept("arrow_right-up", self.setKey, ["turnRight", 0])
     self.accept("arrow_up", self.setKey, ["accel", 1])
     self.accept("arrow_up-up", self.setKey, ["accel", 0])
     self.accept("space", self.setKey, ["fire", 1])
     self.gameon = 0
     self.gton = 0
     self.startgame()
     mySound = loader.loadSfx("music.wav")
     myInterval = SoundInterval(mySound, loop=1)
     myInterval.loop()
コード例 #16
0
class DDPlayground(Playground.Playground):
    def __init__(self, loader, parentFSM, doneEvent):
        Playground.Playground.__init__(self, loader, parentFSM, doneEvent)
        self.birdSfx = None

        # Let's handle the Christmas effects.
        if base.cr.holidayManager.getHoliday() == HolidayType.CHRISTMAS:
            water = self.loader.geom.find('**/water')
            water.setCollideMask(CIGlobals.FloorBitmask)

    def load(self):
        Playground.Playground.load(self)
        base.waterReflectionMgr.addWaterNode(
            125, (-25, 30, base.wakeWaterHeight),
            depth=14.0,
            spec=base.waterReflectionMgr.getDefaultSpec('ddPond'))

    def enter(self, requestStatus):
        self.startBirds()
        Playground.Playground.enter(self, requestStatus)

    def startBirds(self):
        taskMgr.add(self.birdTask, "DDPlayground-birdTask")

    def stopBirds(self):
        taskMgr.remove("DDPlayground-birdTask")
        if self.birdSfx:
            self.birdSfx.finish()
            self.birdSfx = None

    def birdTask(self, task):
        noiseFile = self.loader.birdNoise
        noise = base.loadSfx(noiseFile)
        if self.birdSfx:
            self.birdSfx.finish()
            self.birdSfx = None
        self.birdSfx = SoundInterval(noise)
        self.birdSfx.start()
        task.delayTime = random.random() * 20 + 1
        return task.again

    def exit(self):
        self.stopBirds()
        Playground.Playground.exit(self)
コード例 #17
0
ファイル: TTPlayground.py プロジェクト: coginvasion/src
 def birdTask(self, task):
     noiseFile = random.choice(self.loader.birdNoises)
     noise = base.loadSfx(noiseFile)
     if self.birdSfx:
         self.birdSfx.finish()
         self.birdSfx = None
     self.birdSfx = SoundInterval(noise)
     self.birdSfx.start()
     task.delayTime = random.random() * 20 + 1
     return task.again
コード例 #18
0
ファイル: TTPlayground.py プロジェクト: coginvasion/src
class TTPlayground(Playground.Playground):
    notify = directNotify.newCategory('TTPlayground')

    def __init__(self, loader, parentFSM, doneEvent):
        Playground.Playground.__init__(self, loader, parentFSM, doneEvent)
        self.birdSfx = None
        return

    def load(self):
        Playground.Playground.load(self)

    def unload(self):
        Playground.Playground.unload(self)

    def enter(self, requestStatus):
        Playground.Playground.enter(self, requestStatus)
        self.startBirds()

    def startBirds(self):
        taskMgr.add(self.birdTask, 'TTPlayground-birdTask')

    def stopBirds(self):
        taskMgr.remove('TTPlayground-birdTask')
        if self.birdSfx:
            self.birdSfx.finish()
            self.birdSfx = None
        return

    def birdTask(self, task):
        noiseFile = random.choice(self.loader.birdNoises)
        noise = base.loadSfx(noiseFile)
        if self.birdSfx:
            self.birdSfx.finish()
            self.birdSfx = None
        self.birdSfx = SoundInterval(noise)
        self.birdSfx.start()
        task.delayTime = random.random() * 20 + 1
        return task.again

    def exit(self):
        self.stopBirds()
        Playground.Playground.exit(self)
コード例 #19
0
 def setWeapon(self, weapon, playSound = True):
     if weapon == CIGlobals.TNT and self.backpack.getSupply(weapon) <= 0: return
     if self.backpack.getSupply(weapon) <= 0: return
     self.prevGag = self.weapon
     base.localAvatar.b_equip(GagGlobals.getIDByName(weapon))
     self.weapon = self.backpack.getGagByIndex(self.backpack.getIndex())
     if playSound:
         sfx = base.loadSfx("phase_3/audio/sfx/GUI_balloon_popup.mp3")
         SoundInterval(sfx).start()
     self.resetScroll()
     self.update()
コード例 #20
0
    def clientCommonObject(self, type, commonId, pos, hpr, sizeX, sizeY, moveDistance):
        data = self.createCommonObject(type, commonId, pos, hpr, sizeX, sizeY, moveDistance)
        index = data[1]
        if type == 3:
            cross = self.commonObjectDict[commonId][2]
            for pair in self.odePandaRelationList:
                pandaNodePathGeom = pair[0]
                odeBody = pair[1]
                if odeBody == cross:
                    base.sfxPlayer.setCutoffDistance(240)
                    self.notify.debug('nodePath = %s' % pandaNodePathGeom)
                    windmillSfx = loader.loadSfx('phase_6/audio/sfx/Golf_Windmill_Loop.ogg')
                    windMillSoundInterval = SoundInterval(windmillSfx, node=pandaNodePathGeom, listenerNode=base.camera, seamlessLoop=True, volume=0.5)
                    windMillSoundInterval.loop()
                    self.physicsSfxDict[index] = (windmillSfx, windMillSoundInterval)
                    break

        elif type == 4:
            box = self.commonObjectDict[commonId][2]
            for pair in self.odePandaRelationList:
                pandaNodePathGeom = pair[0]
                odeBody = pair[1]
                if odeBody == box:
                    self.notify.debug('nodePath = %s' % pandaNodePathGeom)
                    moverSfx = loader.loadSfx('phase_6/audio/sfx/Golf_Moving_Barrier.ogg')
                    moverSoundInterval = SoundInterval(moverSfx, node=pandaNodePathGeom, listenerNode=base.camera, seamlessLoop=True, volume=0.5)
                    moverSoundInterval.start()
                    self.physicsSfxDict[index] = (moverSfx, moverSoundInterval, index)
                    break
コード例 #21
0
 def __init__(self, batIndex, timeToTraverseField):
     NodePath.__init__(self, 'VineBat')
     DirectObject.__init__(self)
     pos = Point3(0, 0, 0)
     serialNum = 0
     gameId = 0
     self.serialNum = serialNum
     self.batIndex = batIndex
     self.timeToTraverseField = timeToTraverseField
     gameAssets = loader.loadModel('phase_4/models/minigames/vine_game')
     bat3 = gameAssets.find('**/bat3')
     bat2 = gameAssets.find('**/bat2')
     bat1 = gameAssets.find('**/bat__1')
     seqNode = SequenceNode('bat')
     seqNode.addChild(bat1.node())
     seqNode.addChild(bat2.node())
     seqNode.addChild(bat3.node())
     seqNode.setFrameRate(12)
     seqNode.pingpong(False)
     self.batModel = self.attachNewNode(seqNode)
     self.batModel.reparentTo(self)
     gameAssets.removeNode()
     self.batModelIcon = self.attachNewNode('batIcon')
     self.batModel.copyTo(self.batModelIcon)
     regularCamMask = BitMask32.bit(0)
     self.batModelIcon.hide(regularCamMask)
     self.batModelIcon.show(VineGameGlobals.RadarCameraBitmask)
     self.batModelIcon.setScale(0.55)
     self.batModel.setScale(0.15)
     self.setPos(-100, 0, 0)
     center = Point3(0, 0, 0)
     self.sphereName = 'batSphere-%s-%s' % (gameId, self.serialNum)
     self.collSphere = CollisionSphere(center[0], center[1], center[2], self.RADIUS)
     self.collSphere.setTangible(0)
     self.collNode = CollisionNode(self.sphereName)
     self.collNode.setIntoCollideMask(VineGameGlobals.SpiderBitmask)
     self.collNode.addSolid(self.collSphere)
     self.collNodePath = self.attachNewNode(self.collNode)
     self.collNodePath.hide()
     self.accept('enter' + self.sphereName, self.__handleEnterSphere)
     self.screechSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_vine_game_bat_shriek_3.ogg')
     self.flySfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.ogg')
     self.oldCutoffDistance = base.sfxPlayer.getCutoffDistance()
     base.sfxPlayer.setCutoffDistance(240)
     self.soundInterval = SoundInterval(self.flySfx, node=self, listenerNode=base.localAvatar, seamlessLoop=True, volume=0.5, cutOff=240)
     self.reparentTo(render)
     self.startedFlying = False
     self.warnedForThisLap = False
     startX = VineGameGlobals.VineXIncrement * VineGameGlobals.NumVines
     endX = -VineGameGlobals.VineXIncrement
     self.velocity = float(startX - endX) / self.timeToTraverseField
     self.warnDistance = 35
コード例 #22
0
    def handleSuitAttack(self, attack_id, suit_id):
        attack = SuitAttacks.SuitAttackLengths.keys()[attack_id]
        if attack == "canned":
            sfx = base.audio3d.loadSfx(
                "phase_5/audio/sfx/SA_canned_impact_only.ogg")
            base.audio3d.attachSoundToObject(sfx, self)
            SoundInterval(sfx, node=self).start()
        elif attack == "playhardball":
            sfx = base.audio3d.loadSfx(
                "phase_5/audio/sfx/SA_hardball_impact_only_alt.ogg")
            base.audio3d.attachSoundToObject(sfx, self)
            SoundInterval(sfx, node=self).start()
        elif attack == "clipontie":
            sfx = base.audio3d.loadSfx(
                "phase_5/audio/sfx/SA_powertie_impact.ogg")
            base.audio3d.attachSoundToObject(sfx, self)
            SoundInterval(sfx, node=self).start()
        if not self.isDead():
            if attack in ["fountainpen"]:
                self.getPart("head").setColorScale(0, 0, 0, 1)
                Sequence(Wait(3.0), Func(self.resetHeadColor)).start()

        # Stop the current fade interval if it exists.
        if self.dmgFadeIval:
            self.dmgFadeIval.finish()
            self.dmgFadeIval = None

        geomNode = self.getGeomNode()
        # Do a fade effect when we get hit so we are more aware that we were damaged.
        self.dmgFadeIval = Sequence(
            Func(geomNode.setTransparency, 1),
            LerpColorScaleInterval(geomNode,
                                   0.3, (1, 1, 1, 0.5), (1, 1, 1, 1),
                                   blendType='easeOut'),
            LerpColorScaleInterval(geomNode,
                                   0.3, (1, 1, 1, 1), (1, 1, 1, 0.5),
                                   blendType='easeIn'),
            Func(geomNode.setTransparency, 0))
        self.dmgFadeIval.start()
コード例 #23
0
 def handleSuitAttack(self, attack_id, suit_id):
     attack = SuitAttacks.SuitAttackLengths.keys()[attack_id]
     if attack == 'canned':
         sfx = base.audio3d.loadSfx(
             'phase_5/audio/sfx/SA_canned_impact_only.ogg')
         base.audio3d.attachSoundToObject(sfx, self)
         SoundInterval(sfx, node=self).start()
     else:
         if attack == 'playhardball':
             sfx = base.audio3d.loadSfx(
                 'phase_5/audio/sfx/SA_hardball_impact_only_alt.ogg')
             base.audio3d.attachSoundToObject(sfx, self)
             SoundInterval(sfx, node=self).start()
         else:
             if attack == 'clipontie':
                 sfx = base.audio3d.loadSfx(
                     'phase_5/audio/sfx/SA_powertie_impact.ogg')
                 base.audio3d.attachSoundToObject(sfx, self)
                 SoundInterval(sfx, node=self).start()
     if not self.isDead():
         if attack in ('fountainpen', ):
             self.getPart('head').setColorScale(0, 0, 0, 1)
             Sequence(Wait(3.0), Func(self.resetHeadColor)).start()
     if self.dmgFadeIval:
         self.dmgFadeIval.finish()
         self.dmgFadeIval = None
     geomNode = self.getGeomNode()
     self.dmgFadeIval = Sequence(
         Func(geomNode.setTransparency, 1),
         LerpColorScaleInterval(geomNode,
                                0.3, (1, 1, 1, 0.5), (1, 1, 1, 1),
                                blendType='easeOut'),
         LerpColorScaleInterval(geomNode,
                                0.3, (1, 1, 1, 1), (1, 1, 1, 0.5),
                                blendType='easeIn'),
         Func(geomNode.setTransparency, 0))
     self.dmgFadeIval.start()
     return
コード例 #24
0
    def handleSuitAttack(self, attack_id, suit_id):
        attack = SuitAttacks.SuitAttackLengths.keys()[attack_id]
        if attack == "canned":
            sfx = base.audio3d.loadSfx(
                "phase_5/audio/sfx/SA_canned_impact_only.ogg")
            base.audio3d.attachSoundToObject(sfx, self)
            SoundInterval(sfx, node=self).start()
        elif attack == "playhardball":
            sfx = base.audio3d.loadSfx(
                "phase_5/audio/sfx/SA_hardball_impact_only_alt.ogg")
            base.audio3d.attachSoundToObject(sfx, self)
            SoundInterval(sfx, node=self).start()
        elif attack == "clipontie":
            sfx = base.audio3d.loadSfx(
                "phase_5/audio/sfx/SA_powertie_impact.ogg")
            base.audio3d.attachSoundToObject(sfx, self)
            SoundInterval(sfx, node=self).start()
        if not self.isDead():
            if attack in ["fountainpen"]:
                self.getPart("head").setColorScale(0, 0, 0, 1)
                Sequence(Wait(3.0), Func(self.resetHeadColor)).start()

        self.doDamageFade()
コード例 #25
0
    def __showSplat(self, position):
        """Show the splat graphic and sound."""
        if self.kaboomTrack is not None and self.kaboomTrack.isPlaying():
            self.kaboomTrack.finish()

        splatName = 'splat-creampie'
        self.splat = globalPropPool.getProp(splatName)
        self.splat.setBillboardPointEye()

        self.splat.reparentTo(render)
        self.splat.setPos(self.toon, position)
        self.splat.setY(
            self.toon,
            bound(self.splat.getY(),
                  self.toon.getHeight() / 2.0, position.getY()))
        self.splat.setAlphaScale(1.0)

        targetscale = 0.75

        def setSplatAlpha(amount):
            self.splat.setAlphaScale(amount)

        self.kaboomTrack = Parallel(
            SoundInterval(self.pieHitSound,
                          node=self.toon,
                          volume=1.0,
                          cutOff=PartyGlobals.PARTY_COG_CUTOFF),
            Sequence(
                Func(self.splat.showThrough),
                Parallel(
                    Sequence(
                        LerpScaleInterval(self.splat,
                                          duration=0.175,
                                          scale=targetscale,
                                          startScale=Point3(0.1, 0.1, 0.1),
                                          blendType="easeOut"),
                        Wait(0.175),
                    ),
                    Sequence(
                        Wait(0.1),
                        LerpFunc(setSplatAlpha,
                                 duration=1.0,
                                 fromData=1.0,
                                 toData=0.0,
                                 blendType="easeOut"))),
                Func(self.splat.cleanup),
                Func(self.splat.removeNode),
            ))
        self.kaboomTrack.start()
コード例 #26
0
 def _createSoundIval(self,
                      audioSound,
                      volume=1.0,
                      duration=0.0,
                      startTime=0.0,
                      source=None,
                      register=False,
                      cutoff=None):
     if cutoff == None:
         cutoff = self._cutoff
     ival = SoundInterval(audioSound,
                          node=source,
                          duration=duration,
                          startTime=startTime,
                          cutOff=cutoff,
                          seamlessLoop=True,
                          listenerNode=self._listener)
     return ival
コード例 #27
0
 def explode(self):
     self.explosion = Actor('phase_5/models/props/kapow-mod.bam',
                            {'chan': 'phase_5/models/props/kapow-chan.bam'})
     self.explosion.reparentTo(render)
     self.explosion.setBillboardPointEye()
     self.explosion.setPos(self.entity.getPos(render) + (0, 0, 4))
     self.explosion.setScale(0.5)
     self.explosion.play('chan')
     if self.idleSfx:
         self.idleSfx.stop()
     base.audio3d.attachSoundToObject(self.hitSfx, self.explosion)
     SoundInterval(self.hitSfx, node=self.explosion).start()
     self.cleanupParticles()
     self.cleanupEntity()
     self.setState(GagState.LOADED)
     backpack = self.avatar.getBackpack()
     if backpack.getSupply(
             self.getID()) > 0 and backpack.getCurrentGag() == self:
         self.equip()
     Sequence(Wait(0.5), Func(self.cleanupExplosion)).start()
コード例 #28
0
    def _PartyCogActivityPlayer__showSplat(self, position):
        if self.kaboomTrack is not None and self.kaboomTrack.isPlaying():
            self.kaboomTrack.finish()
        
        if not self.pieHitSound:
            self.notify.warning('Trying to play hit sound on destroyed player')
            return None
        
        splatName = 'splat-creampie'
        self.splat = globalPropPool.getProp(splatName)
        self.splat.setBillboardPointEye()
        self.splat.reparentTo(render)
        self.splat.setPos(self.toon, position)
        self.splat.setY(self.toon, bound(self.splat.getY(), self.toon.getHeight() / 2.0, position.getY()))
        self.splat.setAlphaScale(1.0)
        targetscale = 0.75
        
        def setSplatAlpha(amount):
            self.splat.setAlphaScale(amount)

        self.kaboomTrack = Parallel(SoundInterval(self.pieHitSound, node = self.toon, volume = 1.0, cutOff = PartyGlobals.PARTY_COG_CUTOFF), Sequence(Func(self.splat.showThrough), Parallel(Sequence(LerpScaleInterval(self.splat, duration = 0.17499999999999999, scale = targetscale, startScale = Point3(0.10000000000000001, 0.10000000000000001, 0.10000000000000001), blendType = 'easeOut'), Wait(0.17499999999999999)), Sequence(Wait(0.10000000000000001), LerpFunc(setSplatAlpha, duration = 1.0, fromData = 1.0, toData = 0.0, blendType = 'easeOut'))), Func(self.splat.cleanup), Func(self.splat.removeNode)))
        self.kaboomTrack.start()
コード例 #29
0
ファイル: BRPlayground.py プロジェクト: coginvasion/src
class BRPlayground(Playground.Playground):
    notify = directNotify.newCategory('BRPlayground')
    InWaterZ = 0.93

    def __init__(self, loader, parentFSM, doneEvent):
        Playground.Playground.__init__(self, loader, parentFSM, doneEvent)
        self.windSfx = None
        self.water = None
        return

    def enter(self, requestStatus):
        Playground.Playground.enter(self, requestStatus)
        self.water = BRWater.BRWater(self)
        self.startWind()

    def exit(self):
        self.stopWind()
        self.water.fsm.requestFinalState()
        Playground.Playground.exit(self)

    def unload(self):
        self.water.cleanup()
        self.water = None
        Playground.Playground.unload(self)
        return

    def startWaterWatch(self, enter = 1):
        taskMgr.add(self.__waterWatch, 'BRPlayground-waterWatch', extraArgs=[enter], appendTask=True)

    def __waterWatch(self, enter, task):
        if enter:
            if base.localAvatar.getZ(render) <= self.InWaterZ:
                self.water.fsm.request('freezeUp')
                return task.done
        elif base.localAvatar.getZ(render) > self.InWaterZ:
            if self.water.fsm.getCurrentState().getName() == 'freezeUp':
                self.water.fsm.request('coolDown')
                return task.done
        return task.cont

    def stopWaterWatch(self):
        taskMgr.remove('BRPlayground-waterWatch')

    def startWind(self):
        taskMgr.add(self.windTask, 'BRPlayground-windTask')

    def stopWind(self):
        taskMgr.remove('BRPlayground-windTask')
        if self.windSfx:
            self.windSfx.finish()
            self.windSfx = None
        return

    def windTask(self, task):
        noiseFile = random.choice(self.loader.windNoises)
        noise = base.loadSfx(noiseFile)
        if self.windSfx:
            self.windSfx.finish()
            self.windSfx = None
        self.windSfx = SoundInterval(noise)
        self.windSfx.start()
        task.delayTime = random.random() * 20 + 1
        return task.again
コード例 #30
0
ファイル: VineBat.py プロジェクト: ghost4499/toontown-online
class VineBat(NodePath, DirectObject):
    notify = DirectNotifyGlobal.directNotify.newCategory('VineBat')
    notify.setDebug(True)
    RADIUS = 1.7

    def __init__(self, batIndex, timeToTraverseField):
        NodePath.__init__(self, 'VineBat')
        DirectObject.__init__(self)
        pos = Point3(0, 0, 0)
        serialNum = 0
        gameId = 0
        self.serialNum = serialNum
        self.batIndex = batIndex
        self.timeToTraverseField = timeToTraverseField
        gameAssets = loader.loadModel('phase_4/models/minigames/vine_game')
        bat3 = gameAssets.find('**/bat3')
        bat2 = gameAssets.find('**/bat2')
        bat1 = gameAssets.find('**/bat__1')
        seqNode = SequenceNode.SequenceNode('bat')
        seqNode.addChild(bat1.node())
        seqNode.addChild(bat2.node())
        seqNode.addChild(bat3.node())
        seqNode.setFrameRate(12)
        seqNode.pingpong(False)
        self.batModel = self.attachNewNode(seqNode)
        self.batModel.reparentTo(self)
        gameAssets.removeNode()
        self.batModelIcon = self.attachNewNode('batIcon')
        self.batModel.copyTo(self.batModelIcon)
        regularCamMask = BitMask32.bit(0)
        self.batModelIcon.hide(regularCamMask)
        self.batModelIcon.show(VineGameGlobals.RadarCameraBitmask)
        self.batModelIcon.setScale(0.55)
        self.batModel.setScale(0.15)
        self.setPos(-100, 0, 0)
        center = Point3(0, 0, 0)
        self.sphereName = 'batSphere-%s-%s' % (gameId, self.serialNum)
        self.collSphere = CollisionSphere(center[0], center[1], center[2],
                                          self.RADIUS)
        self.collSphere.setTangible(0)
        self.collNode = CollisionNode(self.sphereName)
        self.collNode.setIntoCollideMask(VineGameGlobals.SpiderBitmask)
        self.collNode.addSolid(self.collSphere)
        self.collNodePath = self.attachNewNode(self.collNode)
        self.collNodePath.hide()
        self.accept('enter' + self.sphereName, self.__handleEnterSphere)
        self.screechSfx = base.loadSfx(
            'phase_4/audio/sfx/MG_sfx_vine_game_bat_shriek_3.mp3')
        self.flySfx = base.loadSfx(
            'phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.wav')
        self.oldCutoffDistance = base.sfxPlayer.getCutoffDistance()
        base.sfxPlayer.setCutoffDistance(240)
        self.soundInterval = SoundInterval(self.flySfx,
                                           node=self,
                                           listenerNode=base.localAvatar,
                                           seamlessLoop=True,
                                           volume=0.5,
                                           cutOff=240)
        self.reparentTo(render)
        self.startedFlying = False
        self.warnedForThisLap = False
        startX = VineGameGlobals.VineXIncrement * VineGameGlobals.NumVines
        endX = -VineGameGlobals.VineXIncrement
        self.velocity = float(startX - endX) / self.timeToTraverseField
        self.warnDistance = 35

    def destroy(self):
        self.ignoreAll()
        self.batModel.removeNode()
        del self.batModel
        del self.collSphere
        self.collNodePath.removeNode()
        del self.collNodePath
        del self.collNode
        self.removeNode()
        self.soundInterval.finish()
        del self.soundInterval
        del self.flySfx
        del self.screechSfx
        base.sfxPlayer.setCutoffDistance(self.oldCutoffDistance)

    def __handleEnterSphere(self, collEntry):
        self.ignoreAll()
        self.notify.debug('treasuerGrabbed')
        messenger.send('VineBatGrabbed', [self.serialNum])

    def showGrab(self):
        self.reparentTo(hidden)
        self.collNode.setIntoCollideMask(BitMask32(0))

    def startFlying(self):
        self.startedFlying = True
        self.soundInterval.loop()

    def stopFlying(self):
        self.flySfx.setVolume(0)
        self.soundInterval.finish()

    def startLap(self):
        self.warnedForThisLap = False

    def checkScreech(self):
        distance = base.localAvatar.getDistance(self)
        if distance < self.warnDistance:
            if self.getX(render) > base.localAvatar.getX(render):
                if not self.warnedForThisLap:
                    self.screechSfx.play()
                    self.warnedForThisLap = True
コード例 #31
0
    def __init__(self, id, parent, type, pos):
        self.id = id
        self.parent = parent
        self.hp = 100
        self.speed = 1
        self.can_move = True

        if type == 'baby':
            self.node = Actor(
                'models/baby', {
                    'walk': 'models/baby-walk',
                    'stand': 'models/baby-stand',
                    'idle': 'models/baby-idle',
                    'jump': 'models/baby-jump',
                    'bite1': 'models/baby-bite1',
                    'bite2': 'models/baby-bite2',
                    'head_attack': 'models/baby-head_attack',
                    'hit1': 'models/baby-hit1',
                    'hit2': 'models/baby-hit2',
                    'die': 'models/baby-die'
                })
            self.head_node = self.node.exposeJoint(None, "modelRoot",
                                                   "Bip01_Head")
            self.body_node = self.node.exposeJoint(None, "modelRoot",
                                                   "Bip01_Pelvis")
            self.node.setH(180)
            self.node.setScale(0.03)
            self.node.flattenLight()
            self.zpos = 0
            self.node.setPos(pos[0] * TILE_SIZE, pos[1] * TILE_SIZE, self.zpos)
            self.node.setTexture(loader.loadTexture('models/Zomby_D.png'))
            self.ts_normal = TextureStage('ts_normal')
            self.tex_normal = loader.loadTexture('models/Zomby_N.png')
            self.ts_normal.setMode(TextureStage.MNormal)
            self.node.setTexture(self.ts_normal, self.tex_normal)
            self.ts_gloss = TextureStage('ts_gloss')
            self.tex_gloss = loader.loadTexture('models/Zomby_S1.png')
            self.ts_gloss.setMode(TextureStage.MGloss)
            self.node.setTexture(self.ts_gloss, self.tex_gloss)
            self.ts_glow = TextureStage('ts_glow')
            self.tex_glow = loader.loadTexture('models/Zomby_I.png')
            self.ts_glow.setMode(TextureStage.MGlow)
            self.node.setTexture(self.ts_glow, self.tex_glow)
            self.node.reparentTo(render)
            self.node.loop('walk')
        elif type == 'nos':
            self.node = loader.loadModel('models/nos')
            self.zpos = 5
            self.node.setPos(pos[0] * TILE_SIZE, pos[1] * TILE_SIZE, self.zpos)
            self.node.setScale(2)
            if self.id == 1:
                self.node.setColor(1, 0, 0)
            elif self.id == 2:
                self.node.setColor(0, 1, 0)
            elif self.id == 3:
                self.node.setColor(0, 0, 1)
            else:
                self.node.setColor(1, 1, 1)
            self.node.reparentTo(render)

        #self.patrol_points = [(1,1), (4,11), (12,20), (18,4), (19,17)]

        #initialize 3d sound
        self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0],
                                                     base.camera)
        self.shot_head = self.audio3d.loadSfx(
            'audio/Zombie In Pain-SoundBible.com-134322253.wav')
        self.shot_body = self.audio3d.loadSfx(
            'audio/Zombie Moan-SoundBible.com-565291980.wav')
        self.moan1 = self.audio3d.loadSfx(
            'audio/Mindless Zombie Awakening-SoundBible.com-255444348.wav')
        self.moan2 = self.audio3d.loadSfx(
            'audio/Zombie Brain Eater-SoundBible.com-1076387080.wav')
        self.aggro_sound = self.audio3d.loadSfx(
            'audio/Mummy Zombie-SoundBible.com-1966938763.wav')
        self.attack_sound = self.audio3d.loadSfx(
            'audio/Chopping Off Limb-SoundBible.com-884800545.wav')
        self.audio3d.attachSoundToObject(self.moan1, self.node)
        self.audio3d.attachSoundToObject(self.moan2, self.node)
        self.audio3d.attachSoundToObject(self.shot_head, self.node)
        self.audio3d.attachSoundToObject(self.shot_body, self.node)
        self.audio3d.attachSoundToObject(self.aggro_sound, self.node)
        self.audio3d.attachSoundToObject(self.attack_sound, self.node)
        delay0 = Wait(d(35))
        delay1 = Wait(25 + d(35))
        delay2 = Wait(25 + d(35))
        self.moan_sequence = Sequence(delay0,
                                      SoundInterval(self.moan1), delay1,
                                      SoundInterval(self.moan2), delay2)
        self.moan_sequence.loop()

        self.parent.collision_manager.createMonsterCollision(self)

        self.aggro_sound_last_played = 0
        #--------------------------brain-------------------------
        self.node.setH(160)

        self.pause = False

        self.action = ACTION_IDLE

        if percent(20):
            self.orders = ORDERS_PATROL
        else:
            self.orders = ORDERS_IDLE

        self.last_melee = 0

        self.player_last_seen_abs = None

        self.idle_timer = time.time()
        self.idle_value = 1

        self.current_waypoint = None

        #self.wait_until = None
        self.herding_timer = None

        self.path = None

        taskMgr.doMethodLater(1, self.behaviourTask,
                              'MonsterBehaviourTask' + str(self.id))
        taskMgr.doMethodLater(1, self.debugMoveTask,
                              'MonsterMoveTask' + str(self.id))
コード例 #32
0
    def __init__(self):

        #Our standard title and instructions text
        self.title = OnscreenText(text="Panda3D: Tutorial - Musicbox(sounds)",
                                  style=1,
                                  fg=(1, 1, 1, 1),
                                  pos=(0.7, -0.95),
                                  scale=.07)
        self.escapeEventText = OnscreenText(text="ESC: Quit",
                                            style=1,
                                            fg=(1, 1, 1, 1),
                                            pos=(-1.3, 0.95),
                                            align=TextNode.ALeft,
                                            scale=.05)

        #Set up the key input
        self.accept('escape', sys.exit)

        #Fix the camera position
        base.disableMouse()

        #Loading sounds is done in a similar way to loading other things
        #Loading the main music box song
        self.musicBoxSound = base.loadMusic('music/musicbox.ogg')
        self.musicBoxSound.setVolume(.5)  #Volume is a percentage from 0 to 1
        self.musicBoxSound.setLoopCount(
            0)  #0 means loop forever, 1 (default) means
        #play once. 2 or higher means play that
        #many times

        #Sound objects do not have a pause function, just play and stop. So we will
        #Use this variable to keep track of where the sound is at when it was stoped
        #to impliment pausing
        self.musicTime = 0

        #Loading the open/close effect
        #loadSFX and loadMusic are identical. They are often used for organization
        #(loadMusic is used for background music, loadSfx is used for other effects)
        self.lidSfx = base.loadSfx('music/openclose.ogg')
        #The open/close file has both effects in it. Fortunatly we can use intervals
        #to easily define parts of a sound file to play
        self.lidOpenSfx = SoundInterval(self.lidSfx, duration=2, startTime=0)
        self.lidCloseSfx = SoundInterval(self.lidSfx, startTime=5)

        #For this tutorial, it seemed appropriate to have on screen controls. The
        #following code creates them
        #This is a label for a slider
        self.sliderText = OnscreenText("Volume",
                                       style=1,
                                       fg=(1, 1, 1, 1),
                                       pos=(0, 0.8),
                                       scale=.07)
        #The slider itself. It calls self.setMusicBoxVolume when changed
        self.slider = DirectSlider(pos=Vec3(0, 0, .7),
                                   value=.50,
                                   command=self.setMusicBoxVolume)
        #A button that calls self.toggleMusicBox when pressed
        self.button = DirectButton(pos=Vec3(.7, 0, .7),
                                   text="Open Box",
                                   scale=.1,
                                   pad=(.5, .5),
                                   rolloverSound=None,
                                   clickSound=None,
                                   command=self.toggleMusicBox)

        #A variable to represent the state of the simulation. It starts closed
        self.boxOpen = False

        #Here we load and set up the music box. It was modeled in a complex way, so
        #setting it up will be complicated
        self.musicBox = loader.loadModel('models/MusicBox')
        self.musicBox.setPos(0, 60, -10)
        self.musicBox.reparentTo(render)
        #Just like the scene graph contains hierarchies of nodes, so can
        #models. You can get the NodePath for the node using the find
        #function, and then you can animate the model by moving its parts
        #To see the hierarchy of a model, use, the ls function
        #self.musicBox.ls() prints out the entire hierarchy of the model

        #Finding pieces of the model
        self.Lid = self.musicBox.find('**/lid')
        self.Panda = self.musicBox.find('**/turningthing')

        #This model was made with the hinge in the wrong place
        #this is here so we have something to turn
        self.HingeNode = self.musicBox.find('**/box').attachNewNode(
            'nHingeNode')
        self.HingeNode.setPos(.8659, 6.5, 5.4)
        #WRT - ie with respect to. Reparents the object without changing
        #its position, size, or orientation
        self.Lid.wrtReparentTo(self.HingeNode)
        self.HingeNode.setHpr(0, 90, 0)

        #This sets up an interval to play the close sound and actually close the box
        #at the same time.
        self.lidClose = Parallel(
            self.lidCloseSfx,
            LerpFunc(self.HingeNode.setP,
                     duration=2,
                     fromData=0,
                     toData=90,
                     blendType='easeInOut'))

        #Same thing for opening the box
        self.lidOpen = Parallel(
            self.lidOpenSfx,
            LerpFunc(self.HingeNode.setP,
                     duration=2,
                     fromData=90,
                     toData=0,
                     blendType='easeInOut'))

        #The interval for turning the panda
        self.PandaTurn = self.Panda.hprInterval(7, Vec3(360, 0, 0))
        #Do a quick loop and pause to set it as a looping interval so it can be
        #started with resume and loop properly
        self.PandaTurn.loop()
        self.PandaTurn.pause()
コード例 #33
0
    def getTossPieInterval(self,
                           toon,
                           x,
                           y,
                           z,
                           h,
                           p,
                           r,
                           power,
                           beginFlyIval=Sequence()):
        """Adapted from toon.py to suit our needs.
        Returns (toss, pie, flyPie), where toss is an interval to
        animate the toon tossing a pie, pie is the interval to
        animate the pie flying through the air, and pieModel is the
        model that flies.  This is used in the final BossBattle
        sequence of CogHQ when we all throw pies directly at the
        boss cog.
        """

        from toontown.toonbase import ToontownBattleGlobals
        from toontown.battle import BattleProps

        pie = toon.getPieModel()
        pie.setScale(0.5)
        flyPie = pie.copyTo(NodePath('a'))
        pieName = ToontownBattleGlobals.pieNames[toon.pieType]
        pieType = BattleProps.globalPropPool.getPropType(pieName)
        animPie = Sequence()
        if pieType == 'actor':
            animPie = ActorInterval(pie, pieName, startFrame=48)

        sound = loader.loadSfx('phase_3.5/audio/sfx/AA_pie_throw_only.mp3')

        # First, create a ProjectileInterval to compute the relative
        # velocity.

        assert 0 <= power <= 100, "invalid pie throw power %s" % power

        t = power / 100.0

        # Distance ranges from CogActivityPieMinDist to CogActivityPieMaxDist ft, time ranges from 1 to 1.5 s.
        dist = lerp(PartyGlobals.CogActivityPieMinDist,
                    PartyGlobals.CogActivityPieMaxDist, t)
        time = lerp(1.0, 1.5, t)

        proj = ProjectileInterval(None,
                                  startPos=Point3(0, 0, 0),
                                  endPos=Point3(0, dist, 0),
                                  duration=time)
        relVel = proj.startVel

        def getVelocity(toon=toon, relVel=relVel):
            return render.getRelativeVector(toon, relVel) * 0.6

        toss = Track(
            (
                0,
                Sequence(
                    Func(toon.setPosHpr, x, y, z, h, p, r),
                    Func(pie.reparentTo, toon.rightHand),
                    Func(pie.setPosHpr, 0, 0, 0, 0, 0, 0),
                    animPie,
                    Parallel(
                        ActorInterval(
                            toon,
                            'throw',
                            startFrame=48,
                            #duration=0.25, #self.throwPieLimitTime,
                            playRate=1.5,
                            partName='torso'),
                        animPie),
                    Func(toon.setAnimState, 'Happy'),
                )),
            (16. / 24., Func(pie.detachNode)))

        fly = Track(
            (14. / 24.,
             SoundInterval(
                 sound, node=toon, cutOff=PartyGlobals.PARTY_COG_CUTOFF)),
            (
                16. / 24.,
                Sequence(
                    Func(flyPie.reparentTo, render),
                    Func(flyPie.setPosHpr, toon, 0.52, 0.97, 2.24, 0, -45, 0),
                    beginFlyIval,
                    ProjectileInterval(
                        flyPie, startVel=getVelocity, duration=6),
                    #LerpPosInterval(flyPie, duration = 3, Point3(0.52,50,2.24)),
                    Func(flyPie.detachNode),
                )),
        )
        return (toss, fly, flyPie)
コード例 #34
0
ファイル: VineBat.py プロジェクト: satire6/Anesidora
    def __init__(self, batIndex, timeToTraverseField):
        """Constructor for VineBat.

        batIndex -- [0..2]
        timeToTraverseField -- in seconds, time to traverse field, shorter = faster

        """

        NodePath.__init__(self, 'VineBat')
        DirectObject.__init__(self)
        pos = Point3(0, 0, 0)
        serialNum = 0
        gameId = 0
        self.serialNum = serialNum

        self.batIndex = batIndex
        self.timeToTraverseField = timeToTraverseField

        #import pdb; pdb.set_trace()
        gameAssets = loader.loadModel("phase_4/models/minigames/vine_game")
        bat3 = gameAssets.find('**/bat3')
        bat2 = gameAssets.find('**/bat2')
        bat1 = gameAssets.find('**/bat__1')
        seqNode = SequenceNode.SequenceNode('bat')
        seqNode.addChild(bat1.node())
        seqNode.addChild(bat2.node())
        seqNode.addChild(bat3.node())
        seqNode.setFrameRate(12)
        seqNode.pingpong(False)
        self.batModel = self.attachNewNode(seqNode)
        self.batModel.reparentTo(self)
        gameAssets.removeNode()
        #self.batModel.setH(180)

        self.batModelIcon = self.attachNewNode('batIcon')
        self.batModel.copyTo(self.batModelIcon)
        #bat1.copyTo(self.batModelIcon)
        regularCamMask = BitMask32.bit(0)
        self.batModelIcon.hide(regularCamMask)
        self.batModelIcon.show(VineGameGlobals.RadarCameraBitmask)
        self.batModelIcon.setScale(0.55)
        self.batModel.setScale(0.15)
        #self.batModel.setScale(0.35)

        self.setPos(-100, 0, 0)
        center = Point3(0, 0, 0)

        # Make a sphere, name it uniquely, and child it
        # to the nodepath.
        self.sphereName = "batSphere-%s-%s" % (gameId, self.serialNum)
        self.collSphere = CollisionSphere(center[0], center[1], center[2],
                                          self.RADIUS)
        # Make the sphere intangible
        self.collSphere.setTangible(0)
        self.collNode = CollisionNode(self.sphereName)
        self.collNode.setIntoCollideMask(VineGameGlobals.SpiderBitmask)

        self.collNode.addSolid(self.collSphere)
        self.collNodePath = self.attachNewNode(self.collNode)
        self.collNodePath.hide()

        # Add a hook looking for collisions with localToon
        self.accept('enter' + self.sphereName, self.__handleEnterSphere)

        # now that the treasure and sphere have been placed, flatten the
        # whole silly thing
        #self.flattenLight()

        self.screechSfx = base.loadSfx(
            "phase_4/audio/sfx/MG_sfx_vine_game_bat_shriek_3.mp3")

        #self.flySfx = base.loadSfx("phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.mp3")
        self.flySfx = base.loadSfx(
            "phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.wav")
        self.oldCutoffDistance = base.sfxPlayer.getCutoffDistance()
        base.sfxPlayer.setCutoffDistance(240)
        self.soundInterval = SoundInterval(self.flySfx,
                                           node=self,
                                           listenerNode=base.localAvatar,
                                           seamlessLoop=True,
                                           volume=0.5,
                                           cutOff=240)
        self.reparentTo(render)

        self.startedFlying = False
        self.warnedForThisLap = False

        startX = VineGameGlobals.VineXIncrement * VineGameGlobals.NumVines
        endX = -VineGameGlobals.VineXIncrement
        self.velocity = float(startX -
                              endX) / self.timeToTraverseField  # in ft/s
        #self.warnDistance = 3 * self.velocity # in feet
        self.warnDistance = 35
コード例 #35
0
ファイル: VineBat.py プロジェクト: satire6/Anesidora
class VineBat(NodePath.NodePath, DirectObject):
    """
    Treasures toons can pickup swinging from vine to vine.  Based on MazeTreasure
    """

    notify = DirectNotifyGlobal.directNotify.newCategory("VineBat")
    notify.setDebug(True)

    RADIUS = 1.7

    def __init__(self, batIndex, timeToTraverseField):
        """Constructor for VineBat.

        batIndex -- [0..2]
        timeToTraverseField -- in seconds, time to traverse field, shorter = faster

        """

        NodePath.__init__(self, 'VineBat')
        DirectObject.__init__(self)
        pos = Point3(0, 0, 0)
        serialNum = 0
        gameId = 0
        self.serialNum = serialNum

        self.batIndex = batIndex
        self.timeToTraverseField = timeToTraverseField

        #import pdb; pdb.set_trace()
        gameAssets = loader.loadModel("phase_4/models/minigames/vine_game")
        bat3 = gameAssets.find('**/bat3')
        bat2 = gameAssets.find('**/bat2')
        bat1 = gameAssets.find('**/bat__1')
        seqNode = SequenceNode.SequenceNode('bat')
        seqNode.addChild(bat1.node())
        seqNode.addChild(bat2.node())
        seqNode.addChild(bat3.node())
        seqNode.setFrameRate(12)
        seqNode.pingpong(False)
        self.batModel = self.attachNewNode(seqNode)
        self.batModel.reparentTo(self)
        gameAssets.removeNode()
        #self.batModel.setH(180)

        self.batModelIcon = self.attachNewNode('batIcon')
        self.batModel.copyTo(self.batModelIcon)
        #bat1.copyTo(self.batModelIcon)
        regularCamMask = BitMask32.bit(0)
        self.batModelIcon.hide(regularCamMask)
        self.batModelIcon.show(VineGameGlobals.RadarCameraBitmask)
        self.batModelIcon.setScale(0.55)
        self.batModel.setScale(0.15)
        #self.batModel.setScale(0.35)

        self.setPos(-100, 0, 0)
        center = Point3(0, 0, 0)

        # Make a sphere, name it uniquely, and child it
        # to the nodepath.
        self.sphereName = "batSphere-%s-%s" % (gameId, self.serialNum)
        self.collSphere = CollisionSphere(center[0], center[1], center[2],
                                          self.RADIUS)
        # Make the sphere intangible
        self.collSphere.setTangible(0)
        self.collNode = CollisionNode(self.sphereName)
        self.collNode.setIntoCollideMask(VineGameGlobals.SpiderBitmask)

        self.collNode.addSolid(self.collSphere)
        self.collNodePath = self.attachNewNode(self.collNode)
        self.collNodePath.hide()

        # Add a hook looking for collisions with localToon
        self.accept('enter' + self.sphereName, self.__handleEnterSphere)

        # now that the treasure and sphere have been placed, flatten the
        # whole silly thing
        #self.flattenLight()

        self.screechSfx = base.loadSfx(
            "phase_4/audio/sfx/MG_sfx_vine_game_bat_shriek_3.mp3")

        #self.flySfx = base.loadSfx("phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.mp3")
        self.flySfx = base.loadSfx(
            "phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.wav")
        self.oldCutoffDistance = base.sfxPlayer.getCutoffDistance()
        base.sfxPlayer.setCutoffDistance(240)
        self.soundInterval = SoundInterval(self.flySfx,
                                           node=self,
                                           listenerNode=base.localAvatar,
                                           seamlessLoop=True,
                                           volume=0.5,
                                           cutOff=240)
        self.reparentTo(render)

        self.startedFlying = False
        self.warnedForThisLap = False

        startX = VineGameGlobals.VineXIncrement * VineGameGlobals.NumVines
        endX = -VineGameGlobals.VineXIncrement
        self.velocity = float(startX -
                              endX) / self.timeToTraverseField  # in ft/s
        #self.warnDistance = 3 * self.velocity # in feet
        self.warnDistance = 35

    def destroy(self):
        self.ignoreAll()
        self.batModel.removeNode()
        del self.batModel
        del self.collSphere
        self.collNodePath.removeNode()
        del self.collNodePath
        del self.collNode
        self.removeNode()
        self.soundInterval.finish()
        del self.soundInterval
        del self.flySfx
        del self.screechSfx
        base.sfxPlayer.setCutoffDistance(self.oldCutoffDistance)

    def __handleEnterSphere(self, collEntry):
        self.ignoreAll()
        # announce that this treasure was grabbed
        self.notify.debug('treasuerGrabbed')
        messenger.send("VineBatGrabbed", [self.serialNum])

    def showGrab(self):
        self.reparentTo(hidden)
        # disable collisions
        self.collNode.setIntoCollideMask(BitMask32(0))

    def startFlying(self):
        """Start the bat flying."""
        self.startedFlying = True
        self.soundInterval.loop()

    def stopFlying(self):
        """Stop the bat flying."""
        self.flySfx.setVolume(0)
        self.soundInterval.finish()

    def startLap(self):
        """Called when he starts his lap from the right."""
        self.warnedForThisLap = False

    def checkScreech(self):
        """Check if we should screech to warn the player we are coming."""

        distance = base.localAvatar.getDistance(self)
        if distance < self.warnDistance:
            if self.getX(render) > base.localAvatar.getX(render):
                # screech only when we're to the right of the player
                if not self.warnedForThisLap:
                    self.screechSfx.play()
                    self.warnedForThisLap = True
コード例 #36
0
class VineBat(NodePath, DirectObject):
    notify = DirectNotifyGlobal.directNotify.newCategory('VineBat')
    notify.setDebug(True)
    RADIUS = 1.7

    def __init__(self, batIndex, timeToTraverseField):
        NodePath.__init__(self, 'VineBat')
        DirectObject.__init__(self)
        pos = Point3(0, 0, 0)
        serialNum = 0
        gameId = 0
        self.serialNum = serialNum
        self.batIndex = batIndex
        self.timeToTraverseField = timeToTraverseField
        gameAssets = loader.loadModel('phase_4/models/minigames/vine_game')
        bat3 = gameAssets.find('**/bat3')
        bat2 = gameAssets.find('**/bat2')
        bat1 = gameAssets.find('**/bat__1')
        seqNode = SequenceNode('bat')
        seqNode.addChild(bat1.node())
        seqNode.addChild(bat2.node())
        seqNode.addChild(bat3.node())
        seqNode.setFrameRate(12)
        seqNode.pingpong(False)
        self.batModel = self.attachNewNode(seqNode)
        self.batModel.reparentTo(self)
        gameAssets.removeNode()
        self.batModelIcon = self.attachNewNode('batIcon')
        self.batModel.copyTo(self.batModelIcon)
        regularCamMask = BitMask32.bit(0)
        self.batModelIcon.hide(regularCamMask)
        self.batModelIcon.show(VineGameGlobals.RadarCameraBitmask)
        self.batModelIcon.setScale(0.55)
        self.batModel.setScale(0.15)
        self.setPos(-100, 0, 0)
        center = Point3(0, 0, 0)
        self.sphereName = 'batSphere-%s-%s' % (gameId, self.serialNum)
        self.collSphere = CollisionSphere(center[0], center[1], center[2], self.RADIUS)
        self.collSphere.setTangible(0)
        self.collNode = CollisionNode(self.sphereName)
        self.collNode.setIntoCollideMask(VineGameGlobals.SpiderBitmask)
        self.collNode.addSolid(self.collSphere)
        self.collNodePath = self.attachNewNode(self.collNode)
        self.collNodePath.hide()
        self.accept('enter' + self.sphereName, self.__handleEnterSphere)
        self.screechSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_vine_game_bat_shriek_3.ogg')
        self.flySfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.ogg')
        self.oldCutoffDistance = base.sfxPlayer.getCutoffDistance()
        base.sfxPlayer.setCutoffDistance(240)
        self.soundInterval = SoundInterval(self.flySfx, node=self, listenerNode=base.localAvatar, seamlessLoop=True, volume=0.5, cutOff=240)
        self.reparentTo(render)
        self.startedFlying = False
        self.warnedForThisLap = False
        startX = VineGameGlobals.VineXIncrement * VineGameGlobals.NumVines
        endX = -VineGameGlobals.VineXIncrement
        self.velocity = float(startX - endX) / self.timeToTraverseField
        self.warnDistance = 35

    def destroy(self):
        self.ignoreAll()
        self.batModel.removeNode()
        del self.batModel
        del self.collSphere
        self.collNodePath.removeNode()
        del self.collNodePath
        del self.collNode
        self.removeNode()
        self.soundInterval.finish()
        del self.soundInterval
        del self.flySfx
        del self.screechSfx
        base.sfxPlayer.setCutoffDistance(self.oldCutoffDistance)

    def __handleEnterSphere(self, collEntry):
        self.ignoreAll()
        self.notify.debug('treasuerGrabbed')
        messenger.send('VineBatGrabbed', [self.serialNum])

    def showGrab(self):
        self.reparentTo(hidden)
        self.collNode.setIntoCollideMask(BitMask32(0))

    def startFlying(self):
        self.startedFlying = True
        self.soundInterval.loop()

    def stopFlying(self):
        self.flySfx.setVolume(0)
        self.soundInterval.finish()

    def startLap(self):
        self.warnedForThisLap = False

    def checkScreech(self):
        distance = base.localAvatar.getDistance(self)
        if distance < self.warnDistance:
            if self.getX(render) > base.localAvatar.getX(render):
                if not self.warnedForThisLap:
                    self.screechSfx.play()
                    self.warnedForThisLap = True
コード例 #37
0
class BRPlayground(Playground.Playground):
    notify = directNotify.newCategory('BRPlayground')
    InWaterZ = 0.93

    def __init__(self, loader, parentFSM, doneEvent):
        Playground.Playground.__init__(self, loader, parentFSM, doneEvent)
        self.windSfx = None
        self.water = None
        return

    def enter(self, requestStatus):
        Playground.Playground.enter(self, requestStatus)
        self.water = BRWater.BRWater(self)
        self.startWind()

    def exit(self):
        self.stopWind()
        self.water.fsm.requestFinalState()
        Playground.Playground.exit(self)

    def unload(self):
        self.water.cleanup()
        self.water = None
        Playground.Playground.unload(self)
        return

    def startWaterWatch(self, enter=1):
        taskMgr.add(self.__waterWatch,
                    'BRPlayground-waterWatch',
                    extraArgs=[enter],
                    appendTask=True)

    def __waterWatch(self, enter, task):
        if enter:
            if base.localAvatar.getZ(render) <= self.InWaterZ:
                self.water.fsm.request('freezeUp')
                return task.done
        else:
            if base.localAvatar.getZ(render) > self.InWaterZ:
                if self.water.fsm.getCurrentState().getName() == 'freezeUp':
                    self.water.fsm.request('coolDown')
                    return task.done
        return task.cont

    def stopWaterWatch(self):
        taskMgr.remove('BRPlayground-waterWatch')

    def startWind(self):
        taskMgr.add(self.windTask, 'BRPlayground-windTask')

    def stopWind(self):
        taskMgr.remove('BRPlayground-windTask')
        if self.windSfx:
            self.windSfx.finish()
            self.windSfx = None
        return

    def windTask(self, task):
        noiseFile = random.choice(self.loader.windNoises)
        noise = base.loadSfx(noiseFile)
        if self.windSfx:
            self.windSfx.finish()
            self.windSfx = None
        self.windSfx = SoundInterval(noise)
        self.windSfx.start()
        task.delayTime = random.random() * 20 + 1
        return task.again