Example #1
0
 def bossSpawned(self):
     base.hoodBGM.stop()
     base.hoodBGM = base.loadMusic("phase_7/audio/bgm/encntr_suit_winning_indoor.ogg")
     base.hoodBGM.setVolume(0.7)
     base.hoodBGM.setLoop(True)
     Sequence(Wait(0.5), Func(base.hoodBGM.play)).start()
Example #2
0
 def initIntervals(self):
     self.baseSpinDuration = 1.0
     self.propellerSpinLerp = LerpFunctionInterval(
         self.propeller.setH,
         fromData=0.0,
         toData=360.0,
         duration=self.baseSpinDuration,
         name='%s.propellerSpinLerp-%s' %
         (self.__class__.__name__, self.toon.doId))
     singleBlinkTime = Globals.Gameplay.TargetedWarningSingleBlinkTime
     blinkTime = Globals.Gameplay.TargetedWarningBlinkTime
     self.blinkLoop = Sequence(
         Wait(singleBlinkTime / 2.0),
         Func(self.setBackpackTexture,
              Globals.Gameplay.BackpackStates.Attacked),
         Wait(singleBlinkTime / 2.0),
         Func(self.setBackpackTexture,
              Globals.Gameplay.BackpackStates.Targeted),
         name='%s.blinkLoop-%s' % (self.__class__.__name__, self.toon.doId))
     self.blinkWarningSeq = Sequence(
         Func(self.blinkLoop.loop),
         Wait(blinkTime),
         Func(self.blinkLoop.clearToInitial),
         name='%s.blinkWarningSeq-%s' %
         (self.__class__.__name__, self.toon.doId))
     dur = Globals.Gameplay.BackpackRefuelDuration
     self.refuelSeq = Sequence(
         Func(self.setPropellerSpinRate, Globals.Gameplay.RefuelPropSpeed),
         Wait(dur),
         Func(self.returnBackpackToLastStateFunc),
         name='%s.refuelSeq-%s' % (self.__class__.__name__, self.toon.doId))
     scale = self.redTapeRing.getScale()
     pulseTime = 1.0
     self.pulseBubbleSeq = Parallel(
         Sequence(
             LerpFunctionInterval(self.redTapeRing.setScale,
                                  fromData=scale,
                                  toData=scale * 1.1,
                                  duration=pulseTime / 2.0,
                                  blendType='easeInOut'),
             LerpFunctionInterval(self.redTapeRing.setScale,
                                  fromData=scale * 1.1,
                                  toData=scale,
                                  duration=pulseTime / 2.0,
                                  blendType='easeInOut')),
         LerpHprInterval(self.redTapeRing,
                         pulseTime,
                         Vec3(360, 0, 0),
                         startHpr=Vec3(0, 0, 0)),
         name='%s.pulseBubbleSeq-%s' %
         (self.__class__.__name__, self.toon.doId))
     bouncePercent = 1.2
     scaleTime = 0.5
     scaleBounceTime = 0.25
     self.popUpBubbleLerp = LerpScaleInterval(self.redTapeRing,
                                              scaleTime,
                                              scale * bouncePercent,
                                              startScale=0.0,
                                              blendType='easeInOut')
     self.popUpBubbleSeq = Sequence(
         Func(self.updateLerpStartScale, self.popUpBubbleLerp,
              self.redTapeRing),
         Func(self.redTapeRing.show),
         self.popUpBubbleLerp,
         LerpScaleInterval(self.redTapeRing,
                           scaleBounceTime,
                           scale,
                           startScale=scale * bouncePercent,
                           blendType='easeInOut'),
         Func(self.pulseBubbleSeq.loop),
         name='%s.popUpBubbleSeq-%s' %
         (self.__class__.__name__, self.toon.doId))
     self.removeBubbleLerp = LerpScaleInterval(self.redTapeRing,
                                               scaleBounceTime,
                                               scale * bouncePercent,
                                               startScale=scale,
                                               blendType='easeInOut')
     self.removeBubbleSeq = Sequence(
         Func(self.pulseBubbleSeq.clearToInitial),
         Func(self.updateLerpStartScale, self.removeBubbleLerp,
              self.redTapeRing),
         self.removeBubbleLerp,
         LerpScaleInterval(self.redTapeRing,
                           scaleTime,
                           0.0,
                           startScale=scale * bouncePercent,
                           blendType='easeInOut'),
         Func(self.redTapeRing.hide),
         name='%s.removeBubbleSeq-%s' %
         (self.__class__.__name__, self.toon.doId))
     self.redTapeRing.setScale(0.0)
     self.deathInterval = Sequence(
         Parallel(
             LerpHprInterval(self.toon, 1.0, Vec3(720, 0, 0)),
             LerpFunctionInterval(self.toon.setScale,
                                  fromData=1.0,
                                  toData=0.1,
                                  duration=1.0)),
         Func(self.toon.stash),
         name='%s.deathInterval-%s' %
         (self.__class__.__name__, self.toon.doId))
     self.spawnInterval = Sequence(
         Func(self.toon.stash),
         Func(self.resetToon),
         Wait(1.0),
         Func(self.toon.setAnimState, 'TeleportIn'),
         Func(self.toon.unstash),
         name='%s.spawnInterval-%s' %
         (self.__class__.__name__, self.toon.doId))
     singleBlinkTime = Globals.Gameplay.InvulSingleBlinkTime
     blinkTime = Globals.Gameplay.InvulBlinkTime
     invulBuffTime = Globals.Gameplay.InvulBuffTime
     self.blinkBubbleLoop = Sequence(
         LerpFunctionInterval(self.redTapeRing.setAlphaScale,
                              fromData=1.0,
                              toData=0.0,
                              duration=singleBlinkTime / 2.0,
                              blendType='easeInOut'),
         LerpFunctionInterval(self.redTapeRing.setAlphaScale,
                              fromData=0.0,
                              toData=1.0,
                              duration=singleBlinkTime / 2.0,
                              blendType='easeInOut'),
         name='%s.blinkBubbleLoop-%s' %
         (self.__class__.__name__, self.toon.doId))
     self.blinkBubbleSeq = Sequence(
         Wait(invulBuffTime - blinkTime),
         Func(self.blinkBubbleLoop.loop),
         Wait(blinkTime),
         Func(self.blinkBubbleLoop.finish),
         name='%s.blinkBubbleSeq-%s' %
         (self.__class__.__name__, self.toon.doId))
Example #3
0
 def doActivity(self):
     return Sequence(
                     Func(self.avatar.animFSM.request, 'stunned', ['squirt-small']),
                     Wait(6.0))
Example #4
0
 def enterPlant(self):
     self.current_animations = [self.PLANT]
     if not self.getCurrentAnim() == self.PLANT:
         self.current_seq = Sequence(self.actorInterval(self.PLANT, False),
                                     Func(self.tryRequest, self.STATE_IDLE))
         self.current_seq.start()
Example #5
0
 def enterAboutToBiteLure(self):
     self.fish.initVariables()
     self.fish.showStaminaBar()
     self.fish.actor.clearControlEffectWeights()
     self.fish.reparentTo(self.fish.fishManager.objectsWithCaustics)
     self.fish.setPos(FishingGlobals.rightFishBarrier + FishingGlobals.fullyOffscreenXOffset, 0.0, max(-63.0, self.fish.fishManager.gameObject.lure.getZ()))
     self.fish.actor.changeAnimationTo('swimIdleOpposite')
     self.lfChaseLureSequence = Sequence(self.fish.posInterval(self.fish.myData['swimLeftDuration'], Point3(self.fish.myData['fishTurnX'], 0.0, self.fish.getZ())), Func(self.fish.actor.changeAnimationTo, 'turnOpposite', False), Wait(self.fish.actor.getDuration('turnOpposite') / 4.0), Func(self.fish.actor.changeAnimationTo, 'swimIdle'), self.fish.posInterval(self.fish.myData['swimRightDuration'], Point3(self.fish.fishManager.gameObject.lure.getX() - self.fish.myData['biteXOffset'], 0.0, self.fish.getZ())), Func(self.request, 'Biting'), name=self.fish.fishManager.gameObject.distributedFishingSpot.uniqueName('lfChaseLureSequence'))
     self.lfChaseLureSequence.start()
Example #6
0
    def __tickNearbyCogs(self):
        self.__selectNearbyCogs()
        tickTrack = Parallel()
        tickDuration = 0.4
        for cog in self.selectedCogs:
            if not cog.isDead():
                base.audio3d.attachSoundToObject(self.tickSfx, cog)
                tickTrack.append(Parallel(Sequence(LerpColorScaleInterval(cog, tickDuration, VBase4(1, 0, 0, 1)), Func(cog.clearColorScale), Func(cog.d_disableMovement)), SoundInterval(self.tickSfx, duration=tickDuration, node=cog)))
            else:
                self.selectedCogs.remove(cog)

        return tickTrack
 def updateAspectRatio(self):
     fadeSequence = Sequence(Func(base.transitions.fadeOut, .2), Wait(.2),
                             Func(self.setRatio),
                             Func(base.transitions.fadeIn, .2)).start()
    def showToonHitBySuit(self, avId, timestamp):
        toon = self.getAvatar(avId)
        if toon == None:
            return
        rng = self.toonRNGs[self.avIdList.index(avId)]
        curPos = toon.getPos(render)
        oldTrack = self.toonHitTracks[avId]
        if oldTrack.isPlaying():
            oldTrack.finish()
        toon.setPos(curPos)
        toon.setZ(self.TOON_Z)
        parentNode = render.attachNewNode('mazeFlyToonParent-' + ` avId `)
        parentNode.setPos(toon.getPos())
        toon.reparentTo(parentNode)
        toon.setPos(0, 0, 0)
        startPos = parentNode.getPos()
        dropShadow = toon.dropShadow.copyTo(parentNode)
        dropShadow.setScale(toon.dropShadow.getScale(render))
        trajectory = Trajectory.Trajectory(0,
                                           Point3(0, 0, 0),
                                           Point3(0, 0, 50),
                                           gravMult=1.0)
        oldFlyDur = trajectory.calcTimeOfImpactOnPlane(0.0)
        trajectory = Trajectory.Trajectory(0,
                                           Point3(0, 0, 0),
                                           Point3(0, 0, 50),
                                           gravMult=0.55)
        flyDur = trajectory.calcTimeOfImpactOnPlane(0.0)
        avIndex = self.avIdList.index(avId)
        endPos = CTGG.ToonStartingPositions[avIndex]

        def flyFunc(t,
                    trajectory,
                    startPos=startPos,
                    endPos=endPos,
                    dur=flyDur,
                    moveNode=parentNode,
                    flyNode=toon):
            u = t / dur
            moveNode.setX(startPos[0] + u * (endPos[0] - startPos[0]))
            moveNode.setY(startPos[1] + u * (endPos[1] - startPos[1]))
            flyNode.setPos(trajectory.getPos(t))

        flyTrack = Sequence(LerpFunctionInterval(flyFunc,
                                                 fromData=0.0,
                                                 toData=flyDur,
                                                 duration=flyDur,
                                                 extraArgs=[trajectory]),
                            name=toon.uniqueName('hitBySuit-fly'))
        geomNode = toon.getGeomNode()
        startHpr = geomNode.getHpr()
        destHpr = Point3(startHpr)
        hRot = rng.randrange(1, 8)
        if rng.choice([0, 1]):
            hRot = -hRot
        destHpr.setX(destHpr[0] + hRot * 360)
        spinHTrack = Sequence(LerpHprInterval(geomNode,
                                              flyDur,
                                              destHpr,
                                              startHpr=startHpr),
                              Func(geomNode.setHpr, startHpr),
                              name=toon.uniqueName('hitBySuit-spinH'))
        parent = geomNode.getParent()
        rotNode = parent.attachNewNode('rotNode')
        geomNode.reparentTo(rotNode)
        rotNode.setZ(toon.getHeight() / 2.0)
        oldGeomNodeZ = geomNode.getZ()
        geomNode.setZ(-toon.getHeight() / 2.0)
        startHpr = rotNode.getHpr()
        destHpr = Point3(startHpr)
        pRot = rng.randrange(1, 3)
        if rng.choice([0, 1]):
            pRot = -pRot
        destHpr.setY(destHpr[1] + pRot * 360)
        spinPTrack = Sequence(LerpHprInterval(rotNode,
                                              flyDur,
                                              destHpr,
                                              startHpr=startHpr),
                              Func(rotNode.setHpr, startHpr),
                              name=toon.uniqueName('hitBySuit-spinP'))
        i = self.avIdList.index(avId)
        soundTrack = Sequence(Func(base.playSfx,
                                   self.sndTable['hitBySuit'][i]),
                              Wait(flyDur * (2.0 / 3.0)),
                              SoundInterval(self.sndTable['falling'][i],
                                            duration=flyDur * (1.0 / 3.0)),
                              name=toon.uniqueName('hitBySuit-soundTrack'))

        def preFunc(self=self, avId=avId, toon=toon, dropShadow=dropShadow):
            forwardSpeed = toon.forwardSpeed
            rotateSpeed = toon.rotateSpeed
            if avId == self.localAvId:
                self.stopGameWalk()
            else:
                toon.stopSmooth()
            if forwardSpeed or rotateSpeed:
                toon.setSpeed(forwardSpeed, rotateSpeed)
            toon.dropShadow.hide()

        def postFunc(self=self,
                     avId=avId,
                     oldGeomNodeZ=oldGeomNodeZ,
                     dropShadow=dropShadow,
                     parentNode=parentNode):
            if avId == self.localAvId:
                base.localAvatar.setPos(endPos)
                if hasattr(self, 'gameWalk'):
                    toon = base.localAvatar
                    toon.setSpeed(0, 0)
                    self.startGameWalk()
            dropShadow.removeNode()
            del dropShadow
            toon = self.getAvatar(avId)
            if toon:
                toon.dropShadow.show()
                geomNode = toon.getGeomNode()
                rotNode = geomNode.getParent()
                baseNode = rotNode.getParent()
                geomNode.reparentTo(baseNode)
                rotNode.removeNode()
                del rotNode
                geomNode.setZ(oldGeomNodeZ)
            if toon:
                toon.reparentTo(render)
                toon.setPos(endPos)
            parentNode.removeNode()
            del parentNode
            if avId != self.localAvId:
                if toon:
                    toon.startSmooth()

        preFunc()
        slipBack = Parallel(
            Sequence(ActorInterval(toon, 'slip-backward', endFrame=24),
                     Wait(CTGG.LyingDownDuration - (flyDur - oldFlyDur)),
                     ActorInterval(toon, 'slip-backward', startFrame=24)))
        if toon.doId == self.localAvId:
            slipBack.append(SoundInterval(self.sndOof))
        hitTrack = Sequence(Parallel(flyTrack, spinHTrack, spinPTrack,
                                     soundTrack),
                            slipBack,
                            Func(postFunc),
                            name=toon.uniqueName('hitBySuit'))
        self.notify.debug('hitTrack duration = %s' % hitTrack.getDuration())
        self.toonHitTracks[avId] = hitTrack
        hitTrack.start(globalClockDelta.localElapsedTime(timestamp))
        return
    def showResults(self):
        if not self.gameIsEnding:
            self.gameIsEnding = True
            for barrel in self.barrels:
                barrel.wrtReparentTo(render)

            for key in self.cogInfo:
                thief = self.cogInfo[key]['suit']
                thief.suit.setPos(100, 0, 0)
                thief.suit.hide()

            self.__killRewardCountdown()
            self.stopGameWalk()
            numBarrelsSaved = len(self.barrels) - len(self.stolenBarrels)
            resultStr = ''
            if numBarrelsSaved == len(self.barrels):
                resultStr = TTLocalizer.CogThiefPerfect
            elif numBarrelsSaved > 1:
                resultStr = TTLocalizer.CogThiefBarrelsSaved % {
                    'num': numBarrelsSaved
                }
            elif numBarrelsSaved == 1:
                resultStr = TTLocalizer.CogThiefBarrelSaved % {
                    'num': numBarrelsSaved
                }
            else:
                resultStr = TTLocalizer.CogThiefNoBarrelsSaved
            perfectTextSubnode = hidden.attachNewNode(
                self.__genText(resultStr))
            perfectText = hidden.attachNewNode('perfectText')
            perfectTextSubnode.reparentTo(perfectText)
            frame = self.__textGen.getCardActual()
            offsetY = -abs(frame[2] + frame[3]) / 2.0
            perfectTextSubnode.setPos(0, 0, offsetY)
            perfectText.setColor(1, 0.1, 0.1, 1)

            def fadeFunc(t, text=perfectText):
                text.setColorScale(1, 1, 1, t)

            def destroyText(text=perfectText):
                text.removeNode()

            def safeGameOver(self=self):
                if not self.frameworkFSM.isInternalStateInFlux():
                    self.gameOver()

            textTrack = Sequence(
                Func(perfectText.reparentTo, aspect2d),
                Parallel(
                    LerpScaleInterval(perfectText,
                                      duration=0.5,
                                      scale=0.3,
                                      startScale=0.0),
                    LerpFunctionInterval(fadeFunc,
                                         fromData=0.0,
                                         toData=1.0,
                                         duration=0.5)), Wait(2.0),
                Parallel(
                    LerpScaleInterval(perfectText, duration=0.5, scale=1.0),
                    LerpFunctionInterval(fadeFunc,
                                         fromData=1.0,
                                         toData=0.0,
                                         duration=0.5,
                                         blendType='easeIn')),
                Func(destroyText), WaitInterval(0.5), Func(safeGameOver))
            if numBarrelsSaved == len(self.barrels):
                soundTrack = SoundInterval(self.sndPerfect)
            else:
                soundTrack = Sequence()
            self.resultIval = Parallel(textTrack, soundTrack)
            self.resultIval.start()
Example #10
0
 def fillSlot(self, index, avId, wantBoardingShow=0):
     self.notify.debug('%s.fillSlot(%s, %s, ... %s)' %
                       (self.doId, index, avId, globalClock.getRealTime()))
     request = self.toonRequests.get(index)
     if request:
         self.cr.relatedObjectMgr.abortRequest(request)
         del self.toonRequests[index]
     if avId == 0:
         pass
     elif avId not in self.cr.doId2do:
         func = PythonUtil.Functor(self.gotToon, index, avId)
         self.toonRequests[index] = self.cr.relatedObjectMgr.requestObjects(
             [avId], allCallback=func)
     elif not self.isSetup:
         self.deferredSlots.append((index, avId, wantBoardingShow))
     else:
         if avId == base.localAvatar.getDoId():
             place = base.cr.playGame.getPlace()
             if not place:
                 return
             elevator = self.getPlaceElevator()
             if elevator == None:
                 place.fsm.request('elevator')
                 elevator = self.getPlaceElevator()
             if not elevator:
                 return
             self.localToonOnBoard = 1
             if hasattr(localAvatar,
                        'boardingParty') and localAvatar.boardingParty:
                 localAvatar.boardingParty.forceCleanupInviteePanel()
                 localAvatar.boardingParty.forceCleanupInviterPanels()
             if hasattr(base.localAvatar, 'elevatorNotifier'):
                 base.localAvatar.elevatorNotifier.cleanup()
             cameraTrack = Sequence()
             cameraTrack.append(
                 Func(elevator.fsm.request, 'boarding',
                      [self.getElevatorModel()]))
             cameraTrack.append(Func(elevator.fsm.request, 'boarded'))
         toon = self.cr.doId2do[avId]
         toon.stopSmooth()
         toon.wrtReparentTo(self.golfKart)
         sitStartDuration = toon.getDuration('sit-start')
         jumpTrack = self.generateToonJumpTrack(toon, index)
         track = Sequence(jumpTrack,
                          Func(toon.setAnimState, 'Sit', 1.0),
                          Func(self.clearToonTrack, avId),
                          name=toon.uniqueName('fillElevator'),
                          autoPause=1)
         if wantBoardingShow:
             boardingTrack, boardingTrackType = self.getBoardingTrack(
                 toon, index, True)
             track = Sequence(boardingTrack, track)
             if avId == base.localAvatar.getDoId():
                 cameraWaitTime = 2.5
                 if boardingTrackType == BoardingGroupShow.TRACK_TYPE_RUN:
                     cameraWaitTime = 0.5
                 cameraTrack = Sequence(Wait(cameraWaitTime), cameraTrack)
         if self.canHideBoardingQuitBtn(avId):
             track = Sequence(
                 Func(localAvatar.boardingParty.groupPanel.disableQuitButton
                      ), track)
         if avId == base.localAvatar.getDoId():
             track = Parallel(cameraTrack, track)
         track.delayDelete = DelayDelete.DelayDelete(
             toon, 'CogKart.fillSlot')
         self.storeToonTrack(avId, track)
         track.start()
         self.fillSlotTrack = track
         self.boardedAvIds[avId] = None
     return
 def enterTransition(self, nextState):
     self.gameObject.lfgGui.setTransitionText(nextState)
     self.lfgMouseInteractionTransitionSequence = Sequence(self.gameObject.lfgGui.transitionTextMovingSequence, Func(self.request, nextState), name = self.gameObject.distributedFishingSpot.uniqueName('lfgMouseInteractionTransitionSequence'))
     self.lfgMouseInteractionTransitionSequence.start()
    def startHitFlyingToonInterval(self):
        hitByEnemyPos = self.toon.getPos(render)
        collVec = hitByEnemyPos - self.collPos
        collVec[2] = 0.0
        collVec.normalize()
        collVec *= Globals.Gameplay.HitKnockbackDist

        def spinPlayer(t, rand):
            if rand == 0:
                self.toon.setH(-(t * 720.0))
            else:
                self.toon.setH(t * 720.0)

        direction = random.randint(0, 1)
        self.startEnemyHitIval(Sequence(Parallel(LerpFunc(spinPlayer, fromData=0.0, toData=1.0, duration=Globals.Gameplay.HitKnockbackTime, blendType='easeInOut', extraArgs=[direction]), LerpPosInterval(self.toon, duration=Globals.Gameplay.HitKnockbackTime, pos=hitByEnemyPos + collVec, blendType='easeOut')), Func(self.request, 'FreeFly'), name='hitByLegalEagleIval-%i' % self.toon.doId))
 def startHitRunningToonInterval(self):
     dur = self.toon.getDuration('slip-backward')
     self.startEnemyHitIval(Sequence(Wait(dur), Func(self.request, 'Running'), name='hitByLegalEagleIval-%i' % self.toon.doId))
 def initLocalPlayerIntervals(self):
     self.coolDownAfterHitInterval = Sequence(Wait(Globals.Gameplay.HitCooldownTime), Func(self.setEnemyHitting, False), name='coolDownAfterHitInterval-%i' % self.toon.doId)
     self.deathInterval = Sequence(Func(self.resetVelocities), Parallel(Parallel(Func(self._deathSfx.play), LerpHprInterval(self.toon, 1.0, Vec3(720, 0, 0)), LerpFunctionInterval(self.toon.setScale, fromData=1.0, toData=0.1, duration=1.0), self.toon.posInterval(0.5, Vec3(0, 0, -25), other=self.toon)), Sequence(Wait(0.5), Func(base.transitions.irisOut))), Func(self.toon.stash), Wait(1.0), Func(self.toonSpawnFunc), name='%s.deathInterval' % self.__class__.__name__)
     self.outOfTimeInterval = Sequence(Func(messenger.send, CogdoFlyingLocalPlayer.PlayWaitingMusicEventName), Func(self._loseSfx.play), Func(base.transitions.irisOut), Wait(1.0), Func(self.resetVelocities), Func(self._guiMgr.setMessage, '', transition=None), Func(self.toon.stash), Func(self.toonSpawnFunc), name='%s.outOfTimeInterval' % self.__class__.__name__)
     self.spawnInterval = Sequence(Func(self.resetToonFunc), Func(self._cameraMgr.update, 0.0), Func(self._level.update), Func(self.toon.cnode.broadcastPosHprFull), Func(base.transitions.irisIn), Wait(0.5), Func(self.toon.setAnimState, 'TeleportIn'), Func(self.toon.unstash), Wait(1.5), Func(self.requestPostSpawnState), name='%s.spawnInterval' % self.__class__.__name__)
     self.waitingForWinInterval = Sequence(Func(self._guiMgr.setMessage, TTLocalizer.CogdoFlyingGameWaiting % '.'), Wait(1.5), Func(self._guiMgr.setMessage, TTLocalizer.CogdoFlyingGameWaiting % '..'), Wait(1.5), Func(self._guiMgr.setMessage, TTLocalizer.CogdoFlyingGameWaiting % '...'), Wait(1.5), name='%s.waitingForWinInterval' % self.__class__.__name__)
     self.waitingForWinSeq = Sequence(Func(self.setWaitingForWinState), Wait(4.0), Func(self.removeAllMemos), Wait(2.0), Func(self.game.distGame.d_sendRequestAction, Globals.AI.GameActions.LandOnWinPlatform, 0), Func(self.playWaitingForWinInterval), name='%s.waitingForWinSeq' % self.__class__.__name__)
     self.winInterval = Sequence(Func(self._guiMgr.setMessage, ''), Wait(4.0), Func(self.game.distGame.d_sendRequestAction, Globals.AI.GameActions.WinStateFinished, 0), name='%s.winInterval' % self.__class__.__name__)
     self.goSadSequence = Sequence(Wait(2.5), Func(base.transitions.irisOut, 1.5), name='%s.goSadSequence' % self.__class__.__name__)
     self.introGuiSeq = Sequence(Wait(0.5), Parallel(Func(self._guiMgr.setTemporaryMessage, TTLocalizer.CogdoFlyingGameMinimapIntro, duration=5.0), Sequence(Wait(1.0), Func(self._guiMgr.presentProgressGui))), Wait(5.0), Func(self._guiMgr.setMessage, TTLocalizer.CogdoFlyingGamePickUpAPropeller), name='%s.introGuiSeq' % self.__class__.__name__)
Example #15
0
    def enterScoring(self):
        sortedByDistance = []
        for avId in self.avIdList:
            np = self.getTireNp(avId)
            pos = np.getPos()
            pos.setZ(0)
            sortedByDistance.append((avId, pos.length()))

        def compareDistance(x, y):
            if x[1] - y[1] > 0:
                return 1
            elif x[1] - y[1] < 0:
                return -1
            else:
                return 0

        sortedByDistance.sort(cmp=compareDistance)
        self.scoreMovie = Sequence()
        curScale = 0.01
        curTime = 0
        self.scoreCircle.setScale(0.01)
        self.scoreCircle.show()
        self.notify.debug('newScores = %s' % self.newScores)
        circleStartTime = 0
        for index in xrange(len(sortedByDistance)):
            distance = sortedByDistance[index][1]
            avId = sortedByDistance[index][0]
            scorePanelIndex = self.avIdList.index(avId)
            time = (distance - curScale) / IceGameGlobals.ExpandFeetPerSec
            if time < 0:
                time = 0.01
            scaleXY = distance + IceGameGlobals.TireRadius
            self.notify.debug('circleStartTime = %s' % circleStartTime)
            self.scoreMovie.append(
                Parallel(
                    LerpScaleInterval(self.scoreCircle, time,
                                      Point3(scaleXY, scaleXY, 1.0)),
                    SoundInterval(self.scoreCircleSound,
                                  duration=time,
                                  startTime=circleStartTime)))
            circleStartTime += time
            startScore = self.scorePanels[scorePanelIndex].getScore()
            destScore = self.newScores[scorePanelIndex]
            self.notify.debug('for avId %d, startScore=%d, newScores=%d' %
                              (avId, startScore, destScore))

            def increaseScores(t,
                               scorePanelIndex=scorePanelIndex,
                               startScore=startScore,
                               destScore=destScore):
                oldScore = self.scorePanels[scorePanelIndex].getScore()
                diff = destScore - startScore
                newScore = int(startScore + diff * t)
                if newScore > oldScore:
                    base.playSfx(self.countSound)
                self.scorePanels[scorePanelIndex].setScore(newScore)
                self.scores[scorePanelIndex] = newScore

            duration = (destScore -
                        startScore) * IceGameGlobals.ScoreCountUpRate
            tireNp = self.tireDict[avId]['tireNodePath']
            self.scoreMovie.append(
                Parallel(
                    LerpFunctionInterval(increaseScores, duration),
                    Sequence(
                        LerpColorScaleInterval(tireNp, duration / 6.0,
                                               VBase4(1, 0, 0, 1)),
                        LerpColorScaleInterval(tireNp, duration / 6.0,
                                               VBase4(1, 1, 1, 1)),
                        LerpColorScaleInterval(tireNp, duration / 6.0,
                                               VBase4(1, 0, 0, 1)),
                        LerpColorScaleInterval(tireNp, duration / 6.0,
                                               VBase4(1, 1, 1, 1)),
                        LerpColorScaleInterval(tireNp, duration / 6.0,
                                               VBase4(1, 0, 0, 1)),
                        LerpColorScaleInterval(tireNp, duration / 6.0,
                                               VBase4(1, 1, 1, 1)))))
            curScale += distance

        self.scoreMovie.append(
            Func(self.sendUpdate, 'reportScoringMovieDone', []))
        self.scoreMovie.start()
Example #16
0
def makeExplosion(pos=(0, 0, 0),
                  scale=1,
                  sound=True,
                  shakeCam=True,
                  duration=1.0,
                  soundVol=1.0):
    explosion = loader.loadModel('phase_3.5/models/props/explosion.bam')
    explosion.setScale(scale)
    explosion.reparentTo(render)
    explosion.setBillboardPointEye()
    explosion.setLightOff(1)
    explosion.hide(ShadowCameraBitmask)
    explosion.setPos(pos)

    frames = 10.0
    fps = 24.0
    duration = frames / fps
    explosion.find("**/+SequenceNode").node().play()

    from src.coginvasion.toon import ParticleLoader
    smoke = ParticleLoader.loadParticleEffect(
        "phase_14/etc/explosion_smoke.ptf")
    smoke.setDepthWrite(False, 1)
    smoke.setScale(scale)
    smoke.setPos(pos)
    smoke.start(render, getParticleRender())

    track = Parallel()

    if sound:
        import random

        hlsounds = base.config.GetBool('explosion-hlsounds', False)
        if hlsounds:
            hldir = "phase_14/audio/sfx/"
            snd = base.audio3d.loadSfx(hldir + random.choice(
                ['explode3_hl2', 'explode4_hl2', 'explode5_hl2']) + ".ogg")
        else:
            snd = base.audio3d.loadSfx(
                "phase_3.5/audio/sfx/ENC_cogfall_apart.ogg")

        base.audio3d.attachSoundToObject(snd, explosion)

        # explosion aftermaths
        debChoice = random.randint(1, 4)
        if debChoice <= 3:
            debris = base.audio3d.loadSfx(
                "phase_14/audio/sfx/debris{0}.ogg".format(debChoice))
        else:
            debris = base.audio3d.loadSfx(
                "phase_4/audio/sfx/MG_crash_whizz.ogg")
        base.audio3d.attachSoundToObject(debris, explosion)

        track.append(SoundInterval(snd, volume=soundVol))
        wait = 0.0791 if not hlsounds else 0.0
        track.append(
            Sequence(Wait(wait), SoundInterval(debris, volume=soundVol)))

    if shakeCam:
        dist = camera.getDistance(explosion)
        maxDist = 100.0 * scale
        maxIntense = 1.4 * scale
        if dist <= maxDist:
            base.doCamShake(maxIntense - (maxIntense * (dist / maxDist)),
                            duration)

    track.append(Sequence(Wait(duration), Func(explosion.removeNode)))
    track.append(Sequence(Wait(duration), Func(smoke.softStop)))
    track.start()
Example #17
0
    def createSequence(self, msg_list):
        animation = Sequence()
        animation.append(Func(self.beforeAnimHook))
        unit_pos_dict = {}

        animation.append(Func(self.parent.parent.movement.hideUnitAvailMove))

        for msg in msg_list:
            #========================================================================
            #
            if msg[0] == MOVE or msg[0] == ROTATE:
                unit_id = msg[1]
                tile = msg[2]
                unit_model = self.parent.unit_renderer_dict[unit_id]
                if unit_pos_dict.has_key(unit_id):
                    start_pos = unit_pos_dict[unit_id][0]
                    start_head = unit_pos_dict[unit_id][1]
                else:
                    start_pos = unit_model.model.getPos(render)
                    start_head = unit_model.model.getH(render)
                end_pos = Point3(utils.TILE_SIZE * (tile[0] + 0.5),
                                 utils.TILE_SIZE * (tile[1] + 0.5),
                                 utils.GROUND_LEVEL)
                dummy_start = NodePath("dummy_start")
                dummy_end = NodePath("dummy_end")
                dummy_start.setPos(start_pos)
                dummy_end.setPos(end_pos)
                dummy_start.lookAt(dummy_end)
                end_head = dummy_start.getH(render)

                interval_heading = unit_model.model.quatInterval(
                    0.2,
                    hpr=Point3(end_head, 0, 0),
                    startHpr=Point3(start_head, 0, 0))
                if msg[0] == MOVE:
                    interval_movement = unit_model.node.posInterval(
                        0.5, end_pos, startPos=start_pos)
                    anim = Parallel(interval_movement, interval_heading)
                    unit_pos_dict[unit_id] = (end_pos, end_head)
                else:
                    anim = interval_heading
                    unit_pos_dict[unit_id] = (start_pos, end_head)
                animation.append(anim)
            #========================================================================
            #
            elif msg[0] == UNIT:
                unit = msg[1]
                old_x = self.parent.parent.local_engine.units[
                    unit['id']]['pos'][0]
                old_y = self.parent.parent.local_engine.units[
                    unit['id']]['pos'][1]
                self.parent.parent.local_engine.refreshUnit(unit)
                if self.parent.parent.local_engine.isThisMyUnit(unit['id']):
                    animation.append(
                        Func(self.parent.parent.interface.refreshUnitInfo,
                             unit['id']))
                if self.parent.parent.sel_unit_id == unit['id']:
                    animation.append(
                        Func(self.parent.parent.interface.processUnitData,
                             unit['id']))
                    animation.append(
                        Func(self.parent.parent.interface.printUnitData,
                             unit['id']))
                    self.parent.parent.movement.calcUnitAvailMove(unit['id'])
                    animation.append(
                        Func(self.parent.parent.movement.showUnitAvailMove))
                    #self.parent.parent.render_manager.refreshEnemyUnitMarkers()
                    #if unit['pos'][0] != old_x or unit['pos'][1] != old_y or unit['last_action']=='use':
                    #    animation.append(Func(self.parent.parent.render_manager.refreshFow))
                    #self.parent.sgm.playUnitStateAnim( unit['id'] )
            #========================================================================
            #
            elif msg[0] == SHOOT:
                animation.append(
                    self.buildShootAnim(msg[1], msg[2], msg[3], msg[4]))
            #========================================================================
            #
            elif msg[0] == OVERWATCH:
                if msg[1] == SHOOT:
                    animation.append(
                        self.buildShootAnim(msg[2], msg[3], msg[4], msg[5]))
            #========================================================================
            #
            elif msg[0] == SPOT:
                unit = msg[1]
                self.parent.parent.local_engine.units[unit['id']] = unit
                # This is the first time we see this unit, fill out starting variables for move and rotate actions
                spotted_unit_model = self.parent.loadUnit(unit['id'], False)

                pos = Point3(
                    utils.TILE_SIZE * (self.parent.parent.local_engine.units[
                        unit['id']]['pos'][0] + 0.5),
                    utils.TILE_SIZE * (self.parent.parent.local_engine.units[
                        unit['id']]['pos'][1] + 0.5), utils.GROUND_LEVEL)
                heading = utils.getHeadingAngle(
                    self.parent.parent.local_engine.units[
                        unit['id']]['heading'])
                animation.append(
                    Func(self.parent.showUnit, spotted_unit_model, pos, None))

                self.parent.parent.local_engine.level.putUnitDict(msg[1])
                if self.parent.parent.player_id == self.parent.parent.turn_player and self.parent.parent.sel_unit_id != None:
                    self.parent.parent.movement.calcUnitAvailMove(
                        self.parent.parent.sel_unit_id)
                    #self.parent.sgm.showVisibleEnemies( self.parent.sel_unit_id )
            #========================================================================
            #
            elif msg[0] == VANISH:
                unit_id = msg[1]
                animation.append(Func(self.parent.hideUnit, unit_id))
            #========================================================================
            #
            elif msg[0] == LEVEL:
                self.parent.parent.local_engine.old_level = self.parent.parent.local_engine.level
                level = msg[1]
                for unit in self.parent.parent.local_engine.units.itervalues():
                    level.putUnitDict(unit)
                self.parent.parent.local_engine.level = level
                # if our enemy opens doors, we need to update visibility
                # enemy's visibility gets updated when he gets UNIT message
                if self.parent.parent.player_id == self.parent.parent.turn_player and self.parent.parent.sel_unit_id != None:
                    self.parent.parent.movement.calcUnitAvailMove(
                        self.parent.parent.sel_unit_id)

                # Create animations based on level changes (opened doors etc)
                for x, val in enumerate(
                        self.parent.parent.local_engine.old_level._grid):
                    for y, val2 in enumerate(val):
                        if val2 != None and self.parent.parent.local_engine.level._grid[
                                x][y] != None:
                            if val2.name != self.parent.parent.local_engine.level._grid[
                                    x][y].name:
                                mod_x, mod_y, mod_h = self.parent.level_renderer.getWallPosition(
                                    x, y)
                                model = self.parent.level_renderer.door_dict[(
                                    mod_x, mod_y, mod_h)]
                                door = model.find("**/Door*")
                                if val2.name == 'ClosedDoor':
                                    if (
                                            x, y
                                    ) in self.parent.parent.local_engine.visible_walls:
                                        animation.append(
                                            door.posInterval(
                                                1, Vec3(0.5, 0, -0.72)))
                                    else:
                                        animation.append(
                                            Func(door.setPos,
                                                 Vec3(0.5, 0, -0.72)))
                                elif val2.name == 'OpenedDoor':
                                    if (
                                            x, y
                                    ) in self.parent.parent.local_engine.visible_walls:
                                        animation.append(
                                            door.posInterval(
                                                1, Vec3(0.5, 0, 0)))
                                    else:
                                        animation.append(
                                            Func(door.setPos, Vec3(0.5, 0, 0)))
            #========================================================================
            #
            elif msg[0] == USE:
                self.parent.unit_renderer_dict[msg[1]].model.play('use')
            #========================================================================
            #
            elif msg[0] == TAUNT:
                self.parent.sgm.unit_np_dict[msg[1][0]].model.play('taunt')
                if msg[1][1]:
                    self.parent.handleShoot(msg[1][1])
            #========================================================================
            #
            elif msg[0] == NEW_GAME_STARTED:
                self.parent.newGameStarted(msg[1])
            #========================================================================
            #
            else:
                self._message_in_process = True
                self.log.error("Unknown message Type: %s", msg[0])
                self._message_in_process = False

        animation.append(Func(self.parent.parent.render_manager.refreshFow))
        animation.append(Func(self.afterAnimHook))
        animation.start()
Example #18
0
    def upgradePieces(self):
        for columnIndex in range(self.numColumns):
            for rowIndex in range(self.numRows - 1):
                if self.boardPieces[columnIndex][rowIndex] is None:
                    filled = False
                    for rowIndex2 in range(rowIndex + 1, self.numRows):
                        if self.boardPieces[columnIndex][
                                rowIndex2] is not None:
                            if filled == False:
                                filled = True
                                piece = self.boardPieces[columnIndex][
                                    rowIndex2]
                                if not piece.pendingMatch:
                                    self.boardPieces[columnIndex][
                                        rowIndex] = self.boardPieces[
                                            columnIndex][rowIndex2]
                                    self.boardPieces[columnIndex][
                                        rowIndex2] = None
                                    if piece in self.upgradeList:
                                        rotQuat = Quat()
                                        rotQuat2 = Quat()
                                        rotQuat3 = Quat()
                                        rotQuat.setHpr(
                                            (piece.getH(), piece.getP() + 90,
                                             piece.getR()))
                                        rotQuat2.setHpr(
                                            (piece.getH(), piece.getP() + 270,
                                             piece.getR()))
                                        rotQuat3.setHpr(
                                            (piece.getH(), piece.getP() + 360,
                                             piece.getR()))
                                        self.potionGame.animationList.append(
                                            Sequence(
                                                Func(piece.setY, -10),
                                                LerpQuatInterval(
                                                    piece.background,
                                                    duration=0.4,
                                                    quat=rotQuat,
                                                    blendType='easeIn'),
                                                Func(piece.upgrade),
                                                Parallel(
                                                    piece.moveToBoardSlow(
                                                        columnIndex, rowIndex),
                                                    LerpQuatInterval(
                                                        piece.background,
                                                        duration=0.4,
                                                        quat=rotQuat3,
                                                        startQuat=rotQuat2,
                                                        blendType='easeOut')),
                                                Func(piece.setY, 0)))
                                        self.delayDropped = True
                                        self.upgradeList.remove(piece)
                                    else:
                                        self.delayDropped = True
                                        self.potionGame.animationList.append(
                                            Sequence(
                                                Func(piece.setY, -5),
                                                Wait(0.5),
                                                piece.moveToBoard(
                                                    columnIndex, rowIndex),
                                                Func(piece.setY, 0)))

        for piece in self.upgradeList:
            rotQuat = Quat()
            rotQuat2 = Quat()
            rotQuat3 = Quat()
            rotQuat.setHpr((piece.getH(), piece.getP() + 90, piece.getR()))
            rotQuat2.setHpr((piece.getH(), piece.getP() + 270, piece.getR()))
            rotQuat3.setHpr((piece.getH(), piece.getP() + 360, piece.getR()))
            piece.setY(-10)
            OutSeq = LerpQuatInterval(piece.background,
                                      duration=0.4,
                                      quat=rotQuat3,
                                      startQuat=rotQuat2,
                                      blendType='easeOut')
            self.potionGame.animationList.append(
                Sequence(
                    LerpQuatInterval(piece.background,
                                     duration=0.4,
                                     quat=rotQuat,
                                     blendType='easeIn'), Func(piece.upgrade),
                    OutSeq, Func(piece.setY, 0)))

        return
Example #19
0
    def createOnePlayerSequence(self, index, duration):
        numVotes = self.votes[index]
        direction = self.directions[index]

        def ticketTicker(t,
                         label=self.entryList[index][direction + 1],
                         startVotes=0,
                         endVotes=numVotes):
            label['text'] = str(int(t * endVotes + startVotes))

        track = Parallel()
        startVotes = 0
        for prev in range(index):
            if self.directions[prev] == direction:
                startVotes += self.votes[prev]

        def totalTicker(t,
                        label=self.totalVotesLabels[direction],
                        startVotes=startVotes,
                        additionalVotes=numVotes):
            label['text'] = str(int(t * additionalVotes + startVotes))

        track.append(
            LerpFunc(totalTicker,
                     duration=duration,
                     name='countTotal %d' % index))
        if self.avVotesLabel.has_key(index):

            def avVotesTicker(t,
                              label=self.avVotesLabel[index],
                              startVotes=0,
                              endVotes=numVotes,
                              direction=direction):
                oldValue = label['text']
                newValue = int(t * endVotes + startVotes)
                label['text'] = str(newValue)
                if not oldValue == label['text']:
                    if newValue:
                        if direction == 0:
                            self.upArrowSfx[self.curArrowSfxIndex].play()
                        else:
                            self.downArrowSfx[self.curArrowSfxIndex].play()
                            self.curArrowSfxIndex += 1
                        if self.curArrowSfxIndex >= len(self.upArrowSfx):
                            self.curArrowSfxIndex = 0

            label = self.avVotesLabel[index]
            track.append(
                Func(self.avVotesLabel[index].show,
                     name='showName %d' % index))
            if self.avArrows.has_key(index):
                track.append(
                    Func(self.avArrows[index].show,
                         name='showArrow %d' % index))
            if direction == 0 and numVotes:
                pass
            elif direction == 1 and numVotes:
                pass
            else:
                track.append(SoundInterval(self.noVoteSfx))
            track.append(
                LerpFunc(avVotesTicker,
                         duration=duration,
                         name='countAvVotes %d' % index))
        return track
Example #20
0
    def handleMouseUp(self):
        dragHandled = False
        if self.lastDragPos is not None:
            if base.mouseWatcherNode.hasMouse():
                screenx = base.mouseWatcherNode.getMouseX()
                screeny = base.mouseWatcherNode.getMouseY()
                dragPos = self.getRelativePoint(render2d,
                                                (screenx, 0, screeny))
                self.dragDist += (dragPos - self.lastDragPos).length()
                if self.dragDist < 0.01:
                    if self.dragPiece is not None:
                        self.dragPiece.wrtReparentTo(self)
                        self.potionGame.animationList.append(
                            Sequence(
                                self.dragPiece.moveToBoard(
                                    self.dragPiece.column, self.dragPiece.row),
                                Func(self.dragPiece.setY, 0)))
                        self.dragPiece = None
                    if screenx > 0 and screeny > -0.8 and screenx < 0.88 and screeny < 0.92:
                        self.moveDown()
                if self.dragPiece is not None:
                    if False:
                        recipePos = self.potionGame.currentRecipe.getRelativePoint(
                            render2d, (screenx, 0, screeny))
                        neededIngredient = None
                        for ingredient in self.potionGame.currentRecipe.ingredients:
                            if ingredient.hiddenColor == self.dragPiece.colorIndex and ingredient.hiddenLevel == self.dragPiece.level and not ingredient.completed:
                                neededIngredient = ingredient

                        if neededIngredient is not None:
                            for ingredient in self.potionGame.currentRecipe.ingredients:
                                if not ingredient.completed and not dragHandled:
                                    ingredientDist = (ingredient.getPos() -
                                                      recipePos).length()
                                    if ingredientDist < 0.2:
                                        neededIngredient.completed = True
                                        self.dragPiece.wrtReparentTo(
                                            self.potionGame.currentRecipe)
                                        self.boardPieces[
                                            self.dragPiece.column][
                                                self.dragPiece.row] = None
                                        self.lastDragPos = None
                                        self.potionGame.animationList.append(
                                            Sequence(
                                                self.dragPiece.moveToBoard(
                                                    neededIngredient.column,
                                                    neededIngredient.row),
                                                Func(neededIngredient.setColor,
                                                     self.dragPiece.colorIndex,
                                                     self.dragPiece.level),
                                                Func(self.killDragPiece)))
                                        dragHandled = True
                                        self.experementMatched = True
                                        self.potionGame.gameFSM.request('Anim')

                        else:
                            for ingredient in self.potionGame.currentRecipe.ingredients:
                                if not ingredient.completed:
                                    ingredientDist = (ingredient.getPos() -
                                                      recipePos).length()
                                    if ingredientDist < 0.2:
                                        self.experementFailed = True

                if self.dragPiece is not None and not dragHandled:
                    self.dragPiece.wrtReparentTo(self)
                    self.potionGame.animationList.append(
                        Sequence(
                            self.dragPiece.moveToBoard(self.dragPiece.column,
                                                       self.dragPiece.row),
                            Func(self.dragPiece.setY, 0)))
                    self.potionGame.gameFSM.request('Anim')
                    self.dragPiece = None
                self.lastDragPos = None
        return
Example #21
0
 def startAttacking(self, task=None):
     if hasattr(self.suit,
                'DELETED') or not hasattr(self, 'attacksThisSession'):
         self.stopAttacking()
         if task:
             return Task.done
     if self.attacksThisSession > 0:
         self.resetAvatarsInRange()
     if hasattr(self.suit, 'DELETED'):
         self.stopAttacking()
         return
     from lib.coginvasion.cog.SuitPanicBehavior import SuitPanicBehavior
     brain = self.suit.getBrain()
     panicBehavior = brain.getBehavior(SuitPanicBehavior)
     healthPerct = float(self.suit.getHealth()) / float(
         self.suit.getMaxHealth())
     origHealthPerct = float(self.origHealth) / float(
         self.suit.getMaxHealth())
     if len(
             self.avatarsInRange
     ) < 1 or panicBehavior and healthPerct <= panicBehavior.getPanicHealthPercentage(
     ) or healthPerct - origHealthPerct >= self.ABANDON_ATTACK_PERCT:
         self.stopAttacking()
         return
     from lib.coginvasion.cog.SuitCallInBackupBehavior import SuitCallInBackupBehavior
     backupBehavior = brain.getBehavior(SuitCallInBackupBehavior)
     if backupBehavior is not None:
         if backupBehavior.shouldStart():
             brain.queueBehavior(SuitCallInBackupBehavior)
             self.stopAttacking()
             return
     target = self.avatarsInRange[0]
     attack = SuitUtils.attack(self.suit, target)
     if target.__class__.__name__ == 'DistributedPieTurretAI':
         distance = self.suit.getDistance(target)
         speed = 50.0
         if attack == 'glowerpower':
             speed = 100.0
         timeUntilRelease = distance / speed
         if attack != 'glowerpower':
             if self.suit.getSuit()[0].getSuitType() == SuitType.C:
                 timeUntilRelease += 2.2
             else:
                 timeUntilRelease += 3.0
         else:
             timeUntilRelease += 1.0
         turretPos = target.getPos(render)
         hp = int(self.suit.getMaxHealth() /
                  SuitAttacks.SuitAttackDamageFactors[attack])
         if self.suit.suitPlan.getName() == SuitGlobals.VicePresident:
             hp = int(200 / SuitAttacks.SuitAttackDamageFactors[attack])
         self.suitAttackTurretTrack = Sequence(
             Wait(timeUntilRelease),
             Func(self.damageTurret, target, turretPos, hp))
         self.suitAttackTurretTrack.start()
     self.isAttacking = True
     self.attacksThisSession += 1
     self.attacksDone += 1
     self.ATTACK_COOLDOWN = SuitAttacks.SuitAttackLengths[attack]
     if self.attacksThisSession < self.maxAttacksPerSession and not target.isDead(
     ):
         taskMgr.doMethodLater(self.ATTACK_COOLDOWN, self.startAttacking,
                               self.suit.uniqueName('attackTask'))
     else:
         taskMgr.doMethodLater(self.ATTACK_COOLDOWN, self.stopAttacking,
                               self.suit.uniqueName('finalAttack'))
     if task:
         return Task.done
     return
 def splitBoard(self):
     self.sawingLine.reset()
     board = self.currentBoard
     boardIndex = self.currentBoardIndex
     if self.hitZone2Penalty:
         boardSplitAnim = Parallel(
             LerpPosInterval(self.board_left,
                             duration=self.config.splitBoardAnimTime,
                             pos=Point3(-2.0, 0.0, 0.0)),
             LerpPosInterval(self.board_right,
                             duration=self.config.splitBoardAnimTime,
                             pos=Point3(2.0, 0.0, 0.0)),
             LerpFunc(self.zone2_left.setSa,
                      duration=self.config.splitBoardAnimTime / 2.0,
                      fromData=1.0,
                      toData=0.0),
             LerpFunc(self.zone2_right.setSa,
                      duration=self.config.splitBoardAnimTime / 2.0,
                      fromData=1.0,
                      toData=0.0),
             LerpFunc(self.zone1_left.setSa,
                      duration=self.config.splitBoardAnimTime / 2.0,
                      fromData=1.0,
                      toData=0.0),
             LerpFunc(self.zone1_right.setSa,
                      duration=self.config.splitBoardAnimTime / 2.0,
                      fromData=1.0,
                      toData=0.0),
             LerpFunc(self.cut.setSa,
                      duration=self.config.splitBoardAnimTime / 2.0,
                      fromData=1.0,
                      toData=0.0))
     elif self.hitZone1Penalty:
         boardSplitAnim = Parallel(
             LerpPosInterval(self.board_left,
                             duration=self.config.splitBoardAnimTime,
                             pos=Point3(-2.0, 0.0, 0.0)),
             LerpPosInterval(self.board_right,
                             duration=self.config.splitBoardAnimTime,
                             pos=Point3(2.0, 0.0, 0.0)),
             LerpPosInterval(self.zone2_left,
                             duration=self.config.splitBoardAnimTime,
                             pos=Point3(-2.0, 0.0, 0.0)),
             LerpPosInterval(self.zone2_right,
                             duration=self.config.splitBoardAnimTime,
                             pos=Point3(2.0, 0.0, 0.0)),
             LerpFunc(self.zone1_left.setSa,
                      duration=self.config.splitBoardAnimTime / 2.0,
                      fromData=1.0,
                      toData=0.0),
             LerpFunc(self.zone1_right.setSa,
                      duration=self.config.splitBoardAnimTime / 2.0,
                      fromData=1.0,
                      toData=0.0),
             LerpFunc(self.cut.setSa,
                      duration=self.config.splitBoardAnimTime / 2.0,
                      fromData=1.0,
                      toData=0.0))
     else:
         boardSplitAnim = Parallel(
             LerpPosInterval(self.piece1,
                             duration=self.config.splitBoardAnimTime,
                             pos=Point3(-2.0, self.config.boardYDist, 0.0)),
             LerpPosInterval(self.piece2,
                             duration=self.config.splitBoardAnimTime,
                             pos=Point3(2.0, self.config.boardYDist, 0.0)),
             LerpFunc(self.cut.setSa,
                      duration=self.config.splitBoardAnimTime / 2.0,
                      fromData=1.0,
                      toData=0.0))
     self.splitBoardSequence = Sequence(
         Func(self.updateScore),
         Func(self.boardComplete.play),
         boardSplitAnim,
         Func(board.stash),
         Func(self.piece1.setPos, self.piece1.getPos()),
         Func(self.piece2.setPos, self.piece2.getPos()),
         Func(self.board_right.setPos, self.board_right.getPos()),
         Func(self.board_left.setPos, self.board_left.getPos()),
         Func(self.zone2_right.setPos, self.zone2_right.getPos()),
         Func(self.zone2_left.setPos, self.zone2_left.getPos()),
         Func(self.zone1_right.setPos, self.zone1_right.getPos()),
         Func(self.zone1_left.setPos, self.zone1_left.getPos()),
         Func(self.cut.setSa, 1.0),
         Func(self.zone1_right.setSa, 1.0),
         Func(self.zone1_left.setSa, 1.0),
         Func(self.zone2_right.setSa, 1.0),
         Func(self.zone2_left.setSa, 1.0),
         Func(self.board_right.setSa, 1.0),
         Func(self.board_left.setSa, 1.0),
         Func(self.loadNewBoard),
         Func(self.addBoardBackToPool, board, boardIndex),
         name='RepairSawGame.splitBoardSequence')
     self.splitBoardSequence.start()
 def initIntervals(self):
     dur = Globals.LegalEagle.LiftOffTime
     nestPos = self.nest.getPos(render)
     airPos = nestPos + Vec3(0.0, 0.0, Globals.LegalEagle.LiftOffHeight)
     self.takeOffSeq = Sequence(Parallel(
         Sequence(
             Wait(dur * 0.6),
             LerpPosInterval(self.suit,
                             dur * 0.4,
                             startPos=nestPos,
                             pos=airPos,
                             blendType='easeInOut'))),
                                Wait(1.5),
                                Func(self.request, 'next'),
                                name='%s.takeOffSeq-%i' %
                                (self.__class__.__name__, self.index))
     self.landOnNestPosLerp = LerpPosInterval(self.suit,
                                              1.0,
                                              startPos=airPos,
                                              pos=nestPos,
                                              blendType='easeInOut')
     self.landingSeq = Sequence(Func(self.updateLandOnNestPosLerp),
                                Parallel(self.landOnNestPosLerp),
                                Func(self.request, 'next'),
                                name='%s.landingSeq-%i' %
                                (self.__class__.__name__, self.index))
     dur = Globals.LegalEagle.ChargeUpTime
     self.chargeUpPosLerp = LerpFunc(
         self.moveAlongChargeUpMopathFunc,
         fromData=0.0,
         toData=self.chargeUpMotionPath.getMaxT(),
         duration=dur,
         blendType='easeInOut')
     self.chargeUpAttackSeq = Sequence(
         Func(self.updateChargeUpPosLerp),
         self.chargeUpPosLerp,
         Func(self.request, 'next'),
         name='%s.chargeUpAttackSeq-%i' %
         (self.__class__.__name__, self.index))
     dur = Globals.LegalEagle.RetreatToNestTime
     self.retreatToNestPosLerp = LerpPosInterval(self.suit,
                                                 dur,
                                                 startPos=Vec3(0, 0, 0),
                                                 pos=airPos,
                                                 blendType='easeInOut')
     self.retreatToNestSeq = Sequence(Func(self.updateRetreatToNestPosLerp),
                                      self.retreatToNestPosLerp,
                                      Func(self.request, 'next'),
                                      name='%s.retreatToNestSeq-%i' %
                                      (self.__class__.__name__, self.index))
     dur = Globals.LegalEagle.RetreatToSkyTime
     self.retreatToSkyPosLerp = LerpFunc(
         self.moveAlongRetreatMopathFunc,
         fromData=0.0,
         toData=self.retreatToSkyMotionPath.getMaxT(),
         duration=dur,
         blendType='easeOut')
     self.retreatToSkySeq = Sequence(Func(self.updateRetreatToSkyPosLerp),
                                     self.retreatToSkyPosLerp,
                                     Func(self.request, 'next'),
                                     name='%s.retreatToSkySeq-%i' %
                                     (self.__class__.__name__, self.index))
     dur = Globals.LegalEagle.PreAttackTime
     self.preAttackLerpXY = LerpFunc(self.updateAttackXY,
                                     fromData=0.0,
                                     toData=1.0,
                                     duration=dur)
     self.preAttackLerpZ = LerpFunc(self.updateAttackZ,
                                    fromData=0.0,
                                    toData=1.0,
                                    duration=dur,
                                    blendType='easeOut')
     dur = Globals.LegalEagle.PostAttackTime
     self.postAttackPosLerp = LerpPosInterval(self.suit,
                                              dur,
                                              startPos=Vec3(0, 0, 0),
                                              pos=Vec3(0, 0, 0))
     self.attackSeq = Sequence(
         Parallel(self.preAttackLerpXY, self.preAttackLerpZ),
         Func(self.updatePostAttackPosLerp),
         self.postAttackPosLerp,
         Func(self.request, 'next'),
         name='%s.attackSeq-%i' % (self.__class__.__name__, self.index))
     dur = Globals.LegalEagle.CooldownTime
     self.cooldownSeq = Sequence(Wait(dur),
                                 Func(self.request, 'next'),
                                 name='%s.cooldownSeq-%i' %
                                 (self.__class__.__name__, self.index))
     self.propTrack = Sequence(
         ActorInterval(self.prop, 'propeller', startFrame=0, endFrame=14))
     self.hoverOverNestSeq = Sequence(
         ActorInterval(self.suit,
                       'landing',
                       startFrame=10,
                       endFrame=20,
                       playRate=0.5),
         ActorInterval(self.suit,
                       'landing',
                       startFrame=20,
                       endFrame=10,
                       playRate=0.5))
    def loadNewBoard(self):
        self.progressLabel.stash()
        self.progressDescriptionLabel.stash()
        if self.totalScore >= self.config.totalPoints:
            if self.onDeckBoard:
                self.onDeckBoard.stash()

            self.progressDescriptionLabel.stash()
            taskMgr.remove('SawingGame.updateSawTask')
            self.request('Outro')
            return None

        self.currentBoard = self.onDeckBoard
        self.currentBoardIndex = self.onDeckBoardIndex
        self.piece1 = self.currentBoard.find('**/piece_1')
        self.piece1.setTransparency(1)
        self.piece2 = self.currentBoard.find('**/piece_2')
        self.piece2.setTransparency(1)
        self.cut = self.currentBoard.find('**/piece_cut')
        self.cut.setColor(self.config.cutColor)
        self.cut.setTransparency(1)
        self.board_left = self.piece1.find('**/board')
        self.board_left.setTransparency(1)
        self.zone1_left = self.piece1.find('**/zone_1')
        self.zone1_left.setTransparency(1)
        self.zone2_left = self.piece1.find('**/zone_2')
        self.zone2_left.setTransparency(1)
        self.board_right = self.piece2.find('**/board')
        self.board_right.setTransparency(1)
        self.zone1_right = self.piece2.find('**/zone_1')
        self.zone1_right.setTransparency(1)
        self.zone2_right = self.piece2.find('**/zone_2')
        self.zone2_right.setTransparency(1)
        self.board_left.setCollideMask(SAW_COLLIDE_MASK)
        self.board_right.setCollideMask(SAW_COLLIDE_MASK)
        self.cut.setCollideMask(SAW_COLLIDE_MASK)
        self.zone1_right.setCollideMask(SAW_COLLIDE_MASK)
        self.zone1_left.setCollideMask(SAW_COLLIDE_MASK)
        self.zone2_right.setCollideMask(SAW_COLLIDE_MASK)
        self.zone2_left.setCollideMask(SAW_COLLIDE_MASK)
        self.startPositions = (
            self.currentBoard.find('**/locator_start_0').getPos() +
            Point3(*self.config.activeBoardPosition),
            self.currentBoard.find('**/locator_start_1').getPos() +
            Point3(*self.config.activeBoardPosition))
        self.currentStartIndex = 0
        for waypoint in self.sawWaypoints:
            waypoint.removeNode()

        self.sawWaypoints = []
        locator = self.currentBoard.find('**/locator_0')
        index = 0
        while not locator.isEmpty():
            self.sawWaypoints.append(
                SawWaypoint(index, self.currentBoard, locator.getPos()))
            locator = self.currentBoard.find('**/locator_%i' % (index + 1))
            index += 1
        self.sawButton.deactivate()
        self.sawButton.setPos(self.startPositions[self.currentStartIndex])
        self.hitBoardPenalty = False
        self.hitZone1Penalty = False
        self.hitZone2Penalty = False
        self.lastMousePos = None
        self.moveDiffForSound = self.config.playSawingSoundDelta + 0.10000000000000001
        self.newBoardSequence = Sequence(
            Parallel(
                self.currentBoard.posInterval(
                    self.config.newBoardAnimTime,
                    Point3(*self.config.activeBoardPosition)),
                self.currentBoard.scaleInterval(self.config.newBoardAnimTime,
                                                1.0)),
            name='RepairSawingGame.newBoardSequence')
        if self.state in ['Game']:
            self.newBoardSequence.append(Func(self.sawButton.activate))

        self.newBoardSequence.append(Wait(0.5))
        self.newBoardSequence.append(Func(self.moveNewBoardOnDeck))
        self.newBoardSequence.start()
Example #25
0
 def doActivity(self):
     return Sequence(Func(self.avatar.animFSM.request, 'win'), Wait(9.0))
    def __showToonHitBySuit(self, avId, timestamp):
        toon = self.getAvatar(avId)
        if toon == None:
            return
        rng = self.toonRNGs[self.avIdList.index(avId)]
        curPos = toon.getPos(render)
        oldTrack = self.toonHitTracks[avId]
        if oldTrack.isPlaying():
            oldTrack.finish()
        toon.setPos(curPos)
        toon.setZ(self.TOON_Z)
        parentNode = render.attachNewNode('mazeFlyToonParent-' + ` avId `)
        parentNode.setPos(toon.getPos())
        toon.reparentTo(parentNode)
        toon.setPos(0, 0, 0)
        startPos = parentNode.getPos()
        dropShadow = toon.dropShadow.copyTo(parentNode)
        dropShadow.setScale(toon.dropShadow.getScale(render))
        trajectory = Trajectory.Trajectory(0,
                                           Point3(0, 0, 0),
                                           Point3(0, 0, 50),
                                           gravMult=1.0)
        flyDur = trajectory.calcTimeOfImpactOnPlane(0.0)
        while 1:
            endTile = [
                rng.randint(2, self.maze.width - 1),
                rng.randint(2, self.maze.height - 1)
            ]
            if self.maze.isWalkable(endTile[0], endTile[1]):
                break
        endWorldCoords = self.maze.tile2world(endTile[0], endTile[1])
        endPos = Point3(endWorldCoords[0], endWorldCoords[1], startPos[2])

        def flyFunc(t,
                    trajectory,
                    startPos=startPos,
                    endPos=endPos,
                    dur=flyDur,
                    moveNode=parentNode,
                    flyNode=toon):
            u = t / dur
            moveNode.setX(startPos[0] + u * (endPos[0] - startPos[0]))
            moveNode.setY(startPos[1] + u * (endPos[1] - startPos[1]))
            flyNode.setPos(trajectory.getPos(t))

        flyTrack = Sequence(LerpFunctionInterval(flyFunc,
                                                 fromData=0.0,
                                                 toData=flyDur,
                                                 duration=flyDur,
                                                 extraArgs=[trajectory]),
                            name=toon.uniqueName('hitBySuit-fly'))
        if avId != self.localAvId:
            cameraTrack = Sequence()
        else:
            self.camParent.reparentTo(parentNode)
            startCamPos = camera.getPos()
            destCamPos = camera.getPos()
            zenith = trajectory.getPos(flyDur / 2.0)[2]
            destCamPos.setZ(zenith * 1.3)
            destCamPos.setY(destCamPos[1] * 0.3)

            def camTask(task,
                        zenith=zenith,
                        flyNode=toon,
                        startCamPos=startCamPos,
                        camOffset=destCamPos - startCamPos):
                u = flyNode.getZ() / zenith
                camera.setPos(startCamPos + camOffset * u)
                camera.lookAt(toon)
                return Task.cont

            camTaskName = 'mazeToonFlyCam-' + ` avId `
            taskMgr.add(camTask, camTaskName, priority=20)

            def cleanupCamTask(self=self,
                               toon=toon,
                               camTaskName=camTaskName,
                               startCamPos=startCamPos):
                taskMgr.remove(camTaskName)
                self.camParent.reparentTo(toon)
                camera.setPos(startCamPos)
                camera.lookAt(toon)

            cameraTrack = Sequence(Wait(flyDur),
                                   Func(cleanupCamTask),
                                   name='hitBySuit-cameraLerp')

        geomNode = toon.getGeomNode()
        startHpr = geomNode.getHpr()
        destHpr = Point3(startHpr)
        hRot = rng.randrange(1, 8)
        if rng.choice([0, 1]):
            hRot = -hRot
        destHpr.setX(destHpr[0] + hRot * 360)
        spinHTrack = Sequence(LerpHprInterval(geomNode,
                                              flyDur,
                                              destHpr,
                                              startHpr=startHpr),
                              Func(geomNode.setHpr, startHpr),
                              name=toon.uniqueName('hitBySuit-spinH'))
        parent = geomNode.getParent()
        rotNode = parent.attachNewNode('rotNode')
        geomNode.reparentTo(rotNode)
        rotNode.setZ(toon.getHeight() / 2.0)
        oldGeomNodeZ = geomNode.getZ()
        geomNode.setZ(-toon.getHeight() / 2.0)
        startHpr = rotNode.getHpr()
        destHpr = Point3(startHpr)
        pRot = rng.randrange(1, 3)
        if rng.choice([0, 1]):
            pRot = -pRot
        destHpr.setY(destHpr[1] + pRot * 360)
        spinPTrack = Sequence(LerpHprInterval(rotNode,
                                              flyDur,
                                              destHpr,
                                              startHpr=startHpr),
                              Func(rotNode.setHpr, startHpr),
                              name=toon.uniqueName('hitBySuit-spinP'))
        i = self.avIdList.index(avId)
        soundTrack = Sequence(Func(base.playSfx,
                                   self.sndTable['hitBySuit'][i]),
                              Wait(flyDur * (2.0 / 3.0)),
                              SoundInterval(self.sndTable['falling'][i],
                                            duration=flyDur * (1.0 / 3.0)),
                              name=toon.uniqueName('hitBySuit-soundTrack'))

        def preFunc(self=self, avId=avId, toon=toon, dropShadow=dropShadow):
            forwardSpeed = toon.forwardSpeed
            rotateSpeed = toon.rotateSpeed
            if avId == self.localAvId:
                self.orthoWalk.stop()
            else:
                toon.stopSmooth()
            if forwardSpeed or rotateSpeed:
                toon.setSpeed(forwardSpeed, rotateSpeed)
            toon.dropShadow.hide()

        def postFunc(self=self,
                     avId=avId,
                     oldGeomNodeZ=oldGeomNodeZ,
                     dropShadow=dropShadow,
                     parentNode=parentNode):
            if avId == self.localAvId:
                base.localAvatar.setPos(endPos)
                if hasattr(self, 'orthoWalk'):
                    if self.gameFSM.getCurrentState().getName() == 'play':
                        self.orthoWalk.start()
            dropShadow.removeNode()
            del dropShadow
            toon.dropShadow.show()
            geomNode = toon.getGeomNode()
            rotNode = geomNode.getParent()
            baseNode = rotNode.getParent()
            geomNode.reparentTo(baseNode)
            rotNode.removeNode()
            del rotNode
            geomNode.setZ(oldGeomNodeZ)
            toon.reparentTo(render)
            toon.setPos(endPos)
            parentNode.removeNode()
            del parentNode
            if avId != self.localAvId:
                toon.startSmooth()

        preFunc()

        hitTrack = Sequence(Parallel(flyTrack, cameraTrack, spinHTrack,
                                     spinPTrack, soundTrack),
                            Func(postFunc),
                            name=toon.uniqueName('hitBySuit'))

        self.toonHitTracks[avId] = hitTrack

        hitTrack.start(globalClockDelta.localElapsedTime(timestamp))
 def __allowDetect(self, task):
     if self.fadeTrack:
         self.fadeTrack.finish()
     self.fadeTrack = Sequence(self.ballModel.colorScaleInterval(0.2, self.ballColor), Func(self.ballModel.clearTransparency), name='fadeTrack-allowDetect')
     self.fadeTrack.start()
     self.trigger.unstash()
     self.accept(self.triggerEvent, self.__hitTrigger)
 def setHillType(self, type):
     if self.isUp and (self.hillType == MoleFieldBase.HILL_MOLE
                       and type == MoleFieldBase.HILL_BOMB
                       or self.hillType == MoleFieldBase.HILL_BOMB
                       and type == MoleFieldBase.HILL_MOLE):
         return
     self.hillType = type
     self.moleHead.remove()
     if type == MoleFieldBase.HILL_MOLE:
         self.moleHead = loader.loadModel(
             'phase_12/models/bossbotHQ/mole_norm')
         self.moleColNodePath.setScale(3.0)
         self.moleHead.setH(0)
         self.mole.setBillboardAxis(localAvatar, 0)
     if type == MoleFieldBase.HILL_BOMB or type == MoleFieldBase.HILL_COGWHACKED:
         self.moleHead = loader.loadModel(
             'phase_12/models/bossbotHQ/mole_cog')
         self.moleColNodePath.setScale(1.0)
         self.mole.setBillboardAxis(localAvatar, 0)
         if type == MoleFieldBase.HILL_COGWHACKED:
             self.doMoleDown()
             BattleParticles.loadParticles()
             singleGear = BattleParticles.createParticleEffect(
                 'GearExplosion', numParticles=1)
             smallGearExplosion = BattleParticles.createParticleEffect(
                 'GearExplosion', numParticles=10)
             bigGearExplosion = BattleParticles.createParticleEffect(
                 'BigGearExplosion', numParticles=30)
             gears2MTrack = Track((0.0,
                                   ParticleInterval(singleGear,
                                                    self.hill,
                                                    worldRelative=1,
                                                    duration=5.7,
                                                    cleanup=True)),
                                  (0.0,
                                   ParticleInterval(smallGearExplosion,
                                                    self.hill,
                                                    worldRelative=0,
                                                    duration=1.2,
                                                    cleanup=True)),
                                  (0.3,
                                   ParticleInterval(bigGearExplosion,
                                                    self.hill,
                                                    worldRelative=0,
                                                    duration=1.0,
                                                    cleanup=True)),
                                  name='gears2MTrack')
             gears2MTrack.start()
             self.popIval = Sequence(
                 Parallel(
                     Sequence(
                         LerpPosInterval(self.moleHead, 0.05,
                                         Point3(0.28, 0.0, 0.0)),
                         LerpPosInterval(self.moleHead, 0.05,
                                         Point3(0.0, -0.23, 0.0)),
                         LerpPosInterval(self.moleHead, 0.05,
                                         Point3(0.0, 0.0, 0.28)),
                         LerpPosInterval(self.moleHead, 0.05,
                                         Point3(-0.35, 0.0, 0.0)),
                         LerpPosInterval(self.moleHead, 0.05,
                                         Point3(0.0, 0.28, 0.0)),
                         LerpPosInterval(self.moleHead, 0.05,
                                         Point3(0.31, 0.0, 0.0)),
                         LerpPosInterval(self.moleHead, 0.05,
                                         Point3(0.0, -0.32, 0.0)),
                         LerpPosInterval(self.moleHead, 0.05,
                                         Point3(0.0, 0.0, 0.48)),
                         LerpPosInterval(self.moleHead, 0.05,
                                         Point3(-0.28, 0.0, 0.0)),
                         LerpPosInterval(self.moleHead, 0.05,
                                         Point3(0.0, 0.29, 0.0)))),
                 LerpPosInterval(self.mole, 0.5, Point3(0, 0, -2.5)),
                 Func(self.setHillType, MoleFieldBase.HILL_BOMB))
             self.popIval.start()
         else:
             self.moleHead.setH(0)
     if type == MoleFieldBase.HILL_WHACKED:
         self.moleHead = loader.loadModel(
             'phase_12/models/bossbotHQ/mole_hit')
         self.mole.setBillboardAxis(0)
         self.moleColNodePath.setScale(0.0)
         if self.popIval:
             self.popIval.finish()
         if self.downIval:
             self.downIval.finish()
         self.mole.setPos(0.0, 0.0, 0.0)
         self.popIval = Sequence(
             Parallel(
                 Sequence(
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.18, 0.0, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.0, -0.13, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.0, 0.0, 0.18)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(-0.15, 0.0, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.0, 0.18, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.11, 0.0, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.0, -0.12, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.0, 0.0, 0.18)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(-0.18, 0.0, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.0, 0.13, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.18, 0.0, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.0, -0.15, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.0, 0.0, 0.18)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(-0.16, 0.0, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.0, 0.18, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.11, 0.0, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.0, -0.18, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.0, 0.0, 0.17)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(-0.18, 0.0, 0.0)),
                     LerpPosInterval(self.moleHead, 0.05,
                                     Point3(0.0, 0.0, 0.0))),
                 Sequence(LerpScaleInterval(self.moleHead, 0.5, 3.5),
                          LerpScaleInterval(self.moleHead, 0.5, 1.0))),
             LerpPosInterval(self.mole, 0.5, Point3(0, 0, -2.5)),
             Func(self.setHillType, MoleFieldBase.HILL_MOLE))
         self.popIval.start()
     self.moleHead.reparentTo(self.mole)
 def getToonSitTrack(av):
     toonSitTrack = Sequence(ActorInterval(av, 'sit-start'), Func(av.loop, 'sit'))
     return toonSitTrack
    def goThroughTunnel(self, toZone, inOrOut, requestStatus=None):
        # inOrOut: 0 = in; 1 = out

        if self.tunnelTrack:
            self.ignore(self.tunnelTrack.getDoneEvent())
            self.tunnelTrack.finish()
            self.tunnelTrack = None

        linkTunnel = LinkTunnel.getTunnelThatGoesToZone(toZone)
        if not linkTunnel:
            return
        self.tunnelTrack = Parallel(
            name=self.uniqueName('Place.goThroughTunnel'))

        if inOrOut == 0:
            # Going in a tunnel!
            pivotPoint = linkTunnel.inPivotPoint
            pivotPointNode = linkTunnel.tunnel.attachNewNode(
                'tunnelPivotPoint')
            pivotPointNode.setPos(pivotPoint)
            self.stopSmooth()
            self.wrtReparentTo(pivotPointNode)
            if linkTunnel.__class__.__name__ == "SafeZoneLinkTunnel":
                self.setHpr(180, 0, 0)
            else:
                self.setHpr(0, 0, 0)
            if base.localAvatar.doId == self.doId:
                doneMethod = self._handleWentInTunnel
                extraArgs = [requestStatus]
                self.walkControls.setCollisionsActive(0)
                camera.wrtReparentTo(linkTunnel.tunnel)
                currCamPos = camera.getPos()
                currCamHpr = camera.getHpr()
                tunnelCamPos = linkTunnel.camPos
                tunnelCamHpr = linkTunnel.camHpr
                self.tunnelTrack.append(
                    LerpPosInterval(camera,
                                    duration=0.7,
                                    pos=tunnelCamPos,
                                    startPos=currCamPos,
                                    blendType='easeOut'))
                self.tunnelTrack.append(
                    LerpQuatInterval(camera,
                                     duration=0.7,
                                     quat=tunnelCamHpr,
                                     startHpr=currCamHpr,
                                     blendType='easeOut'))
            exitSeq = Sequence(Func(self.loop, 'run'))
            if base.localAvatar.doId == self.doId:
                exitSeq.append(Wait(2.0))
                exitSeq.append(Func(base.transitions.irisOut))
            self.tunnelTrack.append(exitSeq)
            self.tunnelTrack.append(
                Sequence(
                    LerpHprInterval(
                        pivotPointNode,
                        duration=2.0,
                        hpr=linkTunnel.inPivotEndHpr,
                        startHpr=linkTunnel.inPivotStartHpr,
                    ),
                    LerpPosInterval(pivotPointNode,
                                    duration=1.0,
                                    pos=(linkTunnel.inPivotEndX,
                                         pivotPointNode.getY(),
                                         pivotPointNode.getZ()),
                                    startPos=(linkTunnel.inPivotStartX,
                                              pivotPointNode.getY(),
                                              pivotPointNode.getZ()))))
        elif inOrOut == 1:
            # Going out!
            pivotPoint = linkTunnel.outPivotPoint
            pivotPointNode = linkTunnel.tunnel.attachNewNode(
                'tunnelPivotPoint')
            pivotPointNode.setPos(pivotPoint)
            pivotPointNode.setHpr(linkTunnel.outPivotStartHpr)
            if base.localAvatar.doId == self.doId:
                base.localAvatar.walkControls.setCollisionsActive(0)
                base.localAvatar.detachCamera()
                camera.reparentTo(linkTunnel.tunnel)
                tunnelCamPos = linkTunnel.camPos
                tunnelCamHpr = linkTunnel.camHpr
                camera.setPos(tunnelCamPos)
                camera.setHpr(tunnelCamHpr)
                doneMethod = self._handleCameOutTunnel
                extraArgs = []
            self.reparentTo(pivotPointNode)
            self.setHpr(linkTunnel.toonOutHpr)
            self.setPos(linkTunnel.toonOutPos)
            exitSeq = Sequence(
                Func(self.loop, 'run'),
                LerpPosInterval(pivotPointNode,
                                duration=1.0,
                                pos=(linkTunnel.outPivotEndX,
                                     pivotPointNode.getY(),
                                     pivotPointNode.getZ()),
                                startPos=(linkTunnel.outPivotStartX,
                                          pivotPointNode.getY(),
                                          pivotPointNode.getZ())),
                LerpHprInterval(
                    pivotPointNode,
                    duration=2.0,
                    hpr=linkTunnel.outPivotEndHpr,
                    startHpr=linkTunnel.outPivotStartHpr,
                ), Func(self.wrtReparentTo, render), Func(self.startSmooth))
            self.tunnelTrack.append(exitSeq)

        if base.localAvatar.doId == self.doId:
            self.tunnelTrack.setDoneEvent(self.tunnelTrack.getName())
            self.acceptOnce(self.tunnelTrack.getDoneEvent(), doneMethod,
                            extraArgs)

        self.tunnelTrack.start()