def JogadorAtaque(self, JogadorAtq, JogadorDef): if not self.BatalhaIniciada: self.BatalhaIniciada = True cartaAtq = b.cartas[JogadorAtq.carta] cartaDef = b.cartas[JogadorDef.carta] Sequence( cartaAtq.objeto3D.actorInterval('stand_out'), cartaAtq.objeto3D.actorInterval('atack_in'), cartaAtq.objeto3D.actorInterval('atack_base'), #cartaDef.objeto3D.actorInterval('die_in'), cartaDef.objeto3D.actorInterval('die_in'), cartaDef.objeto3D.actorInterval('die_base'), #Func(cartaDef.die), cartaAtq.objeto3D.actorInterval('stand_in'), cartaAtq.objeto3D.actorInterval('stand_base'), #Func(display.AtulizaDisplayPartida, b.jogador[self.JogadorInicial].nome + ' venceu a partida.'), Func(JogadorAtq.IncluiPontuacao, 10), Func(JogadorDef.RetiraPontuacao, 5), Func(self.AtualizaInfoJogador), Func(self.dlgbox,'Retire da mesa as cartas da batalha anterior!',self.NovaBatalha) ).start()
def fadeInCube(self, duration=2.5): """ spawn cube from the top to the floor """ self.setAnimated(True) x1, y1 = self.cube.getPythonTag("TilePos") # animate the cube, once finished clear the animation tag self.cube.setZ(render, 15) self.cube.wrtReparentTo(render) print("Starting fade in sequence") Sequence( LerpPosInterval(self.cube, duration, (x1, y1, 0.6), blendType="easeOut"), Func(self.setAnimated, False)).start()
def irisIn(self, t=0.5, finishIval=None): self.noTransitions() self.loadIris() if t == 0: self.iris.detachNode() else: self.iris.reparentTo(aspect2d, FADE_SORT_INDEX) self.transitionIval = Sequence(LerpScaleInterval(self.iris, t, scale=0.18, startScale=0.01), Func(self.iris.detachNode), name=self.irisTaskName) if finishIval: self.transitionIval.append(finishIval) self.transitionIval.start()
def _hideFlashMessage(self, duration=0.0): if self.isDisabled(): assert self.notify.debug( "_hideFlashMessage we're disabled, but still hiding self.flashText" ) # return 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 __init__(self, nome, ataque, defesa, classe, pattern, egg, tamanho, ativo): self.nome = nome self.ataque = ataque self.defesa = defesa self.classe = classe self.pattern = pattern self.egg = egg self.ativo = ativo self.tamanho = tamanho #self.pattern3D = render.attachNewNode(PandaNode("floor")) self.pattern3D = loader.loadModel('yup-axis') self.pattern3D.setScale(0.01) self.pattern3D.setBin("fixed", 0) #Cria o OBjeto 3D self.objeto3D = Actor.Actor( "Eggs//" + egg, { "atack": "Eggs//" + egg + "-atack_base", "atack_out": "Eggs//" + egg + "-atack_out", "atack_in": "Eggs//" + egg + "-atack_in", "die_base": "Eggs//" + egg + "-die_base", "die_in": "Eggs//" + egg + "-die_in", "stand_base": "Eggs//" + egg + "-stand_base", "stand_in": "Eggs//" + egg + "-stand_in", "stand_out": "Eggs//" + egg + "-stand_out" }) self.objeto3D.reparentTo(render) #self.objeto3D.setScale(tamanho) self.objeto3D.setBin("fixed", 0) #animacao self.objeto3D.attack = Sequence( self.objeto3D.actorInterval('stand_out'), self.objeto3D.actorInterval('atack_in'), self.objeto3D.actorInterval('atack_base')) self.objeto3D.stand_base = Sequence( self.objeto3D.actorInterval('stand_base', )) self.objeto3D.stand = Sequence( self.objeto3D.actorInterval('stand_in'), self.objeto3D.actorInterval('stand_base'), Func(self.stand)) self.objeto3D.die = Sequence(self.objeto3D.actorInterval('die_in'))
def handleToonExited(self, toonId): DistributedPartyTeamActivity.handleToonExited(self, toonId) if toonId == base.localAvatar.doId: self.cameraMoveIval.pause() if toonId not in self.fallenToons: if toonId in self.toonIdsToAnimIntervals and self.toonIdsToAnimIntervals[toonId] is not None: self.toonIdsToAnimIntervals[toonId].finish() toon = self.getAvatar(toonId) 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), Func(toon.sendCurrentPosition), Func(self.hopOffFinished, toonId)) self.toonIdsToAnimIntervals[toonId] = hopOffAnim self._hopOffFinishedSV.set(False) self.toonIdsToAnimIntervals[toonId].start() else: self._hopOffFinishedSV.set(True) del self.toonIdsToAnimIntervals[toonId]
def set_stage(self, stage_nr): print(("Setting stage", stage_nr)) Sequence( LerpColorScaleInterval(self.text_stage_np, 0.4, Vec4(1, 1, 1, 0), Vec4(1), blendType="easeInOut"), Func(lambda *args: self.text_stage.set_text("Stage " + str(stage_nr ))), LerpColorScaleInterval(self.text_stage_np, 0.4, Vec4(1), Vec4(1, 1, 1, 0), blendType="easeInOut"), ).start()
def deleteItem(self,key,fadeout = 0): '''Delete an item from StoryView''' if not fadeout: self.itemEntries.pop(key) node = self._sceneItems.pop(key) node.removeNode() else: #if it has a fade-out effect then add fade-out intervals self.itemEntries.pop(key) item = self._sceneItems.pop(key) item.setName('removing_'+item.getName()) color = item.getColor() sequcnce = Sequence(LerpColorInterval(item, fadeout, (color[0],color[1],color[2],0), color), Func(self.__deletefromScene,item), ) self._intervals.append(sequcnce) sequcnce.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.ballRoot.setX, fromData = self.ballRoot.getX(), toData = toPos.getX(), duration = .1), LerpFunc(self.ballRoot.setY, fromData = self.ballRoot.getY(), toData = toPos.getY(), duration = .1), LerpFunc(self.ballRoot.setZ, fromData = self.ballRoot.getZ(), toData = self.ballRoot.getZ() - .9, duration = .2)), Wait(1), Func(self.start)).start()
def looseGame(self, holeNP): toPos = holeNP.node().getShapePos(0) self.stopGame() Sequence( Parallel( LerpFunc(self.ballNP.setX, fromData=self.ballNP.getX(), toData=toPos.getX(), duration=.1), LerpFunc(self.ballNP.setY, fromData=self.ballNP.getY(), toData=toPos.getY(), duration=.1), LerpFunc(self.ballNP.setZ, fromData=self.ballNP.getZ(), toData=self.ballNP.getZ() - .9, duration=.2)), Wait(1), Func(self.startGame)).start()
def loseGame(self, entry): toPos = entry.getInteriorPoint(render) taskMgr.remove("rollTask") Sequence( Parallel( LerpFunc(self.ballRoot.setX, fromData=self.ballRoot.getX(), toData=toPos.getX(), duration=0.1), LerpFunc(self.ballRoot.setY, fromData=self.ballRoot.getY(), toData=toPos.getY(), duration=0.1), LerpFunc(self.ballRoot.setZ, fromData=self.ballRoot.getZ(), toData=self.ballRoot.getZ() - .9, duration=0.2)), Wait(1), Func(self.start)).start()
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 pieThrow(self, avId, timestamp, heading, pos, power): toon = self.activity.getAvatar(avId) if toon is None: return else: tossTrack, pieTrack, flyPie = self.getTossPieInterval( toon, pos[0], pos[1], pos[2], heading, 0, 0, power) if avId == base.localAvatar.doId: flyPie.setTag('throwerId', str(avId)) collSphere = CollisionSphere(0, 0, 0, 0.5) collSphere.setTangible(0) name = 'PieSphere-%d' % avId collSphereName = self.activity.uniqueName(name) collNode = CollisionNode(collSphereName) collNode.setFromCollideMask(ToontownGlobals.PieBitmask) collNode.addSolid(collSphere) collNP = flyPie.attachNewNode(collNode) base.cTrav.addCollider(collNP, self.pieHandler) self.toonPieEventNames[collNP] = 'pieHit-' + collSphereName self.accept(self.toonPieEventNames[collNP], self.handlePieCollision) else: player = self.players.get(avId) if player is not None: player.faceForward() def matchRunningAnim(toon=toon): toon.playingAnim = None toon.setSpeed(toon.forwardSpeed, toon.rotateSpeed) return newTossTrack = Sequence(tossTrack, Func(matchRunningAnim)) pieTrack = Parallel(newTossTrack, pieTrack, name='PartyCogActivity.pieTrack-%d-%s' % (avId, timestamp)) elapsedTime = globalClockDelta.localElapsedTime(timestamp) if elapsedTime < 16.0 / 24.0: elapsedTime = 16.0 / 24.0 pieTrack.start(elapsedTime) self.pieIvals.append(pieTrack) self.toonPieTracks[avId] = pieTrack return
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 throwTeamInWater(self, losingTeam): self.notify.debug("throwTeamInWater( %s )" %PartyGlobals.TeamActivityTeams.getString(losingTeam)) splashSet = False for toonId in self.toonIds[losingTeam]: # throw toon in water self.fallenToons.append(toonId) toon = self.getAvatar(toonId) # getting a a crash of popping from empty list #fallenPosIndex = self.unusedFallenPositionsIndices.pop(0) fallenPosIndex = self.toonIds[losingTeam].index(toonId) if (fallenPosIndex < 0) or (fallenPosIndex >= 4): fallenPosIndex = 0 newPos = self.fallenPositions[fallenPosIndex] # animate the toons falling into the water if self.toonIdsToAnimIntervals[toonId] is not None: if self.toonIdsToAnimIntervals[toonId].isPlaying(): self.toonIdsToAnimIntervals[toonId].finish() # Fall into water if toon: parallel = Parallel( ActorInterval(actor=toon, animName='slip-forward', duration=2.0), LerpPosInterval(toon, duration=2.0, pos=newPos, other=self.root), ) else: self.notify.warning("toon %d is none, skipping slip-forward" % toonId) parallel = Parallel() # only setup splash for the first toon if not splashSet: splashSet = True parallel.append(self.splashInterval) if toon: self.toonIdsToAnimIntervals[toonId] = Sequence( parallel, Func(toon.loop, 'neutral'), ) else: self.notify.warning("toon %d is none, skipping toon.loop(neutral)" % toonId) self.toonIdsToAnimIntervals[toonId] = parallel self.toonIdsToAnimIntervals[toonId].start()
def throwTeamInWater(self, losingTeam): self.notify.debug('throwTeamInWater( %s )' % PartyGlobals.TeamActivityTeams.getString(losingTeam)) splashSet = False for toonId in self.toonIds[losingTeam]: self.fallenToons.append(toonId) toon = self.getAvatar(toonId) fallenPosIndex = self.toonIds[losingTeam].index(toonId) if fallenPosIndex < 0 or fallenPosIndex >= 4: fallenPosIndex = 0 newPos = self.fallenPositions[fallenPosIndex] if self.toonIdsToAnimIntervals.has_key( toonId ) and self.toonIdsToAnimIntervals[toonId] is not None: if self.toonIdsToAnimIntervals[toonId].isPlaying(): self.toonIdsToAnimIntervals[toonId].finish() if toon: parallel = Parallel( ActorInterval(actor=toon, animName='slip-forward', duration=2.0), LerpPosInterval(toon, duration=2.0, pos=newPos, other=self.root)) else: self.notify.warning('toon %d is none, skipping slip-forward' % toonId) parallel = Parallel() if not splashSet: splashSet = True parallel.append(self.splashInterval) if toon: self.toonIdsToAnimIntervals[toonId] = Sequence( parallel, Func(toon.loop, 'neutral')) else: self.notify.warning( 'toon %d is none, skipping toon.loop(neutral)' % toonId) self.toonIdsToAnimIntervals[toonId] = parallel self.toonIdsToAnimIntervals[toonId].start() return
def moveActor(self, x, y, z, rotation, isMoving, heartbeat): if isMoving: if not self._is_moving: self._is_moving = True self._character.loop("run") moveInterval = self._character.posInterval(heartbeat, Point3(x, y, z)) rotationInterval = self._character.hprInterval(heartbeat, Point3(rotation, 0, 0)) sequence = Sequence(Parallel(rotationInterval, moveInterval)) moveIntervalf = self._floater.posInterval(heartbeat, Point3(x, y, z)) rotationIntervalf = self._floater.hprInterval(heartbeat, Point3(rotation, 0, 0)) sequencef = Sequence(Parallel(rotationIntervalf, moveIntervalf)) if not isMoving: self._is_moving = False standInterval = Func(self.idle) sequence.append(standInterval) sequence.start() sequencef.start()
def __doDanceMove(self, pattern): self.notify.debug('Dance move! %s' % pattern) anim = self.dancePatternToAnims.get(pattern) if anim: self.__updateLocalToonState(ToonDancingStates.DanceMove, anim) self.gui.setColor(0, 1, 0) self.gui.showText(DanceAnimToName.get(anim, anim)) self.finishRules() if pattern not in self.localPatternsMatched: camNode = NodePath(self.uniqueName('danceCamNode')) camNode.reparentTo(base.localAvatar) camNode.lookAt(camera) camNode.setHpr(camNode.getH(), 0, 0) node2 = NodePath('tempCamNode') node2.reparentTo(camNode) node2.setPos(Point3(0, 15, 10)) node2.lookAt(camNode) h = node2.getH() * (base.camera.getH(camNode) / abs(base.camera.getH(camNode))) node2.removeNode del node2 hpr = base.camera.getHpr() pos = base.camera.getPos() camParent = base.camera.getParent() base.camera.wrtReparentTo(camNode) self.localToonDanceSequence = Sequence( Func(self.__localDisableControls), Parallel( base.camera.posInterval(0.5, Point3(0, 15, 10), blendType='easeIn'), base.camera.hprInterval(0.5, Point3(h, -20, 0), blendType='easeIn')), camNode.hprInterval(4.0, Point3(camNode.getH() - 360, 0, 0)), Func(base.camera.wrtReparentTo, camParent), Func(camNode.removeNode), Parallel( base.camera.posInterval(0.5, pos, blendType='easeOut'), base.camera.hprInterval(0.5, hpr, blendType='easeOut')), Func(self.__localEnableControls)) else: self.localToonDanceSequence = Sequence( Func(self.__localDisableControls), Wait(2.0), Func(self.__localEnableControls)) self.localToonDanceSequence.start() self.localPatternsMatched.append(pattern)
def stop_audio(audio, fadeout=0): '''stops an AudioSound, instant or fade-out''' if _fadeinIntervalTable.has_key( audio ): #If the audio is currently on fade-in, then stop and remove the fade-in interval _fadeinIntervalTable[audio].pause() _intervals.remove(_fadeinIntervalTable[audio]) del _fadeinIntervalTable[audio] if not fadeout: audio.stop() else: sequence = Sequence( LerpFunc(_lerpAdjust, duration=fadeout, fromData=audio.getVolume(), toData=0, extraArgs=[audio], blendType='easeIn'), Func(audio.stop)) sequence.start() #reduce volume and stop the sound
def contTunnel(self): self.tunnel = self.tunnel[1:] + self.tunnel[0:1] self.tunnel[0].setZ(0) self.tunnel[0].reparentTo(render) self.tunnel[0].setScale(.455, .455, .605) self.tunnel[3].reparentTo(self.tunnel[2]) self.tunnel[3].setZ(-TUNNEL_SEGMENT_LENGTH) self.tunnel[3].setScale(1) self.tunnelMove = Sequence( LerpFunc(self.tunnel[0].setZ, duration=TUNNEL_TIME, fromData=0, toData=TUNNEL_SEGMENT_LENGTH * .305), Func(self.contTunnel)) self.tunnelMove.start()
def handleToonJoined(self, toonId): DistributedPartyTeamActivity.handleToonJoined(self, toonId) self.toonIdsToAnimIntervals[toonId] = None if toonId == base.localAvatar.doId: base.cr.playGame.getPlace().fsm.request('activity') 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] 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()
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 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 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 irisIn(self, t=0.5, finishIval=None): """ Play an iris in transition over t seconds. Places a polygon on the aspect2d plane then lerps the scale of the iris polygon up so it looks like we iris in. When the scale lerp is finished, it parents the iris polygon to hidden. """ self.noTransitions() self.loadIris() if (t == 0): self.iris.detachNode() else: self.iris.reparentTo(aspect2d, FADE_SORT_INDEX) self.transitionIval = Sequence( LerpScaleInterval(self.iris, t, scale=0.18, startScale=0.01), Func(self.iris.detachNode), name=self.irisTaskName, ) if finishIval: self.transitionIval.append(finishIval) self.transitionIval.start()
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 letterboxOn(self, t=0.25, finishIval=None, blendType='noBlend'): """ Move black bars in over t seconds. """ self.noLetterbox() self.loadLetterbox() self.letterbox.unstash() if (t == 0): self.letterboxBottom.setPos(0, 0, -1) self.letterboxTop.setPos(0, 0, 0.8) fut = AsyncFuture() fut.setResult(None) return fut else: self.__letterboxFuture = AsyncFuture() self.letterboxIval = Sequence( Parallel( LerpPosInterval( self.letterboxBottom, t, pos=Vec3(0, 0, -1), #startPos = Vec3(0, 0, -1.2), blendType=blendType), LerpPosInterval( self.letterboxTop, t, pos=Vec3(0, 0, 0.8), # startPos = Vec3(0, 0, 1), blendType=blendType), ), Func(self.__finishLetterbox), name=self.letterboxTaskName, ) if finishIval: self.letterboxIval.append(finishIval) self.letterboxIval.start() return self.__letterboxFuture
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 updateToonPositions(self, offset): # Since the timer expires locally, we may still get a few # messages from the AI that were on the wire when we left # the play state, just ignore it if self.activityFSM.state != "Active": return # adjust the camera angle if self.isLocalToonPlaying: camera.lookAt(self.root, offset, 0.0, PartyGlobals.TugOfWarCameraLookAtHeightOffset) # this client sets the position of all toons playing for toonId in self.getToonIdsAsList(): if hasattr(self,"fallenToons") and \ toonId not in self.fallenToons: toon = self.getAvatar(toonId) if toon is not None: origPos = self.toonIdsToStartPositions[toonId] curPos = toon.getPos(self.root) newPos = Point3(origPos[0] + offset, curPos[1], curPos[2]) # finish any existing animation interval if self.toonIdsToAnimIntervals[toonId] != None: if self.toonIdsToAnimIntervals[toonId].isPlaying(): self.toonIdsToAnimIntervals[toonId].finish() self.checkIfFallen(toonId) if toonId not in self.fallenToons: self.toonIdsToAnimIntervals[toonId] = Sequence( LerpPosInterval( toon, duration=PartyGlobals. TugOfWarKeyPressReportRate, pos=newPos, other=self.root, ), Func(self.checkIfFallen, toonId)) self.toonIdsToAnimIntervals[toonId].start()