def __init__(self, factory):
        self.factory = factory
        av = base.localAvatar
        self.currentCamPos = None
        self.views = [['signatureRoomView', (Point3(0.0, -14.8419799805, 13.212685585),
           Point3(0.0, -13.9563484192, 12.749215126),
           Point3(0.0, 1.5, 15.75),
           Point3(0.0, 1.5, -3.9375),
           1), ['localToonLeftBattle']], ['lookoutTrigger', (Point3(0, -17.7, 28.8),
           Point3(0, 10, 0),
           Point3(0.0, 1.5, 15.75),
           Point3(0.0, 1.5, -3.9375),
           1), []], ['moleFieldView', (Point3(0, -17.7, 28.8),
           Point3(0, 10, 0),
           Point3(0.0, 1.5, 15.75),
           Point3(0.0, 1.5, -3.9375),
           1), []]]
        camHeight = av.getClampedAvatarHeight()
        for i in range(len(self.views)):
            camPos = self.views[i][1]
            av.auxCameraPositions.append(camPos)
            factory.accept('enter' + self.views[i][0], Functor(self.switchCamPos, i))
            for msg in self.views[i][2]:
                factory.accept(msg, self.checkCamPos)

        return
Exemple #2
0
    def dropTask(self, task):
        self._scheduleGenerations()
        curT = self.getCurrentCatchActivityTime()
        if self._orderedGenerationIndex is not None:
            i = self._orderedGenerationIndex
            genIndex = self._orderedGenerations[i]
            gen = self._id2gen[genIndex]
            while len(gen.dropSchedule) > 0 and gen.dropSchedule[0][0] < curT:
                drop = gen.dropSchedule[0]
                gen.dropSchedule = gen.dropSchedule[1:]
                dropTime, objName, dropCoords = drop
                objNum = gen.numItemsDropped
                x, y = self.grid2world(*dropCoords)
                dropIval = self.getDropIval(x, y, objName, genIndex, objNum)

                def cleanup(generation, objNum, self=self):
                    del self.dropIntervals[generation, objNum]

                dropIval.append(Func(Functor(cleanup, genIndex, objNum)))
                self.dropIntervals[genIndex, objNum] = dropIval
                gen.numItemsDropped += 1
                dropIval.start(curT - dropTime)
                self._lastDropTime = dropTime

        return Task.cont
 def switchCamPos(self, viewIndex, colEntry = None):
     av = base.localAvatar
     prevView = av.cameraIndex
     self.currentCamPos = viewIndex
     av.accept('exit' + self.views[viewIndex][0], Functor(self.prevCamPos, prevView))
     self.notify.info('auto-switching to camera position %s' % viewIndex)
     av.setCameraSettings(self.views[viewIndex][1])
Exemple #4
0
 def enterInteract(self):
     PetGoal.notify.debug('enterInteract')
     if self._chaseAvInInteractMode():
         self.accept(
             self.brain.getObserveEventAttendingAvStop(self.avatar.doId),
             Functor(self.request, 'Chase'))
     self.startInteract()
 def __handleDelete(self, t_or_b):
     if t_or_b == ClosetGlobals.SHIRT:
         item = TTLocalizer.ClosetShirt
     elif self.toon.style.torso[1] == 'd':
         item = TTLocalizer.ClosetSkirt
     else:
         item = TTLocalizer.ClosetShorts
     self.verify = TTDialog.TTGlobalDialog(doneEvent='verifyDone', message=TTLocalizer.ClosetVerifyDelete % item, style=TTDialog.TwoChoice)
     self.verify.show()
     self.accept('verifyDone', Functor(self.__handleVerifyDelete, t_or_b))
     messenger.send('wakeup')
Exemple #6
0
 def __init__(self, level):
     EntityCreatorBase.EntityCreatorBase.__init__(self, level)
     cLE = createLocalEntity
     self.privRegisterTypes({
         'attribModifier': nothing,
         'ambientSound': nothing,
         'collisionSolid': nothing,
         'cutScene': nothing,
         'editMgr': Functor(cLE, EditMgrAI.EditMgrAI),
         'entityGroup': nothing,
         'entrancePoint': nothing,
         'levelMgr': Functor(cLE, LevelMgrAI.LevelMgrAI),
         'locator': nothing,
         'logicGate': Functor(cLE, LogicGate.LogicGate),
         'model': nothing,
         'nodepath': nothing,
         'path': nothing,
         'propSpinner': nothing,
         'visibilityExtender': nothing,
         'zone': Functor(cLE, ZoneEntityAI.ZoneEntityAI)
     })
Exemple #7
0
 def __init__(self, level):
     EntityCreatorAI.EntityCreatorAI.__init__(self, level)
     cDE = EntityCreatorAI.createDistributedEntity
     cLE = EntityCreatorAI.createLocalEntity
     nothing = EntityCreatorAI.nothing
     self.privRegisterTypes({
         'levelMgr': Functor(cLE, CogdoLevelMgrAI),
         'cogdoBoardroomGameSettings': Functor(cLE, Functor(self._createCogdoSettings, CogdoBoardroomGameConsts.Settings)),
         'cogdoCraneGameSettings': Functor(cLE, Functor(self._createCogdoSettings, CogdoCraneGameConsts.Settings)),
         'cogdoCraneCogSettings': Functor(cLE, Functor(self._createCogdoSettings, CogdoCraneGameConsts.CogSettings))})
    def handleEntitySelect(self, entity):
        self.selectedEntity = entity
        if hasattr(self, 'identifyIval'):
            self.identifyIval.finish()
        if entity is self:
            self.editor.clearAttribEditPane()
        else:
            entityNP = self.getEntInstanceNP(entity.entId)
            if entityNP is not None:
                dur = float(0.5)
                oColor = entityNP.getColorScale()
                flashIval = Sequence(Func(Functor(entityNP.setColorScale, 1, 0, 0, 1)), WaitInterval(dur / 3), Func(Functor(entityNP.setColorScale, 0, 1, 0, 1)), WaitInterval(dur / 3), Func(Functor(entityNP.setColorScale, 0, 0, 1, 1)), WaitInterval(dur / 3), Func(Functor(entityNP.setColorScale, oColor[0], oColor[1], oColor[2], oColor[3])))
                boundIval = Sequence(Func(entityNP.showBounds), WaitInterval(dur * 0.5), Func(entityNP.hideBounds))
                entCp = self.getEntInstanceNPCopy(entity.entId)
                entCp.setRenderModeWireframe()
                entCp.setTextureOff(1)
                wireIval = Sequence(Func(Functor(entCp.setColor, 1, 0, 0, 1, 1)), WaitInterval(dur / 3), Func(Functor(entCp.setColor, 0, 1, 0, 1, 1)), WaitInterval(dur / 3), Func(Functor(entCp.setColor, 0, 0, 1, 1, 1)), WaitInterval(dur / 3), Func(entCp.removeNode))
                self.identifyIval = Parallel(flashIval, boundIval, wireIval)

                def putAxis(self = self, entityNP = entityNP):
                    self.axis.reparentTo(entityNP)
                    self.axis.setPos(0, 0, 0)
                    self.axis.setHpr(0, 0, 0)

                def takeAxis(self = self):
                    self.axis.reparentTo(hidden)

                self.identifyIval = Sequence(Func(putAxis), Parallel(self.identifyIval, WaitInterval(1000.5)), Func(takeAxis))
                self.identifyIval.start()
            self.editor.updateAttribEditPane(entity.entId, self.levelSpec, self.entTypeReg)
            entType = self.getEntityType(entity.entId)
            menu = self.editor.menuBar.component('Entity-menu')
            index = menu.index('Remove Selected Entity')
            if entType in self.entTypeReg.getPermanentTypeNames():
                menu.entryconfigure(index, state='disabled')
            else:
                menu.entryconfigure(index, state='normal')
        return
Exemple #9
0
    def enterChase(self):
        PetGoal.notify.debug('enterChase')
        if self.brain.lookingAt(self.avatar.doId):

            def goToInteract(task=None, self=self):
                self.request('Interact')
                return Task.done

            taskMgr.doMethodLater(0.0001, goToInteract,
                                  self.transitionDoLaterName)
        else:
            self.accept(
                self.brain.getObserveEventAttendingAvStart(self.avatar.doId),
                Functor(self.request, 'Interact'))
            self.brain._chase(self.avatar)
        return
Exemple #10
0
 def __handleDelete(self, which):
     abortDeletion = False
     if which == ToonDNA.HAT:
         item = TTLocalizer.TrunkHat
     elif which == ToonDNA.GLASSES:
         item = TTLocalizer.TrunkGlasses
     elif which == ToonDNA.BACKPACK:
         item = TTLocalizer.TrunkBackpack
     else:
         item = TTLocalizer.TrunkShoes
     self.verify = TTDialog.TTGlobalDialog(
         doneEvent='verifyDone',
         message=TTLocalizer.ClosetVerifyDelete % item,
         style=TTDialog.TwoChoice)
     self.verify.show()
     self.accept('verifyDone', Functor(self.__handleVerifyDelete, which))
     messenger.send('wakeup')
Exemple #11
0
    def initializeLevel(self, levelSpec):
        self.startTime = globalClock.getRealTime()
        self.startTimestamp = globalClockDelta.localToNetworkTime(
            self.startTime, bits=32)
        lol = zip([1] * levelSpec.getNumScenarios(),
                  range(levelSpec.getNumScenarios()))
        scenarioIndex = weightedChoice(lol)
        Level.Level.initializeLevel(self, self.doId, levelSpec, scenarioIndex)
        if __dev__:
            self.accept(self.editMgrEntity.getSpecSaveEvent(), self.saveSpec)
        for avId in self.avIdList:
            self.acceptOnce(self.air.getAvatarExitEvent(avId),
                            Functor(self.handleAvatarDisconnect, avId))

        self.allToonsGoneBarrier = self.beginBarrier('allToonsGone',
                                                     self.avIdList,
                                                     3 * 24 * 60 * 60,
                                                     self.allToonsGone)
Exemple #12
0
    def enterPurchase(self):
        PurchaseBase.enterPurchase(self)
        self.convertingVotesToBeansLabel.hide()
        self.rewardDoubledJellybeanLabel.hide()
        self.bg.reparentTo(render)
        base.setBackgroundColor(0.05, 0.14, 0.4)
        self.accept('purchaseStateChange', self.__handleStateChange)
        self.playAgain.reparentTo(self.toon.inventory.purchaseFrame)
        self.backToPlayground.reparentTo(self.toon.inventory.purchaseFrame)
        self.pointDisplay.reparentTo(self.toon.inventory.purchaseFrame)
        self.statusLabel.reparentTo(self.toon.inventory.purchaseFrame)
        for headFrame in self.headFrames:
            headFrame[1].show()
            headFrame[1].reparentTo(self.toon.inventory.purchaseFrame)

        if base.cr.periodTimerExpired:
            base.cr.loginFSM.request('periodTimeout')
            return
        if not self.tutorialMode:
            if not config.GetBool('disable-purchase-timer', 0):
                self.timer.countdown(self.remain, self.__timerExpired)
            if config.GetBool('metagame-disable-playAgain', 0):
                if self.metagameRound > -1:
                    self.disablePlayAgain()
        else:
            self.timer.hide()
            self.disablePlayAgain()
            self.accept('disableGagPanel', Functor(self.toon.inventory.setActivateMode, 'gagTutDisabled', gagTutMode=1))
            self.accept('disableBackToPlayground', self.disableBackToPlayground)
            self.accept('enableGagPanel', self.handleEnableGagPanel)
            self.accept('enableBackToPlayground', self.enableBackToPlayground)
            for avId, headFrame in self.headFrames:
                if avId != self.newbieId:
                    headFrame.hide()

        messenger.send('gagScreenIsUp')
        if base.autoPlayAgain or self.doMetagamePlayAgain():
            base.transitions.fadeOut(0)
            self.__handlePlayAgain()
 def __init__(self, level):
     EntityCreatorAI.EntityCreatorAI.__init__(self, level)
     cDE = EntityCreatorAI.createDistributedEntity
     cLE = EntityCreatorAI.createLocalEntity
     nothing = EntityCreatorAI.nothing
     self.privRegisterTypes({'activeCell': Functor(cDE, ActiveCellAI.ActiveCellAI), 'crusherCell': Functor(cDE, CrusherCellAI.CrusherCellAI), 'battleBlocker': Functor(cDE, BattleBlockerAI.BattleBlockerAI), 'beanBarrel': Functor(cDE, DistributedBeanBarrelAI.DistributedBeanBarrelAI), 'button': DistributedButtonAI.DistributedButtonAI, 'conveyorBelt': nothing, 'crate': Functor(cDE, DistributedCrateAI.DistributedCrateAI), 'directionalCell': Functor(cDE, DirectionalCellAI.DirectionalCellAI), 'door': DistributedDoorEntityAI.DistributedDoorEntityAI, 'gagBarrel': Functor(cDE, DistributedGagBarrelAI.DistributedGagBarrelAI), 'gear': nothing, 'goon': Functor(cDE, DistributedGoonAI.DistributedGoonAI), 'gridGoon': Functor(cDE, DistributedGridGoonAI.DistributedGridGoonAI), 'golfGreenGame': Functor(cDE, DistributedGolfGreenGameAI.DistributedGolfGreenGameAI), 'goonClipPlane': nothing, 'grid': Functor(cDE, DistributedGridAI.DistributedGridAI), 'healBarrel': Functor(cDE, DistributedHealBarrelAI.DistributedHealBarrelAI), 'levelMgr': Functor(cLE, FactoryLevelMgrAI.FactoryLevelMgrAI), 'lift': Functor(cDE, DistributedLiftAI.DistributedLiftAI), 'mintProduct': nothing, 'mintProductPallet': nothing, 'mintShelf': nothing, 'mover': Functor(cDE, DistributedMoverAI.DistributedMoverAI), 'paintMixer': nothing, 'pathMaster': nothing, 'rendering': nothing, 'platform': nothing, 'sinkingPlatform': Functor(cDE, DistributedSinkingPlatformAI.DistributedSinkingPlatformAI), 'stomper': Functor(cDE, DistributedStomperAI.DistributedStomperAI), 'stomperPair': Functor(cDE, DistributedStomperPairAI.DistributedStomperPairAI), 'laserField': Functor(cDE, DistributedLaserFieldAI.DistributedLaserFieldAI), 'securityCamera': Functor(cDE, DistributedSecurityCameraAI.DistributedSecurityCameraAI), 'elevatorMarker': Functor(cDE, DistributedElevatorMarkerAI.DistributedElevatorMarkerAI), 'trigger': DistributedTriggerAI.DistributedTriggerAI, 'moleField': Functor(cDE, DistributedMoleFieldAI.DistributedMoleFieldAI), 'maze': Functor(cDE, DistributedMazeAI.DistributedMazeAI)})
Exemple #14
0
    def getDropIval(self, x, y, dropObjName, generation, num):
        objType = PartyGlobals.Name2DropObjectType[dropObjName]
        id = (generation, num)
        dropNode = hidden.attachNewNode('catchDropNode%s' % (id, ))
        dropNode.setPos(x, y, 0)
        shadow = self.dropShadow.copyTo(dropNode)
        shadow.setZ(PartyGlobals.CatchDropShadowHeight)
        shadow.setColor(1, 1, 1, 1)
        object = self.getObjModel(dropObjName)
        object.reparentTo(hidden)
        if dropObjName in ['watermelon', 'anvil']:
            objH = object.getH()
            absDelta = {'watermelon': 12, 'anvil': 15}[dropObjName]
            delta = (self.randomNumGen.random() * 2.0 - 1.0) * absDelta
            newH = objH + delta
        else:
            newH = self.randomNumGen.random() * 360.0
        object.setH(newH)
        sphereName = 'FallObj%s' % (id, )
        radius = self.ObjRadius
        if objType.good:
            radius *= lerp(1.0, 1.3, 0.5)
        collSphere = CollisionSphere(0, 0, 0, radius)
        collSphere.setTangible(0)
        collNode = CollisionNode(sphereName)
        collNode.setCollideMask(PartyGlobals.CatchActivityBitmask)
        collNode.addSolid(collSphere)
        collNodePath = object.attachNewNode(collNode)
        collNodePath.hide()
        if self.ShowObjSpheres:
            collNodePath.show()
        catchEventName = 'ltCatch' + sphereName

        def eatCollEntry(forward, collEntry):
            forward()

        self.accept(
            catchEventName,
            Functor(eatCollEntry, Functor(self.__handleCatch, id[0], id[1])))

        def cleanup(self=self, dropNode=dropNode, id=id, event=catchEventName):
            self.ignore(event)
            dropNode.removeNode()

        duration = objType.fallDuration
        onscreenDuration = objType.onscreenDuration
        targetShadowScale = 0.3
        if self.trickShadows:
            intermedScale = targetShadowScale * (self.OffscreenTime /
                                                 self.BaselineDropDuration)
            shadowScaleIval = Sequence(
                LerpScaleInterval(shadow,
                                  self.OffscreenTime,
                                  intermedScale,
                                  startScale=0))
            shadowScaleIval.append(
                LerpScaleInterval(shadow,
                                  duration - self.OffscreenTime,
                                  targetShadowScale,
                                  startScale=intermedScale))
        else:
            shadowScaleIval = LerpScaleInterval(shadow,
                                                duration,
                                                targetShadowScale,
                                                startScale=0)
        targetShadowAlpha = 0.4
        shadowAlphaIval = LerpColorScaleInterval(
            shadow,
            self.OffscreenTime,
            Point4(1, 1, 1, targetShadowAlpha),
            startColorScale=Point4(1, 1, 1, 0))
        shadowIval = Parallel(shadowScaleIval, shadowAlphaIval)
        if self.useGravity:

            def setObjPos(t, objType=objType, object=object):
                z = objType.trajectory.calcZ(t)
                object.setZ(z)

            setObjPos(0)
            dropIval = LerpFunctionInterval(setObjPos,
                                            fromData=0,
                                            toData=onscreenDuration,
                                            duration=onscreenDuration)
        else:
            startPos = Point3(0, 0, self.MinOffscreenHeight)
            object.setPos(startPos)
            dropIval = LerpPosInterval(object,
                                       onscreenDuration,
                                       Point3(0, 0, 0),
                                       startPos=startPos,
                                       blendType='easeIn')
        ival = Sequence(Func(Functor(dropNode.reparentTo, self.root)),
                        Parallel(
                            Sequence(
                                WaitInterval(self.OffscreenTime),
                                Func(Functor(object.reparentTo, dropNode)),
                                dropIval), shadowIval),
                        Func(cleanup),
                        name='drop%s' % (id, ))
        if objType == PartyGlobals.Name2DropObjectType['anvil']:
            ival.append(Func(self.playAnvil))
        return ival
 def handleZoneCreated(self, entId):
     zoneEnt = self.level.getEntity(entId)
     self.level.zoneNum2zoneId[zoneEnt.entId] = zoneEnt.getZoneId()
     self.privCreateSortedZoneIdList()
     self.accept(self.level.getEntityDestroyEvent(entId),
                 Functor(self.handleZoneDestroy, entId))
Exemple #16
0
 def handleZoneCreated(self, entId):
     zoneEnt = self.level.getEntity(entId)
     self.zoneNums.append(zoneEnt.entId)
     self.privAssignZoneIds()
     self.accept(self.level.getEntityDestroyEvent(entId),
                 Functor(self.handleZoneDestroy, entId))