def showExit(): self._setCamTarget(self._exit, 10, offset=Point3(0, 0, 0), angle=Point3(0, 60, 0)) self._exit.close() self._state = 2
def getToonPullingLeverInterval(self, toon): walkTime = 0.2 reach = ActorInterval(toon, 'leverReach', playRate=2.0) pull = ActorInterval(toon, 'leverPull', startFrame=6) origPos = toon.getPos(render) origHpr = toon.getHpr(render) newPos = self.lever.getPos(render) newHpr = self.lever.getHpr(render) origHpr.setX(PythonUtil.fitSrcAngle2Dest(origHpr[0], newHpr[0])) toon.setPosHpr(origPos, origHpr) reachAndPull = Sequence( ActorInterval(toon, 'walk', loop=True, duration=walkTime - reach.getDuration()), reach, pull) leverSeq = Sequence( Wait(walkTime + reach.getDuration() - 0.1), self.stick.hprInterval(0.55, Point3(0.0, 25.0, 0.0), Point3(0.0, 0.0, 0.0)), Wait(0.3), self.stick.hprInterval(0.4, Point3(0.0, 0.0, 0.0), Point3(0.0, 25.0, 0.0)), ) returnSeq = Sequence( Parallel( toon.posInterval(walkTime, newPos, origPos), toon.hprInterval(walkTime, newHpr, origHpr), leverSeq, reachAndPull, ), ) return returnSeq
def getDropIval(self): shadow = self.shadow drop = self.drop id = self.id hangTime = Globals.ShadowTime dropTime = Globals.DropTime dropHeight = Globals.DropHeight targetShadowScale = 0.5 targetShadowAlpha = 0.4 shadowScaleIval = LerpScaleInterval(shadow, dropTime, targetShadowScale, startScale=0) shadowAlphaIval = LerpColorScaleInterval(shadow, hangTime, Point4(1, 1, 1, targetShadowAlpha), startColorScale=Point4(1, 1, 1, 0)) shadowIval = Parallel(shadowScaleIval, shadowAlphaIval) startPos = Point3(0, 0, dropHeight) drop.setPos(startPos) dropIval = LerpPosInterval(drop, dropTime, Point3(0, 0, 0), startPos=startPos, blendType='easeIn') dropSoundIval = self._dropSfx dropSoundIval.node = self self.drop.setTransparency(1) def _setRandScale(t): self.drop.setScale(self, 1 - random.random() / 16, 1 - random.random() / 16, 1 - random.random() / 4) scaleChange = 0.4 + random.random() / 4 dropShakeSeq = Sequence(LerpScaleInterval(self.drop, 0.25, Vec3(1.0 + scaleChange, 1.0 + scaleChange / 2, 1.0 - scaleChange), blendType='easeInOut'), LerpScaleInterval(self.drop, 0.25, Vec3(1.0, 1.0, 1.0), blendType='easeInOut'), Func(self.disableCollisionDamage), LerpScaleInterval(self.drop, 0.2, Vec3(1.0 + scaleChange / 8, 1.0 + scaleChange / 8, 1.0 - scaleChange / 8), blendType='easeInOut'), LerpScaleInterval(self.drop, 0.2, Vec3(1.0, 1.0, 1.0), blendType='easeInOut'), LerpScaleInterval(self.drop, 0.15, Vec3(1.0 + scaleChange / 16, 1.0 + scaleChange / 16, 1.0 - scaleChange / 16), blendType='easeInOut'), LerpScaleInterval(self.drop, 0.15, Vec3(1.0, 1.0, 1.0), blendType='easeInOut'), LerpScaleInterval(self.drop, 0.1, Vec3(1.0 + scaleChange / 16, 1.0 + scaleChange / 8, 1.0 - scaleChange / 16), blendType='easeInOut'), LerpColorScaleInterval(self.drop, Globals.DropFadeTime, Vec4(1.0, 1.0, 1.0, 0.0))) ival = Sequence(Func(self.reparentTo, render), Parallel(Sequence(WaitInterval(hangTime), dropIval), shadowIval), Parallel(Func(self.game.dropHit, self, id), dropSoundIval, dropShakeSeq), Func(self.game.cleanupDrop, id), name='drop%s' % id) self.ival = ival return ival
def setFinalPosition(self, x, y, z): # Create an interval to lerp the treasure to its target # position. if not self.nodePath: self.makeNodePath() if self.treasureFlyTrack: self.treasureFlyTrack.finish() self.treasureFlyTrack = None startPos = None goon = self.cr.doId2do[self.goonId] if goon: startPos = goon.getPos() # We lerp the treasure model up-and-down, while we # simultaneously lerp the overall NodePath linearly, so the # shadow remains on the ground. lerpTime = 1 self.treasureFlyTrack = Sequence( Func(self.collNodePath.stash), Parallel( ProjectileInterval(self.treasure, startPos=Point3(0, 0, 0), endPos=Point3(0, 0, 0), duration=lerpTime, gravityMult=2.0), LerpPosInterval(self.nodePath, lerpTime, Point3(x, y, z), startPos=startPos)), Func(self.collNodePath.unstash)) self.treasureFlyTrack.start()
def showBoss(): self._setCamTarget(bossSuit, 20, offset=Point3(0, 0, 7), angle=Point3(0, 15, 0)) bossSuit.loop('victory') self._state = 1
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))
def enterDown(self): if self.oldState == "Off": self.actor.pose("down", self.actor.getNumFrames("down") - 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()
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()
def _setCamTarget(self, targetNP, distance, offset = Point3(0, 0, 0), angle = Point3(0, 0, 0)): camera.wrtReparentTo(render) self._camTarget = targetNP self._camOffset = offset self._camAngle = angle self._camDistance = distance self._camHelperNode.setPos(self._camTarget, self._camOffset) self._camHelperNode.setHpr(self._camTarget, 180 + self._camAngle[0], self._camAngle[1], self._camAngle[2]) self._camHelperNode.setPos(self._camHelperNode, 0, self._camDistance, 0)
def enterProcessEndingPositions(self): """We've received the final positions from each client, arbitrate.""" # TODO the ending positions should be very close to each other # The total number of physics steps taken tends to be +- 3 # of the others # TODO detect if someone is wildly divergent from the others # TODO detect if someone is dead center averagePos = [ Point3(0, 0, 0), Point3(0, 0, 0), Point3(0, 0, 0), Point3(0, 0, 0) ] divisor = 0 for avId in list(self.avatarEndingPositions.keys()): divisor += 1 oneClientEndingPositions = self.avatarEndingPositions[avId] avIndex = self.avIdList.index(avId) for index in range(len(oneClientEndingPositions)): pos = oneClientEndingPositions[index] averagePos[index] += Point3(pos[0], pos[1], pos[2]) self.notify.debug('index = %d averagePos = %s' % (index, averagePos)) sentPos = [] if divisor: for newPos in averagePos: newPos /= divisor newPos.setZ(IceGameGlobals.TireRadius) # always ground them sentPos.append([newPos[0], newPos[1], newPos[2]]) else: sentPos = self.finalEndingPositions self.sendUpdate('setFinalPositions', [sentPos]) self.finalEndingPositions = sentPos # from here we can go to several different states # if the match is not over, go to waitClientsChoices # if the match is over, but not the game, go to scoring # if the game is over, go to finalResults if (self.curMatch == IceGameGlobals.NumMatches -1) and \ (self.curRound == IceGameGlobals.NumRounds - 1): # end the game self.gameFSM.request('scoreMatch') pass elif self.curRound == IceGameGlobals.NumRounds - 1: # match is ending, score it self.gameFSM.request('scoreMatch') pass else: # match is not yet over self.curRound += 1 self.sendUpdate('setMatchAndRound', [self.curMatch, self.curRound]) self.gameFSM.request('waitClientsChoices') pass
def startBallPlayback(self, power, angle, sequenceNum): """Start the ball flying in the air.""" assert self.notify.debugStateCall(self) # duplicate our current ball model flyBall = self.ballModel.copyTo(NodePath()) flyBall.setScale(1.0) flyBallBubble = self.getFlyBallBubble().instanceTo(NodePath()) flyBallBubble.reparentTo(flyBall) flyBall.setTag('pieSequence', str(sequenceNum)) flyBall.setTag('throwerId', str(self.avId)) # First, create a ProjectileInterval to compute the relative # velocity. t = power / 100.0 # make the ball travel farther, the longer you press the bar t = 1.0 - t # Distance ranges from 300 - 100 ft, time ranges from 1.5 - 2 s. dist = 300 - 200 * t time = 1.5 + 0.5 * t proj = ProjectileInterval( None, startPos=Point3(0, 0, 0), endPos=Point3(0, dist, 0), duration=time, ) relVel = proj.startVel def getVelocity(root=self.root, relVel=relVel): return render.getRelativeVector(root, relVel) fly = Sequence( #Func(self.ballModel.hide), Func(flyBall.reparentTo, render), Func(flyBall.setPosHpr, self.root, 0, 0, 0, 0, 0, 0), Func(base.cTrav.addCollider, flyBallBubble, self.flyBallHandler), ProjectileInterval(flyBall, startVel=getVelocity, duration=3), Func(flyBall.detachNode), Func(base.cTrav.removeCollider, flyBallBubble), Func(self.notify.debug, "removed collider"), Func(self.flyBallFinishedFlying, sequenceNum)) flyWithSound = Parallel(fly, SoundInterval(self.hitBallSfx, node=self.root), name='flyWithSound') self.notify.debug('starting flyball track') flyWithSound.start() self.flyBallTracks[sequenceNum] = flyWithSound pass
def __init__(self, cameraNP): self.cameraNP = cameraNP self.id = CameraManager.nextID CameraManager.nextID += 1 self.otherNP = render self.lookAtNP = NodePath("CameraManager%d.lookAtNP" % self.id) self.lookAtEnabled = False self.targetPos = Point3(0.0, 0.0, 0.0) self.targetLookAtPos = Point3(0.0, 1.0, 0.0) self.enabled = False self.rate = 10.0
def setupCollision(self): DistributedLawnDecor.DistributedLawnDecor.setupCollision(self) minPt = Point3(0,0,0) maxPt = Point3(0,0,0) self.model.calcTightBounds(minPt,maxPt) #radius = bounds.getRadius() self.notify.debug( "max=%s min=%s" % (maxPt,minPt)) xDiff = maxPt[0] - minPt[0] yDiff = maxPt[1] - minPt[1] radius = (xDiff * xDiff + yDiff*yDiff) ** 0.5 #I don't understand why calcTightBounds is giving me such huge numbers back radius /= 3 self.notify.debug( 'xDiff=%s yDiff=%s radius = %s' % (xDiff, yDiff, radius)) self.colSphereNode.setScale(radius)
def doMolePop(self, startTime, timeToMoveUp, timeToStayUp, timeToMoveDown, moleType): """Show a mole popping up. startTime = will be based from startupTime timeToMoveUp = number of seconds it takes to go up timeToStayUp = how long will the mole stay up timeToMoveDown = how long it will take for the mole to move down """ if self.hillType == MoleFieldBase.HILL_WHACKED or self.hillType == MoleFieldBase.HILL_COGWHACKED: return if self.popIval: self.popIval.pause() if self.downIval: self.downIval.pause() self.downIval = None moleColor = None #if moleType == MoleFieldBase.HILL_BOMB: # moleColor = Vec4(1,0,0,1) # self.moleColNodePath.setScale(5.0) #else: # moleColor = Vec4(1,1,1,1) # self.moleColNodePath.setScale(1.0) self.switchUp() self.popupNum += 1 if self.hillType == MoleFieldBase.HILL_BOMB: self.popIval = Sequence( #Func(self.mole.setColorScale, moleColor), Func(self.setHillType, moleType), Func(self.moleColNodePath.unstash), LerpPosInterval(self.mole, timeToMoveUp, Point3(0,0,0.0)), Wait(timeToStayUp), LerpPosInterval(self.mole, timeToMoveDown, Point3(0,0,-2.5)), Func(self.stashMoleCollision), Func(self.switchDown), ) else: self.popIval = Sequence( #Func(self.mole.setColorScale, moleColor), Func(self.setHillType, moleType), LerpPosInterval(self.mole, timeToMoveUp, Point3(0,0,0.0)), Func(self.moleColNodePath.unstash), Wait(timeToStayUp), Func(self.stashMoleCollision), LerpPosInterval(self.mole, timeToMoveDown, Point3(0,0,-2.5)), Func(self.switchDown), ) self.popIval.start()
def cogHitBarrel(self, clientStamp, cogIndex, barrelIndex, x, y, z): """A cog hit the barrel, see if he should pick it up and run""" assert self.notify.debugStateCall(self) if cogIndex >= self.getNumCogs(): self.notify.warning('cogHitBarrel, possible hacker cogIndex=%s' % cogIndex) return if barrelIndex >= CTGG.NumBarrels: self.notify.warning( 'cogHitBarrel, possible hacker barrelIndex=%s' % barrelIndex) return if self.isCogCarryingABarrel(cogIndex): # cog is already carrying a barrel ignore self.notify.debug('cog is already carrying a barrel ignore') return if self.cogInfo[cogIndex]['goal'] == CTGG.NoGoal: # we got a late hit after he was already moved to starting position self.notify.debug('ignoring barrel hit as cog %d has no goal' % cogIndex) return if self.getCogCarryingBarrel(barrelIndex) == CTGG.BarrelOnGround: pos = Point3(x, y, z) returnPosIndex = self.chooseReturnPos(cogIndex, pos) self.runAway(clientStamp, cogIndex, pos, barrelIndex, returnPosIndex)
def setSwingInfo(self, power, angle, sequenceNum): """Handle a toon swinging at the golf ball.""" assert self.notify.debugStateCall(self) av = base.cr.doId2do.get(self.avId) self.swingInterval = Sequence() if av: self.stopAdjustClubTask() self.swingInterval = Sequence( ActorInterval(av, 'swing-putt', startFrame=0, endFrame=GolfGlobals.BALL_CONTACT_FRAME), Func(self.startBallPlayback, power, angle, sequenceNum), Func(self.ballModel.hide), ActorInterval(av, 'swing-putt', startFrame=GolfGlobals.BALL_CONTACT_FRAME, endFrame=24), Func(self.ballModel.setScale, 0.1), Func(self.ballModel.show), LerpScaleInterval(self.ballModel, 1.0, Point3(1, 1, 1)), Func(self.enableControlKey), ) if av == localAvatar: self.swingInterval.append( Func(self.switchToAnimState, 'GolfPuttLoop', True)) self.swingInterval.start()
def elementDragTask(self, state): mwn = base.mouseWatcherNode if mwn.hasMouse(): vMouse2render2d = Point3(mwn.getMouse()[0], 0, mwn.getMouse()[1]) newPos = vMouse2render2d # Check to see if the new position is within the grounds bounds if newPos[0] > PartyGlobals.PartyEditorGridBounds[0][0] and \ newPos[0] < PartyGlobals.PartyEditorGridBounds[1][0] and \ newPos[2] < PartyGlobals.PartyEditorGridBounds[0][1] and \ newPos[2] > PartyGlobals.PartyEditorGridBounds[1][1]: centerGridSquare = self.snapToGrid(newPos) if centerGridSquare is not None: # The mouse is over the grid and over a valid square self.centerGridSquare = centerGridSquare if not self.overValidSquare: self.setOverValidSquare(True) if self.mouseOverTrash: self.setOverTrash(False) return Task.cont # Check to see if it is within the trash bounds if self.id != PartyGlobals.ActivityIds.PartyClock and \ newPos[0] > PartyGlobals.PartyEditorTrashBounds[0][0] and \ newPos[0] < PartyGlobals.PartyEditorTrashBounds[1][0] and \ newPos[2] < PartyGlobals.PartyEditorTrashBounds[0][1] and \ newPos[2] > PartyGlobals.PartyEditorTrashBounds[1][1]: if not self.mouseOverTrash: self.setOverTrash(True) else: if self.mouseOverTrash: self.setOverTrash(False) self.setPos(render2d, newPos) if self.overValidSquare: self.setOverValidSquare(False) return Task.cont
def showQuestArrow(self, parent, nodeToPoint, offset=Point3(0, 0, 0)): self._questArrowNodeToPoint = nodeToPoint self._questArrowParent = parent self._questArrowOffset = offset self._questArrow.unstash() self._questArrowVisible = True self.__startUpdateTask()
def startActive(self): DistributedPartyTeamActivity.startActive(self) # reset active variables 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: # what the heck do we do at this point? lets try 0,0,0 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()
def pieHitSuit(self, avId, timestamp, suitNum, x, y, z): """A toon hit a suit, have the suit do something else.""" assert self.notify.debugStateCall(self) if suitNum >= self.getNumCogs(): self.notify.warning('hitBySuit, possible hacker avId=%s' % avId) return barrelIndex = self.cogInfo[suitNum]['barrel'] # we must set the cog pos before we drop barrel, # as that's where we drop the barrel if barrelIndex >= 0: # the x,y,z we get is actually the cog position, but we drop the # barrel right on it barrelPos = Point3(x, y, z) self.b_makeCogDropBarrel(timestamp, suitNum, barrelIndex, barrelPos) startPos = CTGG.CogStartingPositions[suitNum] self.cogInfo[suitNum]['pos'] = startPos self.cogInfo[suitNum]['goal'] = CTGG.NoGoal self.cogInfo[suitNum]['goalId'] = CTGG.InvalidGoalId self.sendSuitSync(timestamp, suitNum) # TODO figure out if we want to chase a toon or go for a barrel self.doMethodLater(self.ExplodeWaitTime, self.chooseSuitGoal, self.uniqueName('choseSuitGoal-%d-' % suitNum), extraArgs=[suitNum])
def update(self): self.player.tempNP.setPos( self.player.locator, self.player.toon.getPos() + self.defaultOffset) self.player.cameraManager.setTargetPos( self.player.tempNP.getPos(render)) self.player.tempNP.setPos( self.player.locator, self.player.toon.getPos() + self.defaultOffset + Point3(0, 20, 0)) self.player.cameraManager.setTargetLookAtPos( self.player.tempNP.getPos(render)) if not self.player._aimMode and self.player.input.throwPiePressed: self.toggleAim() if self.player._aimMode and not self.player.input.throwPiePressed and ( self.player.input.upPressed or self.player.input.downPressed or self.player.input.leftPressed or self.player.input.rightPressed): self.toggleAim() if not self.player._aimMode: if not (self.player.input.upPressed or self.player.input.downPressed or self.player.input.leftPressed or self.player.input.rightPressed): self.player.faceForward() return if self.player.input.throwPiePressed: self.player.gui.updatePiePowerMeter( self.player.getPieThrowingPower(globalClock.getFrameTime()))
def setupAvatars(self, av): """ Prepare avatars for the quest movie """ # Ignore avatars now to prevent unnecessary requestInteractions when we know # this npc is busy right now. If another toon did manage to request interaction # before we starting ignoring, he will get a freeAvatar message from the server self.ignoreAvatars() # Make us face each other # Actually this looks funny for the fishermen # av.headsUp(self, 0, 0, 0) # self.headsUp(av, 0, 0, 0) av.stopLookAround() av.lerpLookAt(Point3(-0.5, 4, 0), time=0.5) self.stopLookAround() self.lerpLookAt(Point3(av.getPos(self)), time=0.5)
def pieHitsToon(self, toonId, timestamp, x, y, z): """ Broadcast event coming from another client that announces a that a toon in the activity was hit with a pie. """ assert(self.notify.debug("pieHitsToon %s" % toonId)) self.view.pieHitsToon(toonId, timestamp, Point3(x, y, z))
def getPaths(charName, location=0): if charName == TTLocalizer.Mickey: return __mickeyPaths elif charName == TTLocalizer.VampireMickey: return __mickeyPaths elif charName == TTLocalizer.Minnie: return __minniePaths elif charName == TTLocalizer.WitchMinnie: return __minniePaths elif charName == TTLocalizer.Daisy: return __daisyPaths elif charName == TTLocalizer.Goofy: if location == 0: return __goofyPaths else: return __goofySpeedwayPaths elif charName == TTLocalizer.SuperGoofy: return __goofySpeedwayPaths elif charName == TTLocalizer.Donald: return __donaldPaths elif charName == TTLocalizer.Pluto: return __plutoPaths elif charName == TTLocalizer.WesternPluto: return __plutoPaths elif charName == TTLocalizer.Chip: return __chipPaths elif charName == TTLocalizer.Dale: return __chipPaths elif charName == TTLocalizer.DonaldDock: return {'a': (Point3(0, 0, 0), 'a')} else: assert 0, "Unknown path information"
def toonUsedGag(self, toonId, x, y, h, elapsedTime=0.0): player = self.toonId2Player[toonId] heading = h pos = Point3(x, y, 0) gag = player.showToonThrowingGag(heading, pos) if gag is not None: self.gags.append(gag) return
def getWayPoints(fromNode, toNode, paths, wpts=None): list = [] if (fromNode != toNode): if wpts == None: wpts = __getWaypointList(paths) for path in wpts: if path[0] == fromNode and path[1] == toNode: for point in path[3]: list.append(Point3(point)) break elif path[0] == toNode and path[1] == fromNode: # reverse the order of the list for point in path[3]: list = [Point3(point)] + list break return list
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.778 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()
def _initCollisions(self): self.collPlane = CollisionPlane( Plane(Vec3(0, 0, 1.0), Point3(0, 0, 10))) self.collPlane.setTangible(0) self.collNode = CollisionNode('fogPlane') self.collNode.setIntoCollideMask(OTPGlobals.FloorBitmask) self.collNode.addSolid(self.collPlane) self.collNodePath = self.root.attachNewNode(self.collNode) self.collNodePath.hide()
def __init__(self): self.cogTracker = loader.loadModel("phase_13/models/parties/cogTrackerGUI") self.cogTracker.reparentTo( aspect2d ) self.cogTracker.setScale(1.25) self.cogTracker.setX(1.0) self.cogTracker.setZ(-0.75) self.frame = self.cogTracker.find( "**/tracker" ) self.cogs = [] self.cogLayers = [] self.blinkIntervals = [] i=0 self.cogTracker.find("**/shadow").setBin("fixed",0) self.cogTracker.find("**/plane").setBin("fixed",1) for i in range(3): layers = [self.cogTracker.find("**/cog%d_blue" % i), self.cogTracker.find("**/cog%d_orange" % i), self.cogTracker.find("**/cog%d_white" % i)] self.cogs.append(self.cogTracker.find("**/cog%d" % i)) self.cogLayers.append(layers) self.cogTracker.find("**/cog%d" % i).setBin("fixed",2) big = Point3(1.5,1.5,1.5) seq = Sequence( LerpScaleInterval( self.cogs[i], duration=0.1, scale=big, startScale=Point3(1.0,1.0,1.0), blendType="easeOut" ), LerpScaleInterval( self.cogs[i], duration=0.25, scale=Point3(1.0,1.0,1.0), startScale=big, blendType="easeOut" ), Wait(0.4), ) self.blinkIntervals.append( seq ) self.top = self.cogTracker.find("**/cog0_top").getZ() self.bottom = self.cogTracker.find("**/cog0_bottom").getZ() self.whiteTextureNp = self.cogTracker.find( "**/cog0_white" ) self.whiteTexture = self.whiteTextureNp.findTexture("*") for cog in self.cogs: cog.setTexture(self.whiteTexture)
def initCogInfo(self): """For each cog, initialize the info about him.""" for cogIndex in range(self.getNumCogs()): self.cogInfo[cogIndex] = { 'pos': Point3(CogThiefGameGlobals.CogStartingPositions[cogIndex]), 'goal': CTGG.NoGoal, 'goalId': CTGG. InvalidGoalId, # avatar id if he's chasing a toon, barrel index otherwise 'barrel': CTGG.NoBarrelCarried }