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 xrange(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 __init__(self): FSM.__init__(self, "FSM-Golem") random.seed() self.golem = loader.loadModel("Golem") self.golem = Actor( "Golem", { "Idle": "Golem-Idle", "Walk": "Golem-Walk", "Attack": "Golem-Attack", "Destroyed": "Golem-Destroyed" }) self.golem.setBlend(frameBlend=True) golemViewSphere = CollisionSphere(0, 0, 0.5, 6) golemViewSphere.setTangible(False) golemViewColNP = self.golem.attachNewNode( CollisionNode('golemViewField')) golemViewColNP.node().addSolid(golemViewSphere) golemHitSphere = CollisionSphere(0, 0, 0.5, 1) golemHitColNP = self.golem.attachNewNode( CollisionNode('golemHitField')) golemHitColNP.node().addSolid(golemHitSphere) # a collision segment to check attacks self.attackCheckSegment = CollisionSegment(0, 0, 1, 0, -1.3, 1) self.golemAttackRay = self.golem.attachNewNode( CollisionNode("golemAttackCollision")) self.golemAttackRay.node().addSolid(self.attackCheckSegment) self.golemAttackRay.node().setIntoCollideMask(0) self.attackqueue = CollisionHandlerQueue() base.cTrav.addCollider(self.golemAttackRay, self.attackqueue) attackAnim = self.golem.actorInterval("Attack", playRate=2) self.AttackSeq = Parallel(attackAnim, Sequence(Wait(0.5), Func(self.ceckAttack))) self.lookatFloater = NodePath(PandaNode("golemTracker")) self.lookatFloater.setPos(self.golem, 0, 0, 3.4) self.lookatFloater.hide() self.lookatFloater.reparentTo(render) self.trackerObject = loader.loadModel("misc/Pointlight") self.trackerObject.setColor(0, 1, 0) self.trackerObject.setScale(0.25) self.trackerObject.reparentTo(self.lookatFloater)
def showSpamWarning(self): if self._spamWarning.isHidden(): self._spamWarning.show() taskMgr.remove(self._spamWarningIvalName) Sequence( # Boing it in to grab attention. ToontownIntervals.getPulseLargerIval(self._spamWarning, ""), # Let it sit on-screen for a while. Wait(PartyGlobals.CogActivitySpamWarningShowTime), # Then get rid of it. Func(self.hideSpamWarning), name=self._spamWarningIvalName, autoFinish=1 ).start()
def moveTargetToPosition(caster, position, tileMap): """ Moves caster to position. Uses Breadth First Search to get a path to the position. Create and play a sequence of intervals to travel from node to node until reaching the final tile. Drains energy on each move: """ moveSequence = Sequence() # Get list of steps to destination: steps = findTilesFromTo(caster.getGridPosition(), position, tileMap) # Safety Check: if steps == None: print( "NO PATH FOUND" ) #TODO: Implement case when no path is found! Perhaps cancel caster targeter! return # Our algorithm always includes the start position, which we don't want in # this case: steps.pop(0) # For every step, create a movement interpolation interval and then update: initialPos = caster.getGridPosition() count = 0 for step in steps: lastPos = initialPos if count == 0 else steps[count - 1] newPos = coordToRealPosition(step) moveSequence.append(Func(checkDrainEnergy, caster, Move.getEnergyCost)) moveSequence.append(Wait(0.1)) moveSequence.append( Func(syncAction, caster, Move.actionID, coords=(step[0], step[1]))) moveSequence.append( Func(updateObjectLocation, caster, lastPos, step, tileMap)) moveSequence.append(Func(playMoveAnim, caster, step)) moveSequence.append( LerpPosInterval(caster.getNodePath(), 1.0, newPos)) #TODO make 1.0 a speed constant moveSequence.append(Func(pickupAnyItems, caster, tileMap)) moveSequence.append(Func(stopMoveAnim, caster)) count += 1 moveSequence.append(Func(endAction, caster)) # Apply end signal to action. # Finally, play the movement sequence: caster.startAction(moveSequence)
def hourChange(self, currentHour): currentHour = currentHour % 12 if currentHour == 0: currentHour = 12 self.hourSoundInterval = Parallel() seq1 = Sequence() for i in xrange(currentHour): seq1.append(SoundInterval(self.clockSounds[i])) seq1.append(Wait(0.2)) timeForEachDeformation = seq1.getDuration() / currentHour seq2 = Sequence() for i in xrange(currentHour): seq2.append(self.clockFlat.scaleInterval(timeForEachDeformation / 2.0, Vec3(0.9, 1.0, 1.2), blendType='easeInOut')) seq2.append(self.clockFlat.scaleInterval(timeForEachDeformation / 2.0, Vec3(1.2, 1.0, 0.9), blendType='easeInOut')) seq2.append(self.clockFlat.scaleInterval(timeForEachDeformation / 2.0, Vec3(1.0, 1.0, 1.0), blendType='easeInOut')) self.hourSoundInterval.append(seq1) self.hourSoundInterval.append(seq2) self.hourSoundInterval.start()
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 toPos = entry.getInteriorPoint(render) taskMgr.remove('rollTask') # Stop the maze task # 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.ui.ballRoot.setX, fromData = self.ui.ballRoot.getX(), toData = toPos.getX(), duration = .1), LerpFunc(self.ui.ballRoot.setY, fromData = self.ui.ballRoot.getY(), toData = toPos.getY(), duration = .1), LerpFunc(self.ui.ballRoot.setZ, fromData = self.ui.ballRoot.getZ(), toData = self.ui.ballRoot.getZ() - .9, duration = .2)), Func(self.ui.show_message, "Try Again!"), Wait(1), Func(self.ui.show_message, ""), Func(self.start)).start()
def acquireToon( self ): # self.dataLog = open( "dataLog.txt", "w" ) self.toon.disableSmartCameraViews() self.toon.stopUpdateSmartCamera() camera.wrtReparentTo(render) self.toon.dropShadow.reparentTo( hidden ) self.toon.startPosHprBroadcast( period=0.2 ) self.toonAcceleration = 0.0 self.toonVelocity = 0.0 self.topHeight = 0.0 self.trampB = self.normalTrampB self.leavingTrampoline = False self.hopOnAnim = Sequence( Func( self.toon.b_setAnimState, "jump", 1.0 ), Wait( 0.4 ), PartyUtils.arcPosInterval( 0.75, self.toon, Point3( 0.0, 0.0, self.trampHeight ), 5.0, self.tramp ), Func( self.postHopOn ), ) self.hopOnAnim.start()
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()
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.3), 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')))
def fadeInLevel(self, fadeTime=1.6): """ fade-in animation. the parameter it takes is the time in seconds.changing it might cause animation glitches with the cube-fade-in animation """ self.sounds.playSound("nyon.wav") tiles = self.levelNode.findAllMatches("=Pos") for tile in tiles: x, y, z = self.getPosFromTile(tile) tile.setPos(x, y, -15) tile.setHpr(random() * 360 - 180, random() * 360 - 180, random() * 360 - 180) seq = LerpPosQuatInterval(tile, fadeTime + (0.3 * fadeTime * random()), (x, y, 0), (0, 0, 0), blendType='easeOut') tile.setPythonTag("Seq", seq) seq.start() Sequence(Wait(fadeTime * 1.4), Func(lambda: self.animateTiles())).start()
def traverseTask(self, task=None): # handles collisions with collision handers and a # collision queue # essentially checks region of potential collision for collisions # and stops the ball if a collision is triggered # called by task manager self.ballModelGroundHandler.sortEntries() for i in range(self.ballModelGroundHandler.getNumEntries()): entry = self.ballModelGroundHandler.getEntry(i) if self.drop == True: #we cant drop in this situation self.ballModel.setZ(self.currentHeight) dropFailWait = 4 dropFailSeq = Sequence() dropFailSeq.append(Func(addNotification,"Whoops! You can't drop here!")) dropFailSeq.append(Wait(dropFailWait)) dropFailSeq.append(Func(deleteNotifications)) dropFailSeq.start() self.drop = False elif self.direction == "N": self.northDisableMovements() elif self.direction == "S": self.southDisableMovements() elif self.direction == "E": self.eastDisableMovements() elif self.direction == "W": self.westDisableMovements() if task: return task.cont #exit task # If there are no collisions if task: return task.cont
def fade_screen(self, time=1.5, color=(0, 0, 0)): '''Turns the screen to 'color' then fades the color away in 'time' seconds''' startColor = self.fade_quad.get_color() if startColor[3] == 0.0: Sequence( Func(self.fade_quad.show), LerpColorInterval(nodePath=self.fade_quad, duration=time, color=(color[0], color[1], color[2], 1), startColor=startColor), ).start() else: Sequence( Func(self.fade_quad.show), Wait(time * 0.1), LerpColorInterval(nodePath=self.fade_quad, duration=time * 0.9, color=(color[0], color[1], color[2], 0), startColor=startColor, blendType='easeIn'), Func(self.fade_quad.hide), ).start()
def fade(self, time=1.5): '''Turns rhe screen black then fades the black away in 'time' seconds''' startColor = self.black_quad.get_color() if startColor[3] == 0.0: Sequence( Func(self.black_quad.show), LerpColorInterval(nodePath=self.black_quad, duration=time, color=(0, 0, 0, 1), startColor=startColor), ).start() else: Sequence( Func(self.black_quad.show), Wait(time * 0.1), LerpColorInterval(nodePath=self.black_quad, duration=time * 0.9, color=(0, 0, 0, 0), startColor=startColor, blendType='easeIn'), Func(self.black_quad.hide), ).start()
def pickUp(self, toon, elapsedSeconds=0.0): self._wasPickedUp = True if self._animSeq is not None: self._animSeq.finish() self._animSeq = None if self._animate: def lerpFlyToToon(t): vec = toon.getPos(render) - self.getPos(render) vec[2] += toon.getHeight() self.setPos(self.getPos() + vec * t) self.setScale(1.0 - t * 0.8) self._animSeq = Sequence( LerpFunc(lerpFlyToToon, fromData=0.0, toData=1.0, duration=self._animDuration), Wait(0.1), Func(self.hide)) self._animSeq.start(elapsedSeconds) else: self.hide()
def resetGame(self, wait=0): # bullet limit reset self.bullets_fired = 0 self.bullets_hit = 0 self.bullets_num = BULLET_LIMIT self.bullets_text.setText("bullets %d"%self.bullets_num) self.ship_firing = 0 # bullet limit end self.alive = False for i in self.asteroids + self.bullets: i.removeNode() self.bullets = [] # Clear the bullet list self.ship.hide() # Hide the ship # Reset the velocity self.setVelocity(self.ship, LVector3(0, 0, 0)) Sequence(Wait(wait), # Wait 2 seconds Func(self.ship.setR, 0), # Reset heading Func(self.ship.setX, 0), # Reset position X # Reset position Y (Z for Panda) Func(self.ship.setZ, 0), Func(self.ship.show), # Show the ship Func(self.spawnAsteroids)).start() # Remake asteroids
def getPresentGuiIval(np, name, waitDuration=0.5, moveDuration=1.0, parent=aspect2d): """ Presents a new GUI: Shows/boings the gui right on the center of the screen, then moves the gui to where it's supposed to go. """ endPos = np.getPos() np.setPos(parent, 0, 0, 0) return Sequence(Func(np.show), getPulseLargerIval(np, "", scale=np.getScale()), Wait(waitDuration), np.posInterval( moveDuration, endPos, blendType="easeInOut", ), name=name, autoFinish=1)
def getSceneReady(self): '''Get if the scene is ready''' textbox_ready = False view_ready = False intervals_ready = True if not self.gameTextBox.getIsWaiting(): textbox_ready = True if not self.storyView.getIsWaiting(): view_ready = True for itv in self.intervals: if itv.isPlaying(): intervals_ready = False break scene_ready = textbox_ready and view_ready and intervals_ready if not scene_ready: return False #auto play span if scene_ready and self.__autoplaying: if self.__autoplaystep != self.step: self.__autoplaystep = self.step self.__autoInterval = Wait(runtime_data.game_settings['auto_span']) self.__autoInterval.start() scene_ready = False else: if self.__autoInterval.isPlaying(): scene_ready = False if self.audioPlayer.isVoicePlaying(): scene_ready = False return scene_ready
def load(self): """ Loads the dance floor and place it in the right spot. """ DistributedPartyActivity.load(self) self.danceFloor = loader.loadModel( "phase_13/models/parties/danceFloor") self.danceFloor.reparentTo(self.getParentNodePath()) self.danceFloor.setPos(self.x, self.y, 0.0) self.danceFloor.setH(self.h) # Reparent to render so that when the fireworks are on, it "glows" in the dark self.danceFloor.wrtReparentTo(render) self.sign.setPos(22, -22, 0) # Initialize programatic animation sequences floor = self.danceFloor.find("**/danceFloor_mesh") self.danceFloorSequence = Sequence(Wait(0.3), Func(floor.setH, floor, 36)) # Spin the ball around while bobbing up and down # (since it's being held by balloons!) # spinning the disco ball moved to the child classes, # to deal with 10 and 20 on the ball 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")), )
def load(self): self.notify.debug('load()') CogdoGameMovie.load(self) backgroundGui = loader.loadModel( 'phase_5/models/cogdominium/tt_m_gui_csa_flyThru') self.bg = backgroundGui.find('**/background') self.chatBubble = backgroundGui.find('**/chatBubble') self.chatBubble.setScale(6.5, 6.5, 7.3) self.chatBubble.setPos(0.32, 0, -0.78) self.bg.setScale(5.2) self.bg.setPos(0.14, 0, -0.6667) self.bg.reparentTo(aspect2d) self.chatBubble.reparentTo(aspect2d) self.frame = DirectFrame(geom=self.bg, relief=None, pos=(0.2, 0, -0.6667)) self.bg.wrtReparentTo(self.frame) self.gameTitleText = DirectLabel(parent=self.frame, text=TTLocalizer.CogdoBarrelRoomTitle, scale=TTLocalizer.MRPgameTitleText * 0.8, text_align=TextNode.ACenter, text_font=getSignFont(), text_fg=(1.0, 0.33, 0.33, 1.0), pos=TTLocalizer.MRgameTitleTextPos, relief=None) self.chatBubble.wrtReparentTo(self.frame) self.frame.hide() backgroundGui.removeNode() 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.clipPlane = self.toonHead.attachNewNode(PlaneNode('clip')) self.clipPlane.node().setPlane(Plane(0, 0, 1, 0)) self.clipPlane.setPos(0, 0, 2.45) self._toonDialogueSfx = loader.loadSfx( 'phase_3.5/audio/dial/AV_dog_long.ogg') self._camHelperNode = NodePath('CamHelperNode') self._camHelperNode.reparentTo(render) dialogue = TTLocalizer.CogdoBarrelIntroMovieDialogue def start(): self.frame.show() def end(): self._dialogueLabel.reparentTo(hidden) self.toonHead.reparentTo(hidden) self.frame.hide() self._stopUpdateTask() self._ival = Sequence( Func(start), Func(self.displayLine, dialogue), Wait(CogdoBarrelRoomConsts.BarrelRoomIntroTimeout), Func(end)) self._startUpdateTask()
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('ms') self.cogHead.setDNA(self.cogDNA) self.cogHead.getGeomNode().setDepthWrite(1) self.cogHead.getGeomNode().setDepthTest(1) self.cogHead.loop('neutral') self.cogHead.setPosHprScale(-0.73, 0, -1.46, 180, 0, 0, 0.14, 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') suitData = Globals.SuitData[Globals.SuitTypes.Boss] bossSuit = Suit.Suit() d = SuitDNA.SuitDNA() d.newSuit(suitData['dnaName']) bossSuit.setDNA(d) bossSuit.setScale(suitData['scale']) bossSuit.loop('neutral') bossSuit.reparentTo(render) bossSuit.setPos(self._exit, -5, -5, 0) bossSuit.lookAt(self._exit) self._suits.append(bossSuit) self._camHelperNode = NodePath('CamHelperNode') self._camHelperNode.reparentTo(render) dialogue = TTLocalizer.CogdoMazeIntroMovieDialogue introDuration = Globals.IntroDurationSeconds waitDuration = introDuration / len(dialogue) def start(): camera.wrtReparentTo(render) self._exit.open(animate=False) def showBoss(): self._setCamTarget(bossSuit, 20, offset=Point3(0, 0, 7), angle=Point3(0, 15, 0)) bossSuit.loop('victory') self._state = 1 def showExit(): self._setCamTarget(self._exit, 10, offset=Point3(0, 0, 0), angle=Point3(0, 60, 0)) self._exit.close() self._state = 2 showExitIval = Parallel( camera.posInterval(waitDuration * 0.5, (10, -25, 20), other=self._exit, blendType='easeInOut'), Sequence( Wait(waitDuration * 0.25), Func(bossSuit.play, 'effort'), camera.hprInterval(waitDuration * 0.25, (30, -30, 0), blendType='easeInOut'), Func(self._exit.close), Wait(waitDuration * 0.5))) def showWaterCooler(): wc = self._maze.getWaterCoolers()[0] self._setCamTarget(wc, 25, angle=Point3(-30, 60, 0)) camera.wrtReparentTo(self._camHelperNode) self._state = 3 def end(): self._stopUpdateTask() self._ival = Sequence( Func(start), Func(self.displayLine, 'toon', self._getRandomLine(dialogue[0])), showExitIval, Func(showWaterCooler), Func(self.displayLine, 'toon', self._getRandomLine(dialogue[1])), Wait(waitDuration), Func(showBoss), bossSuit.hprInterval(1.0, bossSuit.getHpr() + Point3(180, 0, 0), blendType='easeInOut'), Func(self.displayLine, 'toon', self._getRandomLine(dialogue[2])), Wait(waitDuration - 1.0), Func(end)) self._startUpdateTask()
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))
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 __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()
def startConclusion(self): DistributedPartyCatchActivity.notify.debug('startConclusion') for avId in self.toonIds: if avId in self.toonSDs: toonSD = self.toonSDs[avId] toonSD.fsm.request('notPlaying') self.destroyCatchCollisions() if base.localAvatar.doId not in self.toonIds: return else: self.localToonExiting() if self.fruitsCaught >= self.numFruits: finishText = TTLocalizer.PartyCatchActivityFinishPerfect else: finishText = TTLocalizer.PartyCatchActivityFinish perfectTextSubnode = hidden.attachNewNode(self.__genText(finishText)) perfectText = hidden.attachNewNode('perfectText') perfectTextSubnode.reparentTo(perfectText) frame = self.__textGen.getCardActual() offsetY = -abs(frame[2] + frame[3]) / 2.0 perfectTextSubnode.setPos(0, 0, offsetY) perfectText.setColor(1, 0.1, 0.1, 1) def fadeFunc(t, text = perfectText): text.setColorScale(1, 1, 1, t) def destroyText(text = perfectText): text.removeNode() textTrack = Sequence(Func(perfectText.reparentTo, aspect2d), Parallel(LerpScaleInterval(perfectText, duration=0.5, scale=0.3, startScale=0.0), LerpFunctionInterval(fadeFunc, fromData=0.0, toData=1.0, duration=0.5)), Wait(2.0), Parallel(LerpScaleInterval(perfectText, duration=0.5, scale=1.0), LerpFunctionInterval(fadeFunc, fromData=1.0, toData=0.0, duration=0.5, blendType='easeIn')), Func(destroyText), WaitInterval(0.5)) soundTrack = SoundInterval(self.sndPerfect) self.finishIval = Parallel(textTrack, soundTrack) self.finishIval.start()
def startActive(self): DistributedPartyTrampolineActivity.notify.debug('startActive') if self.toon != None and self.toon.doId == base.localAvatar.doId: base.setCellsActive(base.bottomCells, True) self.accept('arrow_left', self.onLeft) self.accept('arrow_left-up', self.onLeftUp) self.accept('arrow_right', self.onRight) self.accept('arrow_right-up', self.onRightUp) self.beginRoundInterval = Sequence(Func(self._showFlashMessage, TTLocalizer.PartyTrampolineReady), Wait(1.2), Func(self.flashMessage, TTLocalizer.PartyTrampolineGo), Func(self.beginRound)) self.beginRoundInterval.start() return
def endGame(self, task=None): dummy = render.attachNewNode("dummy") dummy.reparentTo(self.cube) dummy.setZ(render, .1) dummy.wrtReparentTo(render) dummy.setHpr(0, 0, 0) self.level.fadeOutLevel() Sequence(Wait(0.3), Func(lambda *args: self.cube.hide())).start() taskMgr.doMethodLater(2, self.levelUp, "lvlup") taskMgr.doMethodLater(2, lambda *args: self.cube.show(), "show cube") taskMgr.doMethodLater( 2, lambda *args: self.shard_node.node().remove_all_children(), "clear shards") Sequence( Wait(0.2), Func(lambda *args: self.sounds.playSound("finish.wav"))).start() cube_min, cube_max = Vec3(-0.5, -0.5, -1), Vec3(0.5, 0.5, 1) self.shard_node.set_pos(dummy.get_pos(render) + Vec3(-0.5, 0, 0)) shard_size = (cube_max - cube_min) / 5.0 self.shard_node.hide() Sequence(Wait(0.22), Func(lambda *args: self.shard_node.show())).start() for i in range(5): for j in range(5): for k in range(5): shard = loader.loadModel("models/CubeShard.bam") shard.reparent_to(self.shard_node) shard.set_x(i * shard_size.x + 0.1) shard.set_y(j * shard_size.y + 0.1) shard.set_z(k * shard_size.z + 0.2) shard.set_scale(0.8 + random()) force = Vec3(i - 2 - 0.15, j - 2 - 0.15, k - 2 + 2.6) force.normalize() force *= 12.0 * (1 + random() * 0.5) d_hpr = Vec3(random(), random(), random()) * 360.0 * (3.0 + random()) shard_anim = Sequence( Wait(0.22), LerpFunc( self.animateShard, fromData=0, toData=2, duration=2.0, blendType='noBlend', extraArgs=[shard.get_pos(), d_hpr, shard, force]), LerpHprInterval(shard, 1.0 + random(), d_hpr * 1.6, d_hpr, blendType='noBlend'), ) shard_anim.start()
def load(self): self.notify.debug('load()') CogdoGameMovie.load(self) backgroundGui = loader.loadModel( 'phase_5/models/cogdominium/tt_m_gui_csa_flyThru') self.bg = backgroundGui.find('**/background') self.chatBubble = backgroundGui.find('**/chatBubble') self.chatBubble.setScale(6.5, 6.5, 7.3) self.chatBubble.setPos(0.32, 0, -0.78) self.bg.setScale(5.2) self.bg.setPos(0.14, 0, -0.6667) self.bg.reparentTo(aspect2d) self.chatBubble.reparentTo(aspect2d) self.frame = DirectFrame(geom=self.bg, relief=None, pos=(0.2, 0, -0.6667)) self.bg.wrtReparentTo(self.frame) self.gameTitleText = DirectLabel( parent=self.frame, text=TTLocalizer.CogdoExecutiveSuiteTitle, scale=TTLocalizer.MRPgameTitleText * 0.8, text_align=TextNode.ACenter, text_font=getSignFont(), text_fg=(1.0, 0.33, 0.33, 1.0), pos=TTLocalizer.MRgameTitleTextPos, relief=None) self.chatBubble.wrtReparentTo(self.frame) self.frame.hide() backgroundGui.removeNode() 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.clipPlane = self.toonHead.attachNewNode(PlaneNode('clip')) self.clipPlane.node().setPlane(Plane(0, 0, 1, 0)) self.clipPlane.setPos(0, 0, 2.45) self._toonDialogueSfx = loader.loadSfx( 'phase_3.5/audio/dial/AV_dog_long.ogg') self._camHelperNode = NodePath('CamHelperNode') self._camHelperNode.reparentTo(render) dialogue = TTLocalizer.CogdoExecutiveSuiteIntroMessage def start(): self.frame.show() base.setCellsAvailable( base.bottomCells + base.leftCells + base.rightCells, 0) def showShopOwner(): self._setCamTarget(self._shopOwner, -10, offset=Point3(0, 0, 5)) def end(): self._dialogueLabel.reparentTo(hidden) self.toonHead.reparentTo(hidden) self.frame.hide() base.setCellsAvailable( base.bottomCells + base.leftCells + base.rightCells, 1) self._stopUpdateTask() self._ival = Sequence( Func(start), Func(self.displayLine, dialogue), Func(showShopOwner), ParallelEndTogether( camera.posInterval(self.cameraMoveDuration, Point3(8, 0, 13), blendType='easeInOut'), camera.hprInterval(0.5, self._camHelperNode.getHpr(), blendType='easeInOut')), Wait(self.introDuration), Func(end)) self._startUpdateTask() return
def initIntervals(self): self.baseSpinDuration = 1.0 self.propellerSpinLerp = LerpFunctionInterval( self.propeller.setH, fromData=0.0, toData=360.0, duration=self.baseSpinDuration, name='%s.propellerSpinLerp-%s' % (self.__class__.__name__, self.toon.doId)) singleBlinkTime = Globals.Gameplay.TargetedWarningSingleBlinkTime blinkTime = Globals.Gameplay.TargetedWarningBlinkTime self.blinkLoop = Sequence( Wait(singleBlinkTime / 2.0), Func(self.setBackpackTexture, Globals.Gameplay.BackpackStates.Attacked), Wait(singleBlinkTime / 2.0), Func(self.setBackpackTexture, Globals.Gameplay.BackpackStates.Targeted), name='%s.blinkLoop-%s' % (self.__class__.__name__, self.toon.doId)) self.blinkWarningSeq = Sequence( Func(self.blinkLoop.loop), Wait(blinkTime), Func(self.blinkLoop.clearToInitial), name='%s.blinkWarningSeq-%s' % (self.__class__.__name__, self.toon.doId)) dur = Globals.Gameplay.BackpackRefuelDuration self.refuelSeq = Sequence( Func(self.setPropellerSpinRate, Globals.Gameplay.RefuelPropSpeed), Wait(dur), Func(self.returnBackpackToLastStateFunc), name='%s.refuelSeq-%s' % (self.__class__.__name__, self.toon.doId)) scale = self.redTapeRing.getScale() pulseTime = 1.0 self.pulseBubbleSeq = Parallel( Sequence( LerpFunctionInterval(self.redTapeRing.setScale, fromData=scale, toData=scale * 1.1, duration=pulseTime / 2.0, blendType='easeInOut'), LerpFunctionInterval(self.redTapeRing.setScale, fromData=scale * 1.1, toData=scale, duration=pulseTime / 2.0, blendType='easeInOut')), LerpHprInterval(self.redTapeRing, pulseTime, Vec3(360, 0, 0), startHpr=Vec3(0, 0, 0)), name='%s.pulseBubbleSeq-%s' % (self.__class__.__name__, self.toon.doId)) bouncePercent = 1.2 scaleTime = 0.5 scaleBounceTime = 0.25 self.popUpBubbleLerp = LerpScaleInterval(self.redTapeRing, scaleTime, scale * bouncePercent, startScale=0.0, blendType='easeInOut') self.popUpBubbleSeq = Sequence( Func(self.updateLerpStartScale, self.popUpBubbleLerp, self.redTapeRing), Func(self.redTapeRing.show), self.popUpBubbleLerp, LerpScaleInterval(self.redTapeRing, scaleBounceTime, scale, startScale=scale * bouncePercent, blendType='easeInOut'), Func(self.pulseBubbleSeq.loop), name='%s.popUpBubbleSeq-%s' % (self.__class__.__name__, self.toon.doId)) self.removeBubbleLerp = LerpScaleInterval(self.redTapeRing, scaleBounceTime, scale * bouncePercent, startScale=scale, blendType='easeInOut') self.removeBubbleSeq = Sequence( Func(self.pulseBubbleSeq.clearToInitial), Func(self.updateLerpStartScale, self.removeBubbleLerp, self.redTapeRing), self.removeBubbleLerp, LerpScaleInterval(self.redTapeRing, scaleTime, 0.0, startScale=scale * bouncePercent, blendType='easeInOut'), Func(self.redTapeRing.hide), name='%s.removeBubbleSeq-%s' % (self.__class__.__name__, self.toon.doId)) self.redTapeRing.setScale(0.0) self.deathInterval = Sequence( Parallel( LerpHprInterval(self.toon, 1.0, Vec3(720, 0, 0)), LerpFunctionInterval(self.toon.setScale, fromData=1.0, toData=0.1, duration=1.0)), Func(self.toon.stash), name='%s.deathInterval-%s' % (self.__class__.__name__, self.toon.doId)) self.spawnInterval = Sequence( Func(self.toon.stash), Func(self.resetToon), Wait(1.0), Func(self.toon.setAnimState, 'TeleportIn'), Func(self.toon.unstash), name='%s.spawnInterval-%s' % (self.__class__.__name__, self.toon.doId)) singleBlinkTime = Globals.Gameplay.InvulSingleBlinkTime blinkTime = Globals.Gameplay.InvulBlinkTime invulBuffTime = Globals.Gameplay.InvulBuffTime self.blinkBubbleLoop = Sequence( LerpFunctionInterval(self.redTapeRing.setAlphaScale, fromData=1.0, toData=0.0, duration=singleBlinkTime / 2.0, blendType='easeInOut'), LerpFunctionInterval(self.redTapeRing.setAlphaScale, fromData=0.0, toData=1.0, duration=singleBlinkTime / 2.0, blendType='easeInOut'), name='%s.blinkBubbleLoop-%s' % (self.__class__.__name__, self.toon.doId)) self.blinkBubbleSeq = Sequence( Wait(invulBuffTime - blinkTime), Func(self.blinkBubbleLoop.loop), Wait(blinkTime), Func(self.blinkBubbleLoop.finish), name='%s.blinkBubbleSeq-%s' % (self.__class__.__name__, self.toon.doId))
def _hideFlashMessage(self, duration = 0.0): if self.isDisabled(): pass self.flashTextInterval = Sequence(Wait(duration), LerpFunc(self.flashText.setAlphaScale, fromData=1.0, toData=0.0, duration=1.0), Func(self.flashText.stash)) self.flashTextInterval.start()
def sceneWait(self,time,hidetextbox = True): waitinterval = Wait(time) self.intervals.append(waitinterval) waitinterval.start() if hidetextbox: self.gameTextBox.hide()