Пример #1
0
    def exitDoorEnterClosing(self, ts):
        assert(self.debugPrint("exitDoorEnterClosing()"))
        # Start animation:

        bldgActor = self.getBuildingActor()
        leftDoor = bldgActor.controlJoint(None, "modelRoot", "def_left_door")

        #if ZoneUtil.isInterior(self.zoneId):
        #    doorFrameHoleLeft.setColor(1., 1., 1., 1.)
        # Left door:
        if self.leftSwing:
            h = -100
        else:
            h = 100

        if (not leftDoor.isEmpty()):
            # Close the door:
            otherNP=self.getDoorNodePath()
            trackName = "doorExitTrack-%d" % (self.doId)
            self.finishDoorExitTrack()
            self.doorExitTrack = Sequence(
                    LerpHprInterval(
                        nodePath=leftDoor,
                        duration=1.0,
                        hpr=VBase3(0, 0, 0),
                        startHpr=VBase3(h, 0, 0),
                        #other=otherNP,
                        blendType="easeInOut"),
                    #Func(doorFrameHoleLeft.hide),
                    #Func(self.hideIfHasFlat, leftDoor),
                    SoundInterval(self.closeSfx, node=leftDoor),
                    name = trackName)
            self.doorExitTrack.start(ts)
Пример #2
0
 def exitDoorEnterOpening(self, ts):
     assert(self.debugPrint("exitDoorEnterOpening()"))
     bldgActor = self.getBuildingActor()
     leftDoor = bldgActor.controlJoint(None, "modelRoot", "def_left_door")
     if self.leftSwing:
         h = -100
     else:
         h = 100
     if (not leftDoor.isEmpty()):
         # Open the door:
         otherNP=self.getDoorNodePath()
         trackName = "doorDoorExitTrack-%d" % (self.doId)
         self.finishDoorExitTrack()
         self.doorExitTrack = Parallel(
             SoundInterval(self.openSfx, node=leftDoor),
             Sequence(
                 #Func(leftDoor.show),
                 #Func(doorFrameHoleLeft.show),
                 LerpHprInterval(nodePath=leftDoor,
                                 duration=0.6,
                                 hpr=VBase3(h, 0, 0),
                                 startHpr=VBase3(0, 0, 0),
                                 #other=otherNP,
                                 blendType="easeInOut")),
             name = trackName)
         # Start the tracks:
         self.doorExitTrack.start(ts)
     else:
         self.notify.warning("exitDoorEnterOpening(): did not find leftDoor")
Пример #3
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),
        )
Пример #4
0
    def enterClosing(self, ts):
        assert(self.debugPrint("enterClosing()"))
        # Right door:
        bldgActor = self.getBuildingActor()
        rightDoor = bldgActor.controlJoint(None, "modelRoot", "def_right_door")
        if (rightDoor.isEmpty()):
            self.notify.warning("enterClosing(): did not find rightDoor")
            return

        # Close the door:
        otherNP=self.getDoorNodePath()
        trackName = "doorClose-%d" % (self.doId)
        if self.rightSwing:
            h = 100
        else:
            h = -100
        # Stop animation:
        self.finishDoorTrack()
        self.doorTrack=Sequence(
                LerpHprInterval(
                    nodePath=rightDoor,
                    duration=1.0,
                    hpr=VBase3(0, 0, 0),
                    startHpr=VBase3(h, 0, 0),
                    #other=otherNP,
                    blendType="easeInOut"),
                #Func(doorFrameHoleRight.hide),
                #Func(self.hideIfHasFlat, rightDoor),
                SoundInterval(self.closeSfx, node=rightDoor),
                name = trackName)
        self.doorTrack.start(ts)
        if hasattr(self, "done"):
            request = self.getRequestStatus()
            messenger.send("doorDoneEvent", [request])
Пример #5
0
    def handleToonExited(self, toonId):
        DistributedPartyTeamActivity.handleToonExited(self, toonId)

        # clean up local toon stuff
        if toonId == base.localAvatar.doId:
            self.cameraMoveIval.pause()

            # make toon jump off the dock if needed
            if toonId not in self.fallenToons:
                # finish any existing interval for that toon
                if toonId in self.toonIdsToAnimIntervals and \
                   self.toonIdsToAnimIntervals[toonId] is not None:
                    self.toonIdsToAnimIntervals[toonId].finish()
                toon = self.getAvatar(toonId)
                # clamp targetHeading to minimize spin
                targetH = fitDestAngle2Src(toon.getH(self.root), 180.0)
                targetPos = self.hopOffPositions[self.getTeam(toonId)][self.getIndex(toonId, self.getTeam(toonId))]
                hopOffAnim = Sequence(
                    Func( toon.startPosHprBroadcast, 0.1 ),
                    toon.hprInterval( 0.2, VBase3( targetH, 0.0, 0.0 ), other=self.root ),
                    Func( toon.b_setAnimState, "jump", 1.0 ),
                    Wait( 0.4 ),
                    PartyUtils.arcPosInterval( 0.75, toon, targetPos, 5.0, self.root ),
                    Func( toon.stopPosHprBroadcast ),
                    # make sure toon ends up on the ground on remote clients
                    Func( toon.sendCurrentPosition ),
                    Func( self.hopOffFinished, toonId ),
                )
                self.toonIdsToAnimIntervals[toonId] = hopOffAnim
                self._hopOffFinishedSV.set(False)
                self.toonIdsToAnimIntervals[toonId].start()
            # local toons not on the dock are put back into the walk state
            else:
                self._hopOffFinishedSV.set(True)
                del self.toonIdsToAnimIntervals[toonId]
 def setCameraOffset(self, radAngle, distance):
     self.camera.setPos(VBase3(
             0,
             -math.cos(radAngle) * distance,
             math.sin(radAngle) * distance
             ))
     self.camera.lookAt(self.toon)
Пример #7
0
 def setupJellyBeans(self):
     self.beanAnims = []
     self.beansToCollect = []
     self.beanDetails = []
     self.numBeansCollected = 0
     for i in range(self.numJellyBeans):
         bean = self.beans[i]
         guiBean = self.guiBeans[i]
         height = self.jellyBeanPositions[i]
         color = random.choice(self.jellyBeanColors)
         bean.find("**/jellybean").setColor(color)
         if self.toon.doId == base.localAvatar.doId:
             bean.setAlphaScale(1.0)
         else:
             bean.setAlphaScale(0.5)
         guiBean.setColor(color)
         bean.setZ(height + self.toon.getHeight() + self.beanOffset)
         guiBean.setZ(height * self.indicatorFactor + self.guiBeanOffset)
         bean.setH(0.0)
         bean.unstash()
         guiBean.unstash()
         beanAnim = bean.hprInterval(
             1.5, VBase3((((i % 2) * 2) - 1) * 360.0, 0.0, 0.0)
         )  # the (((i % 2)*2) - 1) makes adjacent beans spin opposite directions
         beanAnim.loop()
         self.beanAnims.append(beanAnim)
         self.beanDetails.append((height, bean, guiBean, beanAnim))
     self.beansToCollect = list(range(self.numJellyBeans))
    def __init__(self, player, cam, root):
        self.player = player
        self.toon = player.toon
        self.camera = cam
        self.root = root

        self.camOffset = VBase3(0, -12, 5)
        self.cameraManager = FlyingCamera(self.camera)
        self.cameraManager.vecRate = Vec3(3.0, 2.0, 1.8)
        self.cameraManager.otherNP = self.root
Пример #9
0
    def enterOpening(self, ts):
        #if( __debug__ ):
        #    import pdb
        #    pdb.set_trace()
        assert(self.debugPrint("enterOpening()"))

        # Right door:
        bldgActor = self.getBuildingActor()
        rightDoor = bldgActor.controlJoint(None, "modelRoot", "def_right_door")
        if (rightDoor.isEmpty()):
            self.notify.warning("enterOpening(): did not find rightDoor")
            return
        # Open the door:
        otherNP=self.getDoorNodePath()
        trackName = "doorOpen-%d" % (self.doId)
        if self.rightSwing:
            h = 100
        else:
            h = -100
        # Stop animation:
        self.finishDoorTrack()
        self.doorTrack=Parallel(
            SoundInterval(self.openSfx, node=rightDoor),
            Sequence(
                HprInterval(
                    rightDoor,
                    VBase3(0, 0, 0),
                    #other=otherNP,
                    ),
                Wait(0.4),
                #Func(rightDoor.show),
                #Func(doorFrameHoleRight.show),
                LerpHprInterval(
                    nodePath=rightDoor,
                    duration=0.6,
                    hpr=VBase3(h, 0, 0),
                    startHpr=VBase3(0, 0, 0),
                    #other=otherNP,
                    blendType="easeInOut")),
            name = trackName)
        # Start the tracks:
        self.doorTrack.start(ts)
    def handleToonJoined(self, toonId):
        DistributedPartyTeamActivity.handleToonJoined(self, toonId)

        self.toonIdsToAnimIntervals[toonId] = None

        if toonId == base.localAvatar.doId:
            base.cr.playGame.getPlace().fsm.request("activity")

            # set camera to a 3rd person view of play area
            camera.wrtReparentTo(self.root)
            self.cameraMoveIval = LerpPosHprInterval(
                camera,
                1.5,
                PartyGlobals.TugOfWarCameraPos,
                PartyGlobals.TugOfWarCameraInitialHpr,
                other=self.root,
            )
            self.cameraMoveIval.start()

            self.localToonPosIndex = self.getIndex(base.localAvatar.doId,
                                                   self.localToonTeam)
            self.notify.debug("posIndex: %d" % self.localToonPosIndex)

            toon = self.getAvatar(toonId)
            targetPos = self.dockPositions[self.localToonTeam][
                self.localToonPosIndex]
            # prevent toons from clipping through the dock by warping them to dock height
            if toon.getZ(self.root) < PartyGlobals.TugOfWarToonPositionZ:
                toon.setZ(self.root, PartyGlobals.TugOfWarToonPositionZ)
            targetH = fitDestAngle2Src(
                toon.getH(self.root),
                PartyGlobals.TugOfWarHeadings[self.localToonTeam])
            travelVector = targetPos - toon.getPos(self.root)
            duration = travelVector.length() / 5.0
            if self.toonIdsToAnimIntervals[toonId] is not None:
                self.toonIdsToAnimIntervals[toonId].finish()
            self.toonIdsToAnimIntervals[toonId] = Sequence(
                Func(toon.startPosHprBroadcast, 0.1),
                Func(toon.b_setAnimState, "run"),
                LerpPosHprInterval(toon,
                                   duration,
                                   targetPos,
                                   VBase3(targetH, 0.0, 0.0),
                                   other=self.root),
                Func(toon.stopPosHprBroadcast),
                Func(toon.b_setAnimState, "neutral"),
            )
            self.toonIdsToAnimIntervals[toonId].start()
Пример #11
0
    def releaseToon( self ):
        self._hideFlashMessage()

        self.ignore( "arrow_left" )
        self.ignore( "arrow_left-up" )
        self.ignore( "arrow_right" )
        self.ignore( "arrow_right-up" )

        taskMgr.remove(self.uniqueName("TrampolineActivity.updateTask"))
        self.hopOffAnim = Sequence( self.toon.hprInterval( 0.5, VBase3( -90.0, 0.0, 0.0 ), other=self.tramp ),
                                    Func( self.toon.b_setAnimState, "jump", 1.0 ),
                                    Func( self.toon.dropShadow.reparentTo, hidden ),
                                    Wait( 0.4 ),
                                    PartyUtils.arcPosInterval( 0.75, self.toon, self.hopOffPos, 5.0, self.tramp ),
                                    Func( self.postHopOff ), )
        self.hopOffAnim.start()
Пример #12
0
    def startAnimation(self):
        """
        Make the Safezone Treasures animate if there is an animation associated.
        Currently, only the Valentine's Day Hearts animate.
        """
        holidayIds = base.cr.newsManager.getHolidayIdList()
        if ToontownGlobals.VALENTINES_DAY in holidayIds:
            # Animate the Valentine's Day Hearts here.
            originalScale = self.nodePath.getScale()
            throbScale = VBase3(0.85, 0.85, 0.85)
            throbInIval = LerpScaleInterval(self.nodePath,
                                            0.3,
                                            scale=throbScale,
                                            startScale=originalScale,
                                            blendType='easeIn')
            throbOutIval = LerpScaleInterval(self.nodePath,
                                             0.3,
                                             scale=originalScale,
                                             startScale=throbScale,
                                             blendType='easeOut')

            self.heartThrobIval = Sequence(throbInIval, throbOutIval,
                                           Wait(0.75))
            self.heartThrobIval.loop()
    def load(self):
        """
        We're now loading the assets from phase 3.5.
        """
        btnGui = loader.loadModel(
            'phase_3.5/models/gui/tt_m_gui_ign_newsBtnGui')
        self.openNewNewsUp = btnGui.find('**/tt_t_gui_ign_new')
        self.openNewNewsUpBlink = btnGui.find('**/tt_t_gui_ign_newBlink')
        self.openNewNewsHover = btnGui.find('**/tt_t_gui_ign_newHover')
        self.openOldNewsUp = btnGui.find('**/tt_t_gui_ign_oldNews')
        self.openOldNewsHover = btnGui.find('**/tt_t_gui_ign_oldHover')
        self.closeNewsUp = btnGui.find('**/tt_t_gui_ign_open')
        self.closeNewsHover = btnGui.find('**/tt_t_gui_ign_closeHover')
        btnGui.removeNode()

        oldScale = 0.5
        newScale = 0.9
        newPos = VBase3(0.914, 0, 0.862)
        textScale = 0.06
        self.gotoNewsButton = DirectButton(
            relief=None,
            image=(self.openOldNewsUp, self.openOldNewsHover,
                   self.openOldNewsHover),
            text=('', TTLocalizer.EventsPageNewsTabName,
                  TTLocalizer.EventsPageNewsTabName
                  ),  # TODO replace this with a symbol
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            text_scale=textScale,
            text_font=ToontownGlobals.getInterfaceFont(),
            pos=newPos,
            scale=newScale,
            command=self.__handleGotoNewsButton,
        )

        self.newIssueButton = DirectButton(
            relief=None,
            image=(self.openNewNewsUp, self.openNewNewsHover,
                   self.openNewNewsHover),
            text=('', TTLocalizer.EventsPageNewsTabName,
                  TTLocalizer.EventsPageNewsTabName
                  ),  # TODO replace this with a symbol
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            text_scale=textScale,
            text_font=ToontownGlobals.getInterfaceFont(),
            pos=newPos,
            scale=newScale,
            command=self.__handleGotoNewsButton,
        )

        self.gotoPrevPageButton = DirectButton(
            relief=None,
            image=(self.closeNewsUp, self.closeNewsHover, self.closeNewsHover),
            text=('', TTLocalizer.lClose, TTLocalizer.lClose
                  ),  #"goto prev page", # TODO replace this with a synmbol
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            text_scale=textScale,
            text_font=ToontownGlobals.getInterfaceFont(),
            pos=newPos,
            scale=newScale,
            command=self.__handleGotoPrevPageButton,
        )

        self.goto3dWorldButton = DirectButton(
            relief=None,
            image=(self.closeNewsUp, self.closeNewsHover, self.closeNewsHover),
            text=('', TTLocalizer.lClose, TTLocalizer.lClose
                  ),  # "goto 3d world", # TODO replace this with a symbol
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            text_scale=textScale,
            text_font=ToontownGlobals.getInterfaceFont(),
            pos=newPos,
            scale=newScale,
            command=self.__handleGoto3dWorldButton,
        )

        self.newIssueButton.hide()
        self.gotoNewsButton.hide()
        self.gotoPrevPageButton.hide()
        self.goto3dWorldButton.hide()

        self.accept('newIssueOut', self.handleNewIssueOut)

        bounce1Pos = VBase3(newPos.getX(), newPos.getY(),
                            newPos.getZ() + 0.022)  # (0.914, 0, 0.902)
        bounce2Pos = VBase3(newPos.getX(), newPos.getY(),
                            newPos.getZ() + 0.015)  # (0.914, 0, 0.895)

        bounceIval = Sequence(
            LerpPosInterval(self.newIssueButton,
                            0.1,
                            bounce1Pos,
                            blendType='easeOut'),
            LerpPosInterval(self.newIssueButton,
                            0.1,
                            newPos,
                            blendType='easeIn'),
            LerpPosInterval(self.newIssueButton,
                            0.07,
                            bounce2Pos,
                            blendType='easeOut'),
            LerpPosInterval(self.newIssueButton,
                            0.07,
                            newPos,
                            blendType='easeIn'))

        self.__blinkIval = Sequence(
            Func(self.__showOpenEyes),
            Wait(2),
            bounceIval,
            Wait(0.5),
            Func(self.__showClosedEyes),
            Wait(0.1),
            Func(self.__showOpenEyes),
            Wait(0.1),
            Func(self.__showClosedEyes),
            Wait(0.1),
        )

        # Start it looping, but pause it, so we can resume/pause it to
        # start/stop the flashing.
        self.__blinkIval.loop()
        self.__blinkIval.pause()

        self.buttonsLoaded = True
Пример #14
0
"""Cog Thief Game Globals used by AI and client versions."""

from toontown.toonbase.ToontownModules import VBase3, BitMask32

GameTime = 60
NumBarrels = 4
BarrelStartingPositions = (
   VBase3(4.3, 4, 0),
   VBase3(4.3, -4, 0),
   VBase3(-4.3, 4, 0),
   VBase3(-4.3, -4, 0),
   )

ToonStartingPositions = (
   VBase3(0, 16, 0),
   VBase3(0, -16, 0),
   VBase3(-16, 0, 0),
   VBase3(16, 0, 0),
   )


# make sure the starting positions are off the screen
CogStartingPositions = (
   VBase3(35, 18, 0),
   VBase3(35, 0, 0),
   VBase3(35, -18, 0),
   VBase3(-35, 18, 0),
   VBase3(-35, 0, 0),
   VBase3(-35, -18, 0),
   VBase3(0, 27, 0),
   VBase3(0, -27, 0),
Пример #15
0
 def setScale(self, xy=1, z=1):
     self.maze.setScale(VBase3(xy, xy, z))
     self.cellWidth = self._initialCellWidth * xy
Пример #16
0
    def setScale(self, xy=1, z=1):
        self.maze.setScale(VBase3(xy, xy, z))

        self.cellWidth = MazeData.CELL_WIDTH * xy
Пример #17
0
    def showSuitsFalling(self, suits, ts, name, callback):
        assert (len(suits) > 0)

        if self.bossCog == None:
            # Hmm, no boss cog?  Maybe not generated yet.
            return

        suitTrack = Parallel()

        delay = 0
        for suit in suits:
            """
            This is done by the AI now.
            if self.battleNumber == 2:
                # Battle 2 features skelecogs only.
                suit.makeSkeleton()
                suit.corpMedallion.hide()
                suit.healthBar.show()
                """
            suit.makeWaiter()
            suit.setState('Battle')
            #RAU lawbot boss battle hack,
            if suit.dna.dept == 'l':
                suit.reparentTo(self.bossCog)
                suit.setPos(0, 0, 0)

            #suit.setScale(3.8 / suit.height)

            # Move all suits into position
            if suit in self.joiningSuits:
                i = len(self.pendingSuits) + self.joiningSuits.index(suit)
                destPos, h = self.suitPendingPoints[i]
                destHpr = VBase3(h, 0, 0)
            else:
                destPos, destHpr = self.getActorPosHpr(suit, self.suits)

            startPos = destPos + Point3(
                0, 0, (SuitTimings.fromSky * ToontownGlobals.SuitWalkSpeed))
            self.notify.debug('startPos for %s = %s' % (suit, startPos))
            suit.reparentTo(self)
            suit.setPos(startPos)
            suit.headsUp(self)

            flyIval = suit.beginSupaFlyMove(destPos, True, 'flyIn')
            suitTrack.append(
                Track(
                    #(delay, self.createAdjustInterval(suit, destPos, destHpr)),
                    (delay, Sequence(flyIval, Func(suit.loop, 'neutral')))))
            delay += 1

        if (self.hasLocalToon()):
            # Parent the camera to the battle and position it to watch the
            # suits join.
            camera.reparentTo(self)

            # Choose either a left or a right view at random.
            if random.choice([0, 1]):
                camera.setPosHpr(20, -4, 7, 60, 0, 0)
            else:
                camera.setPosHpr(-20, -4, 7, -60, 0, 0)

        done = Func(callback)
        track = Sequence(suitTrack, done, name=name)
        track.start(ts)
        self.storeInterval(track, name)
Пример #18
0
    def showSuitsFalling(self, suits, ts, name, callback):
        assert (len(suits) > 0)

        if self.bossCog == None:
            # Hmm, no boss cog?  Maybe not generated yet.
            return

        suitTrack = Parallel()

        delay = 0
        for suit in suits:
            """
            This is done by the AI now.
            if self.battleNumber == 2:
                # Battle 2 features skelecogs only.
                suit.makeSkeleton()
                suit.corpMedallion.hide()
                suit.healthBar.show()
                """

            suit.setState('Battle')
            #RAU lawbot boss battle hack,
            if suit.dna.dept == 'l':
                suit.reparentTo(self.bossCog)
                suit.setPos(0, 0, 0)

            #suit.setScale(3.8 / suit.height)

            # Move all suits into position
            if suit in self.joiningSuits:
                i = len(self.pendingSuits) + self.joiningSuits.index(suit)
                destPos, h = self.suitPendingPoints[i]
                destHpr = VBase3(h, 0, 0)
            else:
                destPos, destHpr = self.getActorPosHpr(suit, self.suits)

            startPos = destPos + Point3(
                0, 0, (SuitTimings.fromSky * ToontownGlobals.SuitWalkSpeed))
            self.notify.debug('startPos for %s = %s' % (suit, startPos))
            suit.reparentTo(self)
            suit.setPos(startPos)
            suit.headsUp(self)

            moveIval = Sequence()
            chairInfo = self.bossCog.claimOneChair()
            if chairInfo:
                moveIval = self.createDinerMoveIval(suit, destPos, chairInfo)

            suitTrack.append(
                Track((delay, Sequence(moveIval, Func(suit.loop, 'neutral')))))
            delay += 1

        if (self.hasLocalToon()):
            # Parent the camera to the battle and position it to watch the
            # suits join.
            camera.reparentTo(self)

            # Choose a back angle to see the diners flying to their battle position
            self.notify.debug('self.battleSide =%s' % self.battleSide)
            camHeading = -20
            camX = -4
            if self.battleSide == 0:
                camHeading = 20
                camX = 4
            camera.setPosHpr(camX, -15, 7, camHeading, 0, 0)

        done = Func(callback)
        track = Sequence(suitTrack, done, name=name)
        track.start(ts)
        self.storeInterval(track, name)