def getFadeOutIval(self, t=0.5, finishIval=None, blendType='noBlend'): """ Create a sequence that lerps the color out, then parents the fade to hidden """ self.noTransitions() self.loadFade() parent = aspect2d if self.fadeModel else render2d transitionIval = Sequence(Func(self.fade.reparentTo, parent, DGG.FADE_SORT_INDEX), Func(self.fade.showThrough), # in case aspect2d is hidden for some reason self.lerpFunc(self.fade, t, self.alphaOn, # self.alphaOff, blendType=blendType ), name = self.fadeTaskName, ) if finishIval: transitionIval.append(finishIval) return transitionIval
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 pieThrow(self, avId, timestamp, heading, pos, power): toon = self.activity.getAvatar(avId) if toon is None: return 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) 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
def handleToonJoined(self, toonId): DistributedPartyTeamActivity.handleToonJoined(self, toonId) self.toonIdsToAnimIntervals[toonId] = None if toonId == base.localAvatar.doId: base.cr.playGame.getPlace().fsm.request("activity") # set camera to a 3rd person view of play area camera.wrtReparentTo(self.root) self.cameraMoveIval = LerpPosHprInterval( camera, 1.5, PartyGlobals.TugOfWarCameraPos, PartyGlobals.TugOfWarCameraInitialHpr, other=self.root, ) self.cameraMoveIval.start() self.localToonPosIndex = self.getIndex(base.localAvatar.doId, self.localToonTeam) self.notify.debug("posIndex: %d" %self.localToonPosIndex) toon = self.getAvatar(toonId) targetPos = self.dockPositions[self.localToonTeam][self.localToonPosIndex] # prevent toons from clipping through the dock by warping them to dock height if toon.getZ(self.root) < PartyGlobals.TugOfWarToonPositionZ: toon.setZ(self.root, PartyGlobals.TugOfWarToonPositionZ) targetH = fitDestAngle2Src(toon.getH(self.root), PartyGlobals.TugOfWarHeadings[self.localToonTeam]) travelVector = targetPos - toon.getPos(self.root) duration = travelVector.length() / 5.0 if self.toonIdsToAnimIntervals[toonId] is not None: self.toonIdsToAnimIntervals[toonId].finish() self.toonIdsToAnimIntervals[toonId] = Sequence( Func( toon.startPosHprBroadcast, 0.1 ), Func( toon.b_setAnimState, "run" ), LerpPosHprInterval( toon, duration, targetPos, VBase3( targetH, 0.0, 0.0 ), other=self.root ), Func( toon.stopPosHprBroadcast ), Func( toon.b_setAnimState, "neutral" ), ) self.toonIdsToAnimIntervals[toonId].start()
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 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() return
def handleToonExited(self, toonId): DistributedPartyTeamActivity.handleToonExited(self, toonId) # clean up local toon stuff if toonId == base.localAvatar.doId: self.cameraMoveIval.pause() # make toon jump off the dock if needed if toonId not in self.fallenToons: # finish any existing interval for that toon if toonId in self.toonIdsToAnimIntervals and \ self.toonIdsToAnimIntervals[toonId] is not None: self.toonIdsToAnimIntervals[toonId].finish() toon = self.getAvatar(toonId) # clamp targetHeading to minimize spin targetH = fitDestAngle2Src(toon.getH(self.root), 180.0) targetPos = self.hopOffPositions[self.getTeam(toonId)][ self.getIndex(toonId, self.getTeam(toonId))] hopOffAnim = Sequence( Func(toon.startPosHprBroadcast, 0.1), toon.hprInterval(0.2, VBase3(targetH, 0.0, 0.0), other=self.root), Func(toon.b_setAnimState, "jump", 1.0), Wait(0.4), PartyUtils.arcPosInterval(0.75, toon, targetPos, 5.0, self.root), Func(toon.stopPosHprBroadcast), # make sure toon ends up on the ground on remote clients Func(toon.sendCurrentPosition), Func(self.hopOffFinished, toonId), ) self.toonIdsToAnimIntervals[toonId] = hopOffAnim self._hopOffFinishedSV.set(False) self.toonIdsToAnimIntervals[toonId].start() # local toons not on the dock are put back into the walk state else: self._hopOffFinishedSV.set(True) del self.toonIdsToAnimIntervals[toonId]
def 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 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 onMessage(self, msg, *args): ''' Using Messenger objects any game component can broadcast messages which will become available to the active nodescript through this method. The msg parameter is the name of the message, while *args is a list of arguments provided by the sender. Each nodescript must first declare the list of messages for which it is interested to receive. The list is declared in the NodeScript.registerMessages method. ''' # When a sound has finished playing the sound_finished message is broadcasted. # We handle it here to get notified when the blah sound has finished and update the UI accordingly. if msg == 'sound_finished': print 'FINISHED' self.eventText.setFg((1.0, 0.0, 0.0, 0.0)) self.eventText.show() Sequence( LerpColorScaleInterval(self.eventText, 0.5, (1,1,1,1), (1,1,1,0)), LerpColorScaleInterval(self.eventText, 0.5, (1,1,1,0), (1,1,1,1)) ).start()
def getFadeInIval(self, t=0.5, finishIval=None, blendType='noBlend'): """ Returns an interval without starting it. This is particularly useful in cutscenes, so when the cutsceneIval is escaped out of we can finish the fade immediately """ #self.noTransitions() masad: this creates a one frame pop, is it necessary? self.loadFade() parent = aspect2d if self.fadeModel else render2d transitionIval = Sequence(Func(self.fade.reparentTo, parent, DGG.FADE_SORT_INDEX), Func(self.fade.showThrough), # in case aspect2d is hidden for some reason self.lerpFunc(self.fade, t, self.alphaOff, # self.alphaOn, blendType=blendType ), Func(self.fade.detachNode), name = self.fadeTaskName, ) if finishIval: transitionIval.append(finishIval) return transitionIval
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 toonId in self.toonIdsToAnimIntervals 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()
def getRunToStartPositionIval(self): targetH = self.locator.getH() travelVec = self.position - self.toon.getPos(self.activity.root) duration = travelVec.length() / 9.778 startH = 0.0 if travelVec.getY() < 0.0: startH = 180.0 return Sequence( Func(self.toon.startPosHprBroadcast, 0.1), Func(self.toon.b_setAnimState, 'run'), Parallel( self.toon.hprInterval(0.5, VBase3(startH, 0.0, 0.0), other=self.activity.root), self.toon.posInterval(duration, self.position, other=self.activity.root)), Func(self.toon.b_setAnimState, 'neutral'), self.toon.hprInterval(0.25, VBase3(targetH, 0.0, 0.0), other=self.activity.root), Func(self.toon.stopPosHprBroadcast))
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 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 irisOut(self, t=0.5, finishIval=None, blendType='noBlend'): """ Play an iris out transition over t seconds. Places a polygon on the aspect2d plane then lerps the scale of the iris down so it looks like we iris out. When the scale lerp is finished, it leaves the iris polygon covering the aspect2d plane until you irisIn or call noIris. """ self.noTransitions() self.loadIris() self.loadFade() # we need this to cover up the hole. if (t == 0): self.iris.detachNode() self.fadeOut(0) fut = AsyncFuture() fut.setResult(None) return fut else: self.iris.reparentTo(aspect2d, DGG.FADE_SORT_INDEX) scale = 0.18 * max(base.a2dRight, base.a2dTop) self.transitionIval = Sequence( LerpScaleInterval(self.iris, t, scale=0.01, startScale=scale, blendType=blendType), Func(self.iris.detachNode), # Use the fade to cover up the hole that the iris would leave Func(self.fadeOut, 0), Func(self.__finishTransition), name=self.irisTaskName, ) self.__transitionFuture = AsyncFuture() if finishIval: self.transitionIval.append(finishIval) self.transitionIval.start() return self.__transitionFuture
def letterboxOff(self, t=0.25, finishIval=None, blendType='noBlend'): """ Move black bars away over t seconds. """ self.noLetterbox() self.loadLetterbox() self.letterbox.unstash() if (t == 0): self.letterbox.stash() fut = AsyncFuture() fut.setResult(None) return fut else: self.__letterboxFuture = AsyncFuture() self.letterboxIval = Sequence( Parallel( LerpPosInterval( self.letterboxBottom, t, pos=Vec3(0, 0, -1.2), # startPos = Vec3(0, 0, -1), blendType=blendType), LerpPosInterval( self.letterboxTop, t, pos=Vec3(0, 0, 1), # startPos = Vec3(0, 0, 0.8), blendType=blendType), ), Func(self.letterbox.stash), Func(self.__finishLetterbox), Func(messenger.send, 'letterboxOff'), name=self.letterboxTaskName, ) if finishIval: self.letterboxIval.append(finishIval) self.letterboxIval.start() return self.__letterboxFuture
def approach(self, collEntry): if not self.interactionAllowed(localAvatar.doId): return None if not self.disk: self.createInteractionDisk() if self.proximityText: if not self.useLabel: self.loadUseLabel(self.proximityText) if self.fader: self.fader.pause() fadeIn = LerpFunctionInterval(self.useLabel.setAlphaScale, fromData=0, toData=1, duration=0.5) self.fader = Sequence(Func(self.useLabel.show), fadeIn) self.fader.start() self.disk.show() self.accept(USE_KEY_EVENT, self.handleUseKey)
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 makeBlendIntervalForBlendingToThisAnimation(self, newTransitionAnimation, transitionDuration): currentlyPlayingAnimationsAndEffectsAndDesiredEffects = [] for animationName in self.skeletonAnimationNames: if animationName == newTransitionAnimation: continue controlEffect = self.getControlEffect(animationName) if controlEffect > 0.0: currentlyPlayingAnimationsAndEffectsAndDesiredEffects.append((animationName, controlEffect, 0.0)) continue currentlyPlayingAnimationsAndEffectsAndDesiredEffects.append((newTransitionAnimation, 0.0, 1.0)) if self.blendInterval: self.blendInterval.pause() self.blendInterval.clearToInitial() self.blendInterval = Sequence(name = '%s_%d.blendInterval' % (self.getName(), self.uniqueCounter)) par = Parallel() for (animationName, fromData, toData) in currentlyPlayingAnimationsAndEffectsAndDesiredEffects: par.append(LerpFunctionInterval(self.adjustEffect, duration = transitionDuration, fromData = fromData, toData = toData, extraArgs = [ animationName])) self.blendInterval.append(par)
def __init__(self, name, parent, pos=(0.0, 0.0, -0.5), scale=0.089999999999999997, color=(1.0, 1.0, 0, 1), sfx=None): self.color = color self._displaySfx = sfx textNode = TextNode('messageLabel.' + name) textNode.setTextColor(self.color) textNode.setAlign(TextNode.ACenter) textNode.setFont(ToontownGlobals.getSignFont()) textNode.setShadow(0.059999999999999998, 0.059999999999999998) textNode.setShadowColor(0.5, 0.5, 0.5, 1.0) self.pos = pos self.scale = scale self.messageLabel = parent.attachNewNode(textNode) self.messageLabel.setPos(self.pos) self.messageLabel.setScale(self.scale) self.messageLabel.stash() self.transitionInterval = Sequence(name='%s.transitionInterval' % self.__class__.__name__)
def loadIntervals(self): self.updateIdealRateInterval = Sequence() self.updateIdealRateInterval.append(Wait(PartyGlobals.TugOfWarTargetRateList[0][0])) for i in range(1, len(PartyGlobals.TugOfWarTargetRateList)): duration = PartyGlobals.TugOfWarTargetRateList[i][0] idealRate = PartyGlobals.TugOfWarTargetRateList[i][1] self.updateIdealRateInterval.append(Func(self.setIdealRate, idealRate)) if i == len(PartyGlobals.TugOfWarTargetRateList) - 1: self.updateIdealRateInterval.append(Func(setattr, self, 'allOutMode', True)) else: self.updateIdealRateInterval.append(Wait(duration)) self.updateKeyPressRateInterval = Sequence(Wait(PartyGlobals.TugOfWarKeyPressUpdateRate), Func(self.updateKeyPressRate)) self.reportToServerInterval = Sequence(Wait(PartyGlobals.TugOfWarKeyPressReportRate), Func(self.reportToServer)) self.setupInterval = Parallel() self.globalSetupInterval = Sequence(Wait(PartyGlobals.TugOfWarReadyDuration + PartyGlobals.TugOfWarGoDuration), Func(self.tightenRopes)) self.localSetupInterval = Sequence(Func(self.setStatus, TTLocalizer.PartyTugOfWarReady), Func(self.showStatus), Wait(PartyGlobals.TugOfWarReadyDuration), Func(base.playSfx, self.whistleSound), Func(self.setStatus, TTLocalizer.PartyTugOfWarGo), Wait(PartyGlobals.TugOfWarGoDuration), Func(self.enableKeys), Func(self.hideStatus), Func(self.updateIdealRateInterval.start), Func(self.updateKeyPressRateInterval.loop), Func(self.reportToServerInterval.loop)) self.splashInterval = Sequence(Func(base.playSfx, self.splashSound), Func(self.splash.play))
def __showSplat(self, position, direction, hot = False): if self.kaboomTrack is not None and self.kaboomTrack.isPlaying(): self.kaboomTrack.finish() self.clearHitInterval() splatName = 'splat-creampie' self.splat = globalPropPool.getProp(splatName) self.splat.setBillboardPointEye() self.splat.reparentTo(render) self.splat.setPos(self.root, position) self.splat.setAlphaScale(1.0) if not direction == 1.0: self.splat.setColorScale(PartyGlobals.CogActivitySplatColors[0]) if self.currentFacing > 0.0: facing = 'HitFront' else: facing = 'HitBack' else: self.splat.setColorScale(PartyGlobals.CogActivitySplatColors[1]) if self.currentFacing > 0.0: facing = 'HitBack' else: facing = 'HitFront' if hot: targetscale = 0.75 part = 'head' else: targetscale = 0.5 part = 'body' def setSplatAlpha(amount): self.splat.setAlphaScale(amount) self.hitInterval = Sequence(ActorInterval(self.actor, part + facing, loop=0), Func(self.actor.loop, 'idle')) self.hitInterval.start() self.kaboomTrack = Parallel(SoundInterval(self.pieHitSound, volume=1.0, node=self.actor, 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() return
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()
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 enterDanceMove(self, anim=""): """ Changes the animation state of the toon to dancing. Typically this state happens when the toon is not moving in the dance floor. Parameters: anim is the animation to be set. if it's none, then it's set to the previous dance move or to the default dance move """ if self.lastAnim is None and anim == "": self.toon.loop("victory", fromFrame = 98, toFrame = 122) else: if anim == "": anim = self.lastAnim if anim in DanceReverseLoopAnims: self.danceMoveSequence = Sequence(self.toon.actorInterval(anim, loop = 0), self.toon.actorInterval(anim, loop = 0, playRate = -1.0) ) self.danceMoveSequence.loop() else: self.toon.loop(anim) self.lastAnim = anim
def __init__(self, type, index, model, collSolid, motionPath = None, motionPattern = None, blendMotion = True, instanceModel = True): self.type = type self.index = index name = 'CogdoFlyingObstacle-%s-%i' % (self.type, self.index) if instanceModel: self.model = NodePath(name) model.instanceTo(self.model) else: self.model = model self.model.setName(name) self.currentT = 0.0 self.direction = 1.0 self.collNode = None self._initCollisions(name, collSolid) self.motionPath = motionPath self.motionPattern = motionPattern self.motionSequence = None if blendMotion: blendType = 'easeInOut' else: blendType = 'noBlend' if motionPath is not None: def moveObstacle(value): self.motionPath.goTo(self.model, value) self.motionPath = Mopath.Mopath(name='obstacle-%i' % self.index) self.motionPath.loadNodePath(motionPath) dur = self.motionPath.getMaxT() self.motionSequence = Sequence(name='%s.obstacle-%i-motionSequence' % (self.__class__.__name__, self.index)) movePart1 = LerpFunc(moveObstacle, fromData=0.0, toData=self.motionPath.getMaxT(), duration=dur, blendType=blendType) self.motionSequence.append(movePart1) if self.motionPattern == CogdoFlyingObstacle.MotionTypes.BackForth: movePart2 = LerpFunc(moveObstacle, fromData=self.motionPath.getMaxT(), toData=0.0, duration=dur, blendType=blendType) self.motionSequence.append(movePart2) return
def showHitScore(self, number, scale = 1): if number <= 0: return if self.hpText: self.hideHitScore() self.HpTextGenerator.setFont(ToontownGlobals.getSignFont()) if number < 0: self.HpTextGenerator.setText(str(number)) else: self.HpTextGenerator.setText('+' + str(number)) self.HpTextGenerator.clearShadow() self.HpTextGenerator.setAlign(TextNode.ACenter) r = 1 g = 1 b = 0 a = 1 self.HpTextGenerator.setTextColor(r, g, b, a) self.hpTextNode = self.HpTextGenerator.generate() self.hpText = render.attachNewNode(self.hpTextNode) self.hpText.setScale(scale) self.hpText.setBillboardPointEye() self.hpText.setBin('fixed', 100) self.hpText.setPos(self.root, 0, 0, self.height / 2) Sequence(self.hpText.posInterval(0.25, Point3(self.root.getX(render), self.root.getY(render), self.root.getZ(render) + self.height + 1.0), blendType='easeOut'), Wait(0.25), self.hpText.colorInterval(0.1, Vec4(r, g, b, 0)), Func(self.hideHitScore)).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 poofBean(self, bean, beanAnim): if bean == None: self.notify.warning( 'poofBean, returning immediately as bean is None') return if bean.isEmpty(): self.notify.warning( 'poofBean, returning immediately as bean is empty') return currentAlpha = bean.getColorScale()[3] currentScale = bean.getScale() poofAnim = Sequence( Parallel( LerpFunc(bean.setAlphaScale, fromData=currentAlpha, toData=0.0, duration=0.25), LerpFunc(bean.setScale, fromData=currentScale, toData=currentScale * 5.0, duration=0.25)), Func(bean.stash), Func(beanAnim.finish), Func(bean.setAlphaScale, currentAlpha), Func(bean.setScale, currentScale)) poofAnim.start()