Пример #1
0
 def move_and_rotate_camera_to(self, new_pos, new_rot, absolute=True, duration=0):
     if settings.debug_jump: duration = 0
     if duration == 0:
         if absolute:
             self.camera.set_camera_pos(new_pos)
             self.camera.set_camera_rot(new_rot)
         else:
             self.camera.set_rel_camera_pos(new_pos)
             self.camera.set_rel_camera_rot(new_rot)
     else:
         if self.current_interval != None:
             self.current_interval.pause()
         self.fake = NodePath('fake')
         if absolute:
             self.start_pos = self.camera.get_rel_camera_pos()
             self.end_pos = self.camera.get_rel_position_of(new_pos)
             #TODO
             #new_rot = self.camera.get_rel_rotation_of(new_pos)
         nodepath_lerp = LerpQuatInterval(self.fake,
                                          duration=duration,
                                          blendType='easeInOut',
                                          quat = LQuaternion(*new_rot),
                                          startQuat = LQuaternion(*self.camera.get_camera_rot())
                                          )
         func_lerp = LerpFunc(self.do_camera_move_and_rot,
                              fromData=0,
                              toData=1,
                              duration=duration,
                              blendType='easeInOut',
                              name=None)
         parallel = Parallel(nodepath_lerp, func_lerp)
         self.current_interval = parallel
         self.current_interval.start()
Пример #2
0
    def getRunToStartPositionIval(self):
        targetH = self.locator.getH()
        travelVec = self.position - self.toon.getPos(self.activity.root)
        duration = travelVec.length() / 9.778

        startH = 0.0
        if travelVec.getY() < 0.0:
            startH = 180.0

        return Sequence(
            Func(self.toon.startPosHprBroadcast, 0.1),
            Func(self.toon.b_setAnimState, "run"),
            Parallel(
                self.toon.hprInterval(
                    0.5,
                    VBase3(startH, 0.0, 0.0),
                    other=self.activity.root,
                ),
                self.toon.posInterval(duration,
                                      self.position,
                                      other=self.activity.root),
            ),
            Func(self.toon.b_setAnimState, "neutral"),
            self.toon.hprInterval(0.25,
                                  VBase3(targetH, 0.0, 0.0),
                                  other=self.activity.root),
            Func(self.toon.stopPosHprBroadcast),
        )
Пример #3
0
    def startActive(self):
        DistributedPartyTeamActivity.startActive(self)
        self.toonIdsToStartPositions.clear()
        self.toonIdsToIsPullingFlags.clear()
        for toonId in self.getToonIdsAsList():
            self.toonIdsToIsPullingFlags[toonId] = False
            toon = self.getAvatar(toonId)
            if toon:
                self.toonIdsToStartPositions[toonId] = toon.getPos(self.root)
            else:
                self.notify.warning("couldn't find toon %d assigning 0,0,0 to startPos" % toonId)
                self.toonIdsToStartPositions[toonId] = Point3(0, 0, 0)

        self.unusedFallenPositionsIndices = [0,
         1,
         2,
         3]
        self.setupInterval = Parallel(self.globalSetupInterval)
        if self.isLocalToonPlaying:
            self.keyTTL = []
            self.idealForce = 0.0
            self.keyRate = 0
            self.rateMatchAward = 0.0
            self.allOutMode = False
            self.setIdealRate(PartyGlobals.TugOfWarTargetRateList[0][1])
            self.setupInterval.append(self.localSetupInterval)
        self.setupInterval.start()
Пример #4
0
    def loseGame(self, entry):
        # The triggers are set up so that the center of the ball should move to the
        # collision point to be in the hole
        global action
        action = "start"
        toPos = entry.getInteriorPoint(render)
        taskMgr.remove('rollTask')  # Stop the maze task
        self.pathFollowed = np.zeros(self.pm.shape)
        self.maze.setP(0)
        self.maze.setR(0)

        # Move the ball into the hole over a short sequence of time. Then wait a
        # second and call start to reset the game
        Sequence(
            Parallel(
                LerpFunc(self.ballRoot.setX,
                         fromData=self.ballRoot.getX(),
                         toData=toPos.getX(),
                         duration=.1),
                LerpFunc(self.ballRoot.setY,
                         fromData=self.ballRoot.getY(),
                         toData=toPos.getY(),
                         duration=.1),
                LerpFunc(self.ballRoot.setZ,
                         fromData=self.ballRoot.getZ(),
                         toData=self.ballRoot.getZ() - .9,
                         duration=.2)), Wait(1), Func(self.start)).start()
Пример #5
0
    def makeBlendIntervalForBlendingToThisAnimation(self,
                                                    newTransitionAnimation,
                                                    transitionDuration):
        currentlyPlayingAnimationsAndEffectsAndDesiredEffects = []
        for animationName in self.skeletonAnimationNames:
            if animationName == newTransitionAnimation:
                continue

            controlEffect = self.getControlEffect(animationName)
            if controlEffect > 0.0:
                currentlyPlayingAnimationsAndEffectsAndDesiredEffects.append(
                    (animationName, controlEffect, 0.0))
                continue

        currentlyPlayingAnimationsAndEffectsAndDesiredEffects.append(
            (newTransitionAnimation, 0.0, 1.0))
        if self.blendInterval:
            self.blendInterval.pause()
            self.blendInterval.clearToInitial()

        self.blendInterval = Sequence(name='%s_%d.blendInterval' %
                                      (self.getName(), self.uniqueCounter))
        par = Parallel()
        for (animationName, fromData,
             toData) in currentlyPlayingAnimationsAndEffectsAndDesiredEffects:
            par.append(
                LerpFunctionInterval(self.adjustEffect,
                                     duration=transitionDuration,
                                     fromData=fromData,
                                     toData=toData,
                                     extraArgs=[animationName]))

        self.blendInterval.append(par)
Пример #6
0
    def getIntroTrack(self):
        self._DistributedMazeGame__cameraTask(None)
        origCamParent = camera.getParent()
        origCamPos = camera.getPos()
        origCamHpr = camera.getHpr()
        iCamParent = base.localAvatar.attachNewNode('iCamParent')
        iCamParent.setH(180)
        camera.reparentTo(iCamParent)
        toonHeight = base.localAvatar.getHeight()
        camera.setPos(0, -15, toonHeight * 3)
        camera.lookAt(0, 0, toonHeight / 2.0)
        iCamParent.wrtReparentTo(origCamParent)
        waitDur = 5.0
        lerpDur = 4.5
        lerpTrack = Parallel()
        startHpr = iCamParent.getHpr()
        startHpr.setX(PythonUtil.reduceAngle(startHpr[0]))
        lerpTrack.append(LerpPosHprInterval(iCamParent, lerpDur, pos = Point3(0, 0, 0), hpr = Point3(0, 0, 0), startHpr = startHpr, name = self.uniqueName('introLerpParent')))
        lerpTrack.append(LerpPosHprInterval(camera, lerpDur, pos = origCamPos, hpr = origCamHpr, blendType = 'easeInOut', name = self.uniqueName('introLerpCameraPos')))
        base.localAvatar.startLookAround()
        
        def cleanup(origCamParent = origCamParent, origCamPos = origCamPos, origCamHpr = origCamHpr, iCamParent = iCamParent):
            camera.reparentTo(origCamParent)
            camera.setPos(origCamPos)
            camera.setHpr(origCamHpr)
            iCamParent.removeNode()
            del iCamParent
            base.localAvatar.stopLookAround()

        return Sequence(Wait(waitDur), lerpTrack, Func(cleanup))
Пример #7
0
 def letterboxOff(self, t=0.25, finishIval=None):
     """
     Move black bars away over t seconds.
     """
     self.noLetterbox()
     self.loadLetterbox()
     self.letterbox.unstash()
     if (t == 0):
         self.letterbox.stash()
     else:
         self.letterboxIval = Sequence(
             Parallel(
                 LerpPosInterval(
                     self.letterboxBottom,
                     t,
                     pos=Vec3(0, 0, -1.2),
                     # startPos = Vec3(0, 0, -1),
                 ),
                 LerpPosInterval(
                     self.letterboxTop,
                     t,
                     pos=Vec3(0, 0, 1),
                     # startPos = Vec3(0, 0, 0.8),
                 ),
             ),
             Func(self.letterbox.stash),
             Func(messenger.send, 'letterboxOff'),
             name=self.letterboxTaskName,
         )
         if finishIval:
             self.letterboxIval.append(finishIval)
         self.letterboxIval.start()
Пример #8
0
 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
 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()
Пример #10
0
 def poofBean(self, bean, beanAnim):
     if bean == None:
         self.notify.warning(
             'poofBean, returning immediately as bean is None')
         return
     if bean.isEmpty():
         self.notify.warning(
             'poofBean, returning immediately as bean is empty')
         return
     currentAlpha = bean.getColorScale()[3]
     currentScale = bean.getScale()
     poofAnim = Sequence(
         Parallel(
             LerpFunc(bean.setAlphaScale,
                      fromData=currentAlpha,
                      toData=0.0,
                      duration=0.25),
             LerpFunc(bean.setScale,
                      fromData=currentScale,
                      toData=currentScale * 5.0,
                      duration=0.25)), Func(bean.stash),
         Func(beanAnim.finish), Func(bean.setAlphaScale, currentAlpha),
         Func(bean.setScale, currentScale))
     poofAnim.start()
     return
Пример #11
0
    def load(self):
        CogdoGameMovie.load(self)

        def showDoor():
            camera.wrtReparentTo(render)
            camera.setPos(self._exit, 0, -55, 40)
            camera.lookAt(self._exit, 0, 0, -20)
            self._exit.open()

        exitDur = 1.0
        showExitIval = Sequence(
            Func(camera.wrtReparentTo, render),
            Parallel(
                camera.posInterval(exitDur,
                                   Point3(0, -55, 40),
                                   other=self._exit,
                                   blendType='easeInOut'),
                camera.hprInterval(exitDur,
                                   Point3(0, -45, 0),
                                   blendType='easeInOut')))

        def showPlayersLeaving():
            for player in self._players:
                self._exit.toonEnters(player.toon)

        self._ival = Sequence(
            showExitIval, Func(self._exit.open), Func(showPlayersLeaving),
            Wait(Globals.Gameplay.FinishDurationSeconds - exitDur - 1.0),
            Func(base.transitions.irisOut), Wait(1.0))
Пример #12
0
 def set_view(self, view='front', num=0):
     views = {
         'front': (Vec3(90, 0, 0), Vec3(90, 0, 0)),
         'back': (Vec3(-90, 0, 0), Vec3(-90, 0, 0)),
         'left': (Vec3(0, 0, 0), Vec3(0, 0, 0)),
         'right': (Vec3(180, 0, 0), Vec3(180, 0, 0)),
         'top': (Vec3(90, 0, 0), Vec3(90, 90, 0)),
         'bottom': (Vec3(90, 0, 0), Vec3(90, -90, 0))
     }
     if view in views:
         if self.node.get_hpr(render).almost_equal(
                 views[view][0]) and self.gimbal.get_hpr(
                     render).almost_equal(views[view][1]):
             return
         else:
             if num > 3:
                 self.node.set_hpr(render, views[view][0])
                 self.gimbal.set_hpr(render, views[view][1])
                 self.node.set_pos(render, (0, 0, 0))
                 return
             Sequence(
                 Parallel(
                     LerpHprInterval(self.gimbal,
                                     0.21,
                                     views[view][1],
                                     other=render),
                     LerpHprInterval(self.node,
                                     0.21,
                                     views[view][0],
                                     other=render),
                     LerpPosInterval(self.node,
                                     0.21,
                                     Vec3(0, 0, 0),
                                     other=render)),
                 Func(self.set_view, view, 1 + num)).start()
Пример #13
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(
         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()
    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()
Пример #15
0
 def letterboxOn(self, t=0.25, finishIval=None):
     """
     Move black bars in over t seconds.
     """
     self.noLetterbox()
     self.loadLetterbox()
     self.letterbox.unstash()
     if (t == 0):
         self.letterboxBottom.setPos(0, 0, -1)
         self.letterboxTop.setPos(0, 0, 0.8)
         fut = AsyncFuture()
         fut.setResult(None)
         return fut
     else:
         self.__letterboxFuture = AsyncFuture()
         self.letterboxIval = Sequence(Parallel(
             LerpPosInterval(self.letterboxBottom,
                             t,
                             pos = Vec3(0, 0, -1),
                             #startPos = Vec3(0, 0, -1.2),
                             ),
             LerpPosInterval(self.letterboxTop,
                             t,
                             pos = Vec3(0, 0, 0.8),
                             # startPos = Vec3(0, 0, 1),
                             ),
             ),
                                       Func(self.__finishLetterbox),
                                       name = self.letterboxTaskName,
                                       )
         if finishIval:
             self.letterboxIval.append(finishIval)
         self.letterboxIval.start()
         return self.__letterboxFuture
Пример #16
0
 def think(self, curTic, curT, unwalkables):
     self.TX = self.nextTX
     self.TY = self.nextTY
     self.lastDirection = self.direction
     self.direction = self.__chooseNewWalkDirection(unwalkables)
     self.nextTX, self.nextTY = self.__applyDirection(self.direction, self.TX, self.TY)
     self.occupiedTiles = [(self.TX, self.TY), (self.nextTX, self.nextTY)]
     if curTic == self.lastTicBeforeRender:
         fromCoords = self.maze.tile2world(self.TX, self.TY)
         toCoords = self.maze.tile2world(self.nextTX, self.nextTY)
         self.fromPos.set(fromCoords[0], fromCoords[1], self.SUIT_Z)
         self.toPos.set(toCoords[0], toCoords[1], self.SUIT_Z)
         self.moveIval = LerpPosInterval(self.suit, self.cellWalkDuration, self.toPos, startPos=self.fromPos, name=self.uniqueName(self.MOVE_IVAL_NAME))
         if self.direction != self.lastDirection:
             self.fromH = self.directionHs[self.lastDirection]
             toH = self.directionHs[self.direction]
             if self.fromH == 270 and toH == 0:
                 self.fromH = -90
             elif self.fromH == 0 and toH == 270:
                 self.fromH = 360
             self.fromHpr.set(self.fromH, 0, 0)
             self.toHpr.set(toH, 0, 0)
             turnIval = LerpHprInterval(self.suit, self.turnDuration, self.toHpr, startHpr=self.fromHpr, name=self.uniqueName('turnMazeSuit'))
             self.moveIval = Parallel(self.moveIval, turnIval, name=self.uniqueName(self.MOVE_IVAL_NAME))
         else:
             self.suit.setH(self.directionHs[self.direction])
         moveStartT = float(self.nextThinkTic) / float(self.ticFreq)
         self.moveIval.start(curT - (moveStartT + self.gameStartTime))
     self.nextThinkTic += self.ticPeriod
 def _DistributedPartyDanceActivityBase__setViewMode(self, mode):
     toon = base.localAvatar
     if mode == DanceViews.Normal:
         if self.cameraParallel is not None:
             self.cameraParallel.pause()
             self.cameraParallel = None
         
         camera.reparentTo(toon)
         base.localAvatar.startUpdateSmartCamera()
     elif mode == DanceViews.Dancing:
         base.localAvatar.stopUpdateSmartCamera()
         camera.wrtReparentTo(self.danceFloor)
         node = NodePath('temp')
         node.reparentTo(toon.getParent())
         node.setPos(Point3(0, -40, 20))
         node2 = NodePath('temp2')
         node2.reparentTo(self.danceFloor)
         node.reparentTo(node2)
         node2.setH(render, toon.getParent().getH())
         pos = node.getPos(self.danceFloor)
         node2.removeNode()
         node.removeNode()
         self.cameraParallel = Parallel(camera.posInterval(0.5, pos, blendType = 'easeIn'), camera.hprInterval(0.5, Point3(0, -27, 0), other = toon.getParent(), blendType = 'easeIn'))
         self.cameraParallel.start()
     
     self.currentCameraMode = mode
    def _runToonThroughSlot(self, toon, slot, goInside=True):
        helperNode = NodePath('helper')
        helperNode.reparentTo(toon.getParent())
        helperNode.lookAt(self)
        lookAtH = helperNode.getH(self._model)
        toonH = toon.getH(self._model)
        hDiff = abs(lookAtH - toonH)
        distanceFromElev = toon.getDistance(self._model)
        moveSpeed = 9.7780000000000005
        anim = 'run'
        if toon.animFSM.getCurrentState() == 'Sad':
            moveSpeed *= 0.5
            anim = 'sad-walk'

        runInsideDistance = 20
        track = Sequence(Func(toon.stopSmooth),
                         Func(toon.loop, anim, 1.0),
                         Parallel(
                             toon.hprInterval(hDiff / 360.0,
                                              Point3(lookAtH, 0, 0),
                                              other=self._model,
                                              blendType='easeIn'),
                             toon.posInterval(distanceFromElev / moveSpeed,
                                              Point3(
                                                  self._elevatorPoints[slot],
                                                  0, 0),
                                              other=self._model,
                                              blendType='easeIn')),
                         name=toon.uniqueName('runThroughExit'),
                         autoPause=1)
        if goInside:
            track.append(
                Parallel(
                    toon.hprInterval(lookAtH / 360.0,
                                     Point3(0, 0, 0),
                                     other=self._model,
                                     blendType='easeOut'),
                    toon.posInterval(runInsideDistance / moveSpeed,
                                     Point3(self._elevatorPoints[slot],
                                            runInsideDistance, 0),
                                     other=self._model,
                                     blendType='easeOut')))

        track.append(Func(self._clearToonTrack, toon))
        track.append(Func(toon.setAnimState, 'Happy', 1.0))
        self._storeToonTrack(toon, track)
        track.start()
Пример #19
0
    def enterShowScores(self):
        self.notify.debug('enterShowScores')
        lerpTrack = Parallel()
        lerpDur = 0.5
        lerpTrack.append(
            Parallel(
                LerpPosInterval(self.goalBar,
                                lerpDur,
                                Point3(0, 0, -.6),
                                blendType='easeInOut'),
                LerpScaleInterval(self.goalBar,
                                  lerpDur,
                                  Vec3(self.goalBar.getScale()) * 2.0,
                                  blendType='easeInOut')))
        tY = 0.6
        bY = -.05
        lX = -.5
        cX = 0
        rX = 0.5
        scorePanelLocs = (((cX, bY), ), ((lX, bY), (rX, bY)),
                          ((cX, tY), (lX, bY), (rX, bY)), ((lX, tY), (rX, tY),
                                                           (lX, bY), (rX, bY)))
        scorePanelLocs = scorePanelLocs[self.numPlayers - 1]
        for i in range(self.numPlayers):
            panel = self.scorePanels[i]
            pos = scorePanelLocs[i]
            panel.wrtReparentTo(aspect2d)
            lerpTrack.append(
                Parallel(
                    LerpPosInterval(panel,
                                    lerpDur,
                                    Point3(pos[0], 0, pos[1]),
                                    blendType='easeInOut'),
                    LerpScaleInterval(panel,
                                      lerpDur,
                                      Vec3(panel.getScale()) * 2.0,
                                      blendType='easeInOut')))

        self.showScoreTrack = Parallel(
            lerpTrack,
            Sequence(Wait(MazeGameGlobals.SHOWSCORES_DURATION),
                     Func(self.gameOver)))
        self.showScoreTrack.start()

        #For the Alpha Blueprint ARG
        if base.config.GetBool('want-blueprint4-ARG', False):
            MinigameGlobals.generateDebugARGPhrase()
Пример #20
0
    def loadIntervals(self):
        # create an interval that updates the ideal key press rate for each stage
        self.updateIdealRateInterval = Sequence()
        # other code handles setting the initial ideal rate, so only add the
        # wait for the first state
        self.updateIdealRateInterval.append(
            Wait(PartyGlobals.TugOfWarTargetRateList[0][0]), )
        # for each stage after the first
        for i in range(1, len(PartyGlobals.TugOfWarTargetRateList)):
            duration = PartyGlobals.TugOfWarTargetRateList[i][0]
            idealRate = PartyGlobals.TugOfWarTargetRateList[i][1]
            # set ideal speed
            self.updateIdealRateInterval.append(
                Func(self.setIdealRate, idealRate))
            # add delay for stage's length or set last stage flag
            if i == (len(PartyGlobals.TugOfWarTargetRateList) - 1):
                self.updateIdealRateInterval.append(
                    Func(setattr, self, "allOutMode", True))
            else:
                self.updateIdealRateInterval.append(Wait(duration), )
        # create an interval that updates the local player's key press rate
        self.updateKeyPressRateInterval = Sequence(
            Wait(PartyGlobals.TugOfWarKeyPressUpdateRate),
            Func(self.updateKeyPressRate),
        )
        # create an interval that updates the local player's force and tells the
        # server
        self.reportToServerInterval = Sequence(
            Wait(PartyGlobals.TugOfWarKeyPressReportRate),
            Func(self.reportToServer),
        )

        self.setupInterval = Parallel()
        # run this even if the local toon is not playing
        self.globalSetupInterval = Sequence(
            Wait(PartyGlobals.TugOfWarReadyDuration +
                 PartyGlobals.TugOfWarGoDuration),
            Func(self.tightenRopes),
        )
        # only run this when a local toon is playing
        self.localSetupInterval = Sequence(
            Func(self.setStatus, TTLocalizer.PartyTugOfWarReady),
            Func(self.showStatus),
            Wait(PartyGlobals.TugOfWarReadyDuration),
            Func(base.playSfx, self.whistleSound),
            Func(self.setStatus, TTLocalizer.PartyTugOfWarGo),
            Wait(PartyGlobals.TugOfWarGoDuration),
            Func(self.enableKeys),
            Func(self.hideStatus),
            Func(self.updateIdealRateInterval.start),
            Func(self.updateKeyPressRateInterval.loop),
            Func(self.reportToServerInterval.loop),
        )

        # interval for playing the splash sound and showing the splash visual effect
        self.splashInterval = Sequence(
            Func(base.playSfx, self.splashSound),
            Func(self.splash.play),
        )
Пример #21
0
 def playFireSequence(self):
     self.smokeNode.reparentTo(self.barrelNode)
     self.smokeNode.setPos(0, 6, -3)
     self.smokeNode.setScale(0.5)
     self.smokeNode.wrtReparentTo(render)
     track = Sequence(Parallel(LerpScaleInterval(self.smokeNode, 0.5, 3), LerpColorScaleInterval(self.smokeNode, 0.5, Vec4(2, 2, 2, 0))), Func(self.smokeNode.reparentTo, hidden), Func(self.smokeNode.clearColorScale))
     base.playSfx(self.sndCannonFire)
     track.start()
Пример #22
0
    def __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
        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()
        return
Пример #23
0
    def throwTeamInWater(self, losingTeam):
        self.notify.debug("throwTeamInWater( %s )" %PartyGlobals.TeamActivityTeams.getString(losingTeam))
        splashSet = False
        for toonId in self.toonIds[losingTeam]:
            # throw toon in water
            self.fallenToons.append(toonId)
            toon = self.getAvatar(toonId)
            # getting a a crash of popping from empty list
            #fallenPosIndex = self.unusedFallenPositionsIndices.pop(0)
            fallenPosIndex = self.toonIds[losingTeam].index(toonId)
            if (fallenPosIndex < 0) or (fallenPosIndex >= 4):
                fallenPosIndex = 0
            newPos = self.fallenPositions[fallenPosIndex]

            # animate the toons falling into the water
            if self.toonIdsToAnimIntervals[toonId] is not None:
                if self.toonIdsToAnimIntervals[toonId].isPlaying():
                    self.toonIdsToAnimIntervals[toonId].finish()

            # Fall into water
            if toon:
                parallel = Parallel(
                    ActorInterval(actor=toon, animName='slip-forward', duration=2.0),
                    LerpPosInterval(toon, duration=2.0, pos=newPos, other=self.root),
                    )
            else:
                self.notify.warning("toon %d is none, skipping slip-forward" % toonId)
                parallel = Parallel()

            # only setup splash for the first toon
            if not splashSet:
                splashSet = True
                parallel.append(self.splashInterval)

            if toon:
                self.toonIdsToAnimIntervals[toonId] = Sequence(
                    parallel,
                    Func(toon.loop, 'neutral'),
                    )
            else:
                self.notify.warning("toon %d is none, skipping toon.loop(neutral)" % toonId)
                self.toonIdsToAnimIntervals[toonId] = parallel
            self.toonIdsToAnimIntervals[toonId].start()
Пример #24
0
 def enterShowScores(self):
     self.notify.debug('enterShowScores')
     lerpTrack = Parallel()
     lerpDur = 0.5
     lerpTrack.append(Parallel(LerpPosInterval(self.goalBar, lerpDur, Point3(0, 0, -0.59999999999999998), blendType = 'easeInOut'), LerpScaleInterval(self.goalBar, lerpDur, Vec3(self.goalBar.getScale()) * 2.0, blendType = 'easeInOut')))
     tY = 0.59999999999999998
     bY = -0.050000000000000003
     lX = -0.5
     cX = 0
     rX = 0.5
     scorePanelLocs = (((cX, bY),), ((lX, bY), (rX, bY)), ((cX, tY), (lX, bY), (rX, bY)), ((lX, tY), (rX, tY), (lX, bY), (rX, bY)))
     scorePanelLocs = scorePanelLocs[self.numPlayers - 1]
     for i in xrange(self.numPlayers):
         panel = self.scorePanels[i]
         pos = scorePanelLocs[i]
         lerpTrack.append(Parallel(LerpPosInterval(panel, lerpDur, Point3(pos[0], 0, pos[1]), blendType = 'easeInOut'), LerpScaleInterval(panel, lerpDur, Vec3(panel.getScale()) * 2.0, blendType = 'easeInOut')))
     
     self.showScoreTrack = Parallel(lerpTrack, Sequence(Wait(MazeGameGlobals.SHOWSCORES_DURATION), Func(self.gameOver)))
     self.showScoreTrack.start()
Пример #25
0
    def throwTeamInWater(self, losingTeam):
        self.notify.debug('throwTeamInWater( %s )' %
                          PartyGlobals.TeamActivityTeams.getString(losingTeam))
        splashSet = False
        for toonId in self.toonIds[losingTeam]:
            self.fallenToons.append(toonId)
            toon = self.getAvatar(toonId)
            fallenPosIndex = self.toonIds[losingTeam].index(toonId)
            if fallenPosIndex < 0 or fallenPosIndex >= 4:
                fallenPosIndex = 0
            newPos = self.fallenPositions[fallenPosIndex]
            if self.toonIdsToAnimIntervals.has_key(
                    toonId
            ) and self.toonIdsToAnimIntervals[toonId] is not None:
                if self.toonIdsToAnimIntervals[toonId].isPlaying():
                    self.toonIdsToAnimIntervals[toonId].finish()
            if toon:
                parallel = Parallel(
                    ActorInterval(actor=toon,
                                  animName='slip-forward',
                                  duration=2.0),
                    LerpPosInterval(toon,
                                    duration=2.0,
                                    pos=newPos,
                                    other=self.root))
            else:
                self.notify.warning('toon %d is none, skipping slip-forward' %
                                    toonId)
                parallel = Parallel()
            if not splashSet:
                splashSet = True
                parallel.append(self.splashInterval)
            if toon:
                self.toonIdsToAnimIntervals[toonId] = Sequence(
                    parallel, Func(toon.loop, 'neutral'))
            else:
                self.notify.warning(
                    'toon %d is none, skipping toon.loop(neutral)' % toonId)
                self.toonIdsToAnimIntervals[toonId] = parallel
            self.toonIdsToAnimIntervals[toonId].start()

        return
Пример #26
0
    def load(self):
        CogdoGameMovie.load(self)
        self.toonDNA = ToonDNA.ToonDNA()
        self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14)
        self.toonHead = Toon.Toon()
        self.toonHead.setDNA(self.toonDNA)
        self.makeSuit('sc')
        self.toonHead.getGeomNode().setDepthWrite(1)
        self.toonHead.getGeomNode().setDepthTest(1)
        self.toonHead.loop('neutral')
        self.toonHead.setPosHprScale(-0.73, 0, -1.27, 180, 0, 0, 0.18, 0.18, 0.18)
        self.toonHead.reparentTo(hidden)
        self.toonHead.startBlink()
        self.cogHead = Suit.Suit()
        self.cogDNA = SuitDNA.SuitDNA()
        self.cogDNA.newSuit('le')
        self.cogHead.setDNA(self.cogDNA)
        self.cogHead.getGeomNode().setDepthWrite(1)
        self.cogHead.getGeomNode().setDepthTest(1)
        self.cogHead.loop('neutral')
        self.cogHead.setPosHprScale(-0.74, 0, -1.79, 180, 0, 0, 0.12, 0.14, 0.14)
        self.cogHead.reparentTo(hidden)
        self.clipPlane = self.toonHead.attachNewNode(PlaneNode('clip'))
        self.clipPlane.node().setPlane(Plane(0, 0, 1, 0))
        self.clipPlane.setPos(0, 0, 2.45)
        audioMgr = base.cogdoGameAudioMgr
        self._cogDialogueSfx = audioMgr.createSfx('cogDialogue')
        self._toonDialogueSfx = audioMgr.createSfx('toonDialogue')

        def start():
            camera.wrtReparentTo(render)
            self._startUpdateTask()

        def end():
            self._stopUpdateTask()

        introDuration = Globals.Gameplay.IntroDurationSeconds
        dialogue = TTLocalizer.CogdoFlyingIntroMovieDialogue
        waitDur = introDuration / len(dialogue)
        flyDur = introDuration - waitDur * 0.5
        flyThroughIval = Parallel(camera.posInterval(flyDur, self._exit.getPos(render) + Point3(0, -22, 1), blendType='easeInOut'), camera.hprInterval(flyDur, Point3(0, 5, 0), blendType='easeInOut'))
        self._ival = Sequence(Func(start), Parallel(flyThroughIval, Sequence(Func(self.displayLine, 'cog', self._getRandomLine(dialogue[0])), Wait(waitDur), Func(self.displayLine, 'toon', self._getRandomLine(dialogue[1])), Wait(waitDur), Func(self.displayLine, 'cog', self._getRandomLine(dialogue[2])), Wait(waitDur))), Func(end))
Пример #27
0
    def pieThrow(self, avId, timestamp, heading, pos, power):
        """Show local or remote toon throwing a pie."""

        toon = self.activity.getAvatar(avId)

        if toon is None:
            return

        tossTrack, pieTrack, flyPie = self.getTossPieInterval(
            toon, pos[0], pos[1], pos[2], heading, 0, 0, power)

        if avId == base.localAvatar.doId:
            flyPie.setTag('throwerId', str(avId))

            collSphere = CollisionSphere(0, 0, 0, 0.5)
            # Make the sphere intangible
            collSphere.setTangible(0)
            name = "PieSphere-%d" % avId
            collSphereName = self.activity.uniqueName(name)
            collNode = CollisionNode(collSphereName)
            collNode.setFromCollideMask(ToontownGlobals.PieBitmask)
            collNode.addSolid(collSphere)
            collNP = flyPie.attachNewNode(collNode)

            base.cTrav.addCollider(collNP, self.pieHandler)

            self.toonPieEventNames[collNP] = 'pieHit-' + collSphereName
            self.accept(self.toonPieEventNames[collNP],
                        self.handlePieCollision)
        else:
            player = self.players.get(avId)
            if player is not None:
                player.faceForward()

        def matchRunningAnim(toon=toon):
            toon.playingAnim = None
            toon.setSpeed(toon.forwardSpeed, toon.rotateSpeed)

        newTossTrack = Sequence(tossTrack, Func(matchRunningAnim))

        pieTrack = Parallel(newTossTrack,
                            pieTrack,
                            name="PartyCogActivity.pieTrack-%d-%s" %
                            (avId, timestamp))

        elapsedTime = globalClockDelta.localElapsedTime(timestamp)

        if elapsedTime < 16. / 24.:
            elapsedTime = 16. / 24.  # make the pie fly immediately

        pieTrack.start(elapsedTime)

        self.pieIvals.append(pieTrack)
        self.toonPieTracks[avId] = pieTrack
Пример #28
0
 def showNumber(self):
     self.setHit(False)
     self._bossIconX.show()
     ToontownIntervals.cleanup('boss_code%i' % self._id)
     ToontownIntervals.start(
         Sequence(Parallel(
             ToontownIntervals.getPresentGuiIval(self._bossIcon,
                                                 '',
                                                 startPos=(0, 0, -0.15))),
                  Wait(1.0),
                  ToontownIntervals.getPulseLargerIval(self._bg, ''),
                  name='boss_code%i' % self._id))
 def load(self):
     DistributedPartyActivity.load(self)
     self.danceFloor = loader.loadModel(self.model)
     self.danceFloor.reparentTo(self.getParentNodePath())
     self.danceFloor.setPos(self.x, self.y, 0.0)
     self.danceFloor.setH(self.h)
     self.danceFloor.wrtReparentTo(render)
     self.sign.setPos(22, -22, 0)
     floor = self.danceFloor.find('**/danceFloor_mesh')
     self.danceFloorSequence = Sequence(Wait(0.29999999999999999), Func(floor.setH, floor, 36))
     discoBall = self.danceFloor.find('**/discoBall_mesh')
     self.discoBallSequence = Parallel(discoBall.hprInterval(6.0, Vec3(360, 0, 0)), Sequence(discoBall.posInterval(3, Point3(0, 0, 1), blendType = 'easeInOut'), discoBall.posInterval(3, Point3(0, 0, 0), blendType = 'easeInOut')))
Пример #30
0
 def letterboxOff(self, t = 0.25, finishIval = None):
     self.noLetterbox()
     self.loadLetterbox()
     self.letterbox.unstash()
     if t == 0:
         self.letterbox.stash()
     else:
         self.letterboxIval = Sequence(Parallel(LerpPosInterval(self.letterboxBottom, t, pos = Vec3(0, 0, -1.2)), LerpPosInterval(self.letterboxTop, t, pos = Vec3(0, 0, 1))), Func(self.letterbox.stash), Func(messenger.send, 'letterboxOff'), name = self.letterboxTaskName)
         if finishIval:
             self.letterboxIval.append(finishIval)
         
         self.letterboxIval.start()