def setSwingInfo(self, power, angle, sequenceNum): 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 buttonInAnimation(self): logo = self.logo.posInterval(.5, Point3(0, 0, .5), blendType='easeInOut') play = self.PlayButton.posInterval(.2, Point3(PlayBtnPos), blendType='easeInOut') opt = self.OptionsButton.posInterval(.2, Point3(OptionsBtnPos), blendType='easeInOut') quit = self.QuitButton.posInterval(.2, Point3(QuitBtnPos), blendType='easeInOut') discord = self.NewsButton.posInterval(.2, Point3(DiscordBtnPos), blendType='easeInOut') credits = self.CreditsButton.posInterval(.2, Point3(CreditsBtnPos), blendType='easeInOut') Sequence(Func(logo.start), Wait(0.1), Func(play.start), Wait(0.1), Func(opt.start), Func(discord.start), Func(credits.start), Func(quit.start)).start()
def onSetAction(self, action): self.model.show() self.model.setPos(self.ModelOrigin) self.model.setHpr(self.ModelAngles) self.model.setLightOff() self.avatar.doingActivity = False if action == self.StateAttack: self.avatar.doingActivity = True joint = self.model.find('**/joint_toSpray') def positionAndOrientSpray(): self.sprayMdl.setPos(joint.getPos(render)) self.sprayMdl.setHpr(joint.getHpr(render)) self.setAnimTrack(Parallel( self.getAnimationTrack('watercooler', fullBody=False), Sequence( Wait(1.01), Func(self.model.show), LerpScaleInterval(self.model, 0.5, Point3(1.15, 1.15, 1.15)), Wait(1.6), Func(self.sprayMdl.show), Func(self.sprayMdl.reparentTo, render), Func(positionAndOrientSpray), LerpScaleInterval(self.sprayMdl, duration=0.3, scale=(1.0, 15.0, 1.0), startScale=(1.0, 1.0, 1.0)), Func(self.sprayMdl.hide), Func(self.sprayMdl.reparentTo, hidden)), Sequence(Wait(1.1), SoundInterval(self.coolerAppearSfx, duration=1.4722), Wait(0.4), SoundInterval(self.sprayOnlySfx, duration=2.313))), startNow=True)
def startDrop(self, entity): if entity and self.getLocation(): endPos = self.getLocation() startPos = Point3(endPos.getX(), endPos.getY(), endPos.getZ() + 20) entity.setPos(startPos.getX(), startPos.getY() + 2, startPos.getZ()) entity.find('**/DropMdl').setScale(5) entity.setP(90) entity.headsUp(self.avatar) entity.setH(entity.getH() - 180) entity.node().setBounds(OmniBoundingVolume()) entity.node().setFinal(1) self.buildCollisions(entity) objectTrack = Sequence() animProp = LerpPosInterval(entity, self.fallDuration, endPos, startPos=startPos) bounceProp = Effects.createZBounce(entity, 2, endPos, 0.5, 1.5) objAnimShrink = Sequence(Func(entity.setP, 90), Wait(0.5), Func(entity.reparentTo, render), animProp, bounceProp) objectTrack.append(objAnimShrink) dropShadow = CIGlobals.makeDropShadow(1.0) dropShadow.reparentTo(hidden) dropShadow.setPos(endPos) shadowTrack = Sequence( Func(dropShadow.reparentTo, render), LerpScaleInterval(dropShadow, self.fallDuration + 0.1, (2, 2, 2), startScale=Point3(0.01, 0.01, 0.01)), Wait(0.8), Func(dropShadow.removeNode)) Parallel( Sequence(Wait(self.fallDuration), Func(self.completeDrop), Wait(4), Func(self.clearEntity, entity)), objectTrack, shadowTrack).start() self.dropLoc = None
def enterCountdown(self): base.localAvatar.chatInput.disableKeyboardShortcuts() base.localAvatar.disableChatInput() base.setBackgroundColor(CIGlobals.DefaultBackgroundColor) base.render.show() self.playMinigameMusic() self.countdownLbl = OnscreenText(text="", fg=(1, 1, 1, 1), font=CIGlobals.getMinnieFont(), scale=0.1) self.countdownTrack = Sequence(Func(self.countdownLbl.setText, "5"), Wait(1.0), Func(self.countdownLbl.setText, "4"), Wait(1.0), Func(self.countdownLbl.setText, "3"), Wait(1.0), Func(self.countdownLbl.setText, "2"), Wait(1.0), Func(self.countdownLbl.setText, "1"), Wait(1.0), Func(self.fsm.request, "play")) self.countdownTrack.start() self.firstPerson.start() self.firstPerson.disableMouse()
def slipAndSlideOnThisBananaPeelHaHaHa(self): if base.mouseWatcherNode.hasMouse(): mpos = base.mouseWatcherNode.getMouse() def setPlayingStatus(status): self.isBananaPlaying = status self.ray.setFromLens(base.camNode, mpos.getX(), mpos.getY()) self.bananaClicker.traverse(render) if self.collHandlerQueue.getNumEntries() > 0: self.collHandlerQueue.sortEntries() pickedObj = self.collHandlerQueue.getEntry(0).getIntoNodePath() surleeAnim = random.choice(['slip-backward', 'slip-forward']) dimmAnim = random.choice(['slip-backward', 'slip-forward']) if pickedObj == self.banana: self.seq = Sequence( Func(setPlayingStatus, True), Func(self.surlee.play, surleeAnim), Func(self.dimm.play, dimmAnim), Wait(3), Func(self.surlee.loop, 'scientistGame'), Func(self.dimm.loop, 'scientistGame'), Func(setPlayingStatus, False)) if not self.isBananaPlaying: self.seq.start()
def onSetAction_firstPerson(self, action): track = Sequence() vm = self.getViewModel() fpsCam = self.getFPSCam() if action in [self.StateFire, self.StateDblFire]: CIGlobals.makeMuzzleFlash(self.fpMuzzleAttach, (-0.03, 0.51, 32.45), (0, -90, 0), 7.5) if action == self.StateIdle: track.append(Func(vm.loop, "idle")) elif action == self.StateDraw: track.append(ActorInterval(vm, "draw", playRate=self.Speed)) elif action == self.StatePump: track.append(Func(self.pumpSound.play)) track.append(Func(self.__emitShell)) track.append(ActorInterval(vm, "pump", playRate=self.Speed)) elif action == self.StateFire: fpsCam.addViewPunch( Vec3(random.uniform(-2, 2), random.uniform(2, 1), 0)) track.append(Func(self.fireSound.play)) track.append(ActorInterval(vm, "fire", playRate=self.Speed)) elif action == self.StateDblFire: fpsCam.addViewPunch(Vec3(0, random.uniform(-5, 5), 0)) track.append(Func(self.dblFireSound.play)) track.append(ActorInterval(vm, "altfire", playRate=self.Speed)) elif action == self.StateReload: sound = random.choice(self.reloadSounds) track.append(Func(sound.play)) track.append(ActorInterval(vm, "reload2", playRate=self.Speed)) elif action == self.StateBeginReload: track.append(ActorInterval(vm, "reload1", playRate=self.Speed)) elif action == self.StateEndReload: track.append(ActorInterval(vm, "reload3", playRate=self.Speed)) fpsCam.setVMAnimTrack(track)
def showResults(self): if not self.gameIsEnding: self.gameIsEnding = True for barrel in self.barrels: barrel.wrtReparentTo(render) for key in self.cogInfo: thief = self.cogInfo[key]['suit'] thief.suit.setPos(100, 0, 0) thief.suit.hide() self.__killRewardCountdown() self.stopGameWalk() numBarrelsSaved = len(self.barrels) - len(self.stolenBarrels) resultStr = '' if numBarrelsSaved == len(self.barrels): resultStr = TTLocalizer.CogThiefPerfect else: if numBarrelsSaved > 1: resultStr = TTLocalizer.CogThiefBarrelsSaved % { 'num': numBarrelsSaved } else: if numBarrelsSaved == 1: resultStr = TTLocalizer.CogThiefBarrelSaved % { 'num': numBarrelsSaved } else: resultStr = TTLocalizer.CogThiefNoBarrelsSaved perfectTextSubnode = hidden.attachNewNode( self.__genText(resultStr)) 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() def safeGameOver(self=self): if not self.frameworkFSM.isInternalStateInFlux(): self.gameOver() 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), Func(safeGameOver)) if numBarrelsSaved == len(self.barrels): soundTrack = SoundInterval(self.sndPerfect) else: soundTrack = Sequence() self.resultIval = Parallel(textTrack, soundTrack) self.resultIval.start() if config.GetBool('want-blueprint4-ARG', False): MinigameGlobals.generateDebugARGPhrase()
def doActivity(self): return Sequence(Func(self.avatar.animFSM.request, 'happy'), Wait(5.0))
def __allowDetect(self, task): if self.fadeTrack: self.fadeTrack.finish() self.fadeTrack = Sequence(self.tableGroup.colorScaleInterval(0.2, VBase4(1, 1, 1, 1)), Func(self.tableGroup.clearColorScale), Func(self.tableGroup.clearTransparency)) self.fadeTrack.start() self.allowLocalRequestControl = True
def enterCatch(self): self.ival = Parallel( Sequence(Wait(0.2), Func(self.__tryToCatchOrGrab)), Sequence(ActorInterval(self.vModel, "catch"), Func(self.__maybeHold))) self.ival.start()
def enterHold(self): self.ival = Sequence(ActorInterval(self.vModel, "hold-start"), Func(self.vModel.loop, "hold")) self.ival.start()
def __init__(self, gameObject=None): base.loadingScreen.beginStep('LegendaryGameGUI', 4, 20) self.gameObject = gameObject self.guiImage = loader.loadModel( 'models/minigames/pir_m_gam_fsh_legendaryGui') self.UICompoments = {} self.uiBaseNode = NodePath('baseNode') self.uiBaseNode.reparentTo(aspect2d) self.uiBaseNode.show() self.leftBaseNode = NodePath('leftBaseNode') self.leftBaseNode.reparentTo(base.a2dLeftCenter) self.leftBaseNode.show() self.fishActor = None self.actorAnim = {} self.scaleSize = { InventoryType.Collection_Set11_Part1: 0.059999999999999998, InventoryType.Collection_Set11_Part2: 0.055, InventoryType.Collection_Set11_Part3: 0.12, InventoryType.Collection_Set11_Part4: 0.086999999999999994, InventoryType.Collection_Set11_Part5: 0.080000000000000002 } self.meterFrame = DirectFrame( parent=self.leftBaseNode, frameSize=(-0.29999999999999999, 0.29999999999999999, -1.0, 0.0), frameColor=(1.0, 1.0, 1.0, 0.0), relief=None, state=DGG.DISABLED, pos=(1.0, 0.0, -0.45000000000000001), hpr=(0, 0, 0), scale=(1.3, 0.0, 1.3), image=self.guiImage.find('**/pir_t_gui_fsh_meter'), image_scale=(0.20000000000000001, 0.0, 0.80000000000000004), image_pos=(0, 0, 0), text='', textMayChange=1, text_scale=PiratesGuiGlobals.TextScaleTitleLarge, text_pos=(-0.55000000000000004, 0.10000000000000001), text_shadow=PiratesGuiGlobals.TextShadow) self.UICompoments['meterFrame'] = self.meterFrame self.fishingRod = DirectFrame( parent=self.meterFrame, frameSize=(-0.29999999999999999, 0.29999999999999999, -1.0, 0.0), relief=None, state=DGG.DISABLED, pos=FishingGlobals.fishingRodScreenPosition, image=self.guiImage.find('**/pir_t_gui_fsh_fullRod'), image_scale=(1.0, 0.0, 0.125), image_pos=(0.20000000000000001, 0, 0)) self.fishingRod.setR(FishingGlobals.fishingRodInitSlope) self.UICompoments['fishingRod'] = self.fishingRod base.loadingScreen.tick() self.fishingHandleBaseFrame = DirectFrame( parent=self.uiBaseNode, frameSize=(-0.29999999999999999, 0.29999999999999999, -1.5, 1.5), frameColor=(1.0, 1.0, 1.0, 0.0), relief=None, state=DGG.DISABLED, pos=(0.0, 0.0, 0.0), hpr=(0, 0, 0), scale=(0.71999999999999997, 0.0, 0.71999999999999997), image=self.guiImage.find('**/pir_t_gui_fsh_partialRod'), image_scale=(3.7999999999999998, 0.0, 1.8999999999999999), image_pos=(0, 0, 0), image_hpr=(0.0, 0.0, 0)) self.fishingHandleBaseFrame.hide() self.UICompoments[ 'fishingHandleBaseFrame'] = self.fishingHandleBaseFrame self.fishingHandle = DirectFrame( parent=self.fishingHandleBaseFrame, frameSize=(-0.080000000000000002, 0.080000000000000002, -0.20000000000000001, 0.20000000000000001), relief=None, state=DGG.DISABLED, pos=(-0.10000000000000001, 0.0, -0.050000000000000003), hpr=(0, 0, 0), image=self.guiImage.find('**/pir_t_gui_fsh_handleArm'), image_scale=(1.0, 0.0, 1.0), image_pos=(-0.042000000000000003, 0, -0.115), image_hpr=(0.0, 0.0, 0)) self.UICompoments['fishingHandle'] = self.fishingHandle self.arrowImage = DirectFrame( parent=self.fishingHandleBaseFrame, frameSize=(-0.40000000000000002, 0.40000000000000002, -0.40000000000000002, 0.40000000000000002), relief=None, state=DGG.DISABLED, pos=(0.0, 0.0, 0.0), hpr=(0, 0, 0), scale=(1.2, 0.0, 1.2), image=self.guiImage.find('**/pir_t_gui_fsh_arrow'), image_scale=(1.0, 0.0, 1.0), image_pos=(0.0, 0, 0.0), image_hpr=(0.0, 0.0, 0.0)) self.arrowImage.hide() self.UICompoments['arrowImage'] = self.arrowImage btnGeom = (self.guiImage.find('**/pir_t_gui_fsh_handle'), self.guiImage.find('**/pir_t_gui_fsh_handle'), self.guiImage.find('**/pir_t_gui_fsh_handleOn')) self.fishingHandleButton = GuiButton(pos=(-0.29999999999999999, 0, -0.55000000000000004), hpr=(0, 0, 0), scale=0.45000000000000001, image=btnGeom, image_pos=(0, 0, 0), image_scale=1.0, sortOrder=2) self.fishingHandleButton.bind(DGG.B1PRESS, self.handleButtonClicked) self.fishingHandleButton.reparentTo(self.fishingHandle) self.UICompoments['fishingHandleButton'] = self.fishingHandleButton self.fishingHandleBaseFrame.setTransparency(TransparencyAttrib.MAlpha) self.meterFrame.setTransparency(TransparencyAttrib.MAlpha) self.lineOneTransitTextNode = TextNode('lineOneTransitText') self.lineOneTransitTextNode.setFont(PiratesGlobals.getPirateFont()) self.lineOneTransitTextNode.setText('') self.lineOneTransitTextNode.setAlign(TextNode.ACenter) self.lineOneTransitTextNode.setTextColor(1.0, 1.0, 1.0, 0.5) self.lineOneTransitTextNodePath = NodePath(self.lineOneTransitTextNode) self.lineOneTransitTextNodePath.setPos(0.0, 0.0, -0.80000000000000004) self.lineOneTransitTextNodePath.setScale(0.34999999999999998, 0.34999999999999998, 0.34999999999999998) self.lineOneTransitTextNodePath.reparentTo(self.uiBaseNode) self.lineOneTransitTextNodePath.hide() self.UICompoments[ 'lineOneTransitText'] = self.lineOneTransitTextNodePath self.lineTwoTransitTextNode = TextNode('lineTwoTransitText') self.lineTwoTransitTextNode.setFont(PiratesGlobals.getPirateFont()) self.lineTwoTransitTextNode.setText('') self.lineTwoTransitTextNode.setAlign(TextNode.ACenter) self.lineTwoTransitTextNode.setTextColor(1.0, 1.0, 1.0, 0.5) self.lineTwoTransitTextNodePath = NodePath(self.lineTwoTransitTextNode) self.lineTwoTransitTextNodePath.setPos(-0.40000000000000002, 0.0, -0.94999999999999996) self.lineTwoTransitTextNodePath.setScale(0.12, 0.12, 0.12) self.lineTwoTransitTextNodePath.reparentTo(self.uiBaseNode) self.lineTwoTransitTextNodePath.hide() self.UICompoments[ 'lineTwoTransitText'] = self.lineTwoTransitTextNodePath base.loadingScreen.tick() self.test_guiImage = loader.loadModel('models/gui/toplevel_gui') self.buttonIcon = ( self.test_guiImage.find('**/treasure_chest_closed'), self.test_guiImage.find('**/treasure_chest_closed'), self.test_guiImage.find('**/treasure_chest_closed_over')) self.winImagePanel = GuiPanel.GuiPanel('', 2.6000000000000001, 1.8999999999999999, True) self.winImagePanel.setPos(-1.3, 0.0, -0.94999999999999996) self.winImagePanel.reparentTo(self.uiBaseNode) self.winImagePanel.background = OnscreenImage( parent=self.winImagePanel, scale=(2.3999999999999999, 0, 1.8), image=self.guiImage.find('**/pir_t_gui_fsh_posterBackground'), hpr=(0, 0, 0), pos=(1.3, 0, 0.94999999999999996)) self.winImagePanel.setBin('gui-popup', -4) self.winTitleTextNode = TextNode('winTitleTextNode') self.winTitleTextNode.setText('Congratulations!') self.winTitleTextNode.setAlign(TextNode.ACenter) self.winTitleTextNode.setFont(PiratesGlobals.getPirateFont()) self.winTitleTextNode.setTextColor(0.23000000000000001, 0.089999999999999997, 0.029999999999999999, 1.0) self.winTitleTextNodePath = NodePath(self.winTitleTextNode) self.winTitleTextNodePath.setPos(1.3500000000000001, 0.0, 1.6699999999999999) self.winTitleTextNodePath.setScale(0.17999999999999999) self.winTitleTextNodePath.reparentTo(self.winImagePanel) self.wholeStoryTextNode = TextNode('storyTextNode') self.wholeStoryTextNode.setText('') self.wholeStoryTextNode.setWordwrap(19.0) self.wholeStoryTextNode.setTextColor(0.23000000000000001, 0.089999999999999997, 0.029999999999999999, 1.0) self.wholeStoryTextNodePath = NodePath(self.wholeStoryTextNode) self.wholeStoryTextNodePath.setPos(0.33000000000000002, 0.0, 1.6399999999999999) self.wholeStoryTextNodePath.setScale(0.050000000000000003) self.wholeStoryTextNodePath.reparentTo(self.winImagePanel) self.winImagePanel.closeButton[ 'command'] = self.closeDialogGotNextState self.winImagePanel.closeButton['extraArgs'] = [ 'winImagePanel', 'FarewellLegendaryFish', False ] self.UICompoments['winImagePanel'] = self.winImagePanel self.winImagePanel.hide() self.luiCloseDialogSequence = Sequence() self.arrowImageRotationInterval = LerpHprInterval( self.arrowImage, 2.2000000000000002, self.arrowImage.getHpr() + Point3(0.0, 0.0, 280.0), self.arrowImage.getHpr()) self.luiArrowRotatingSequence = Sequence( Func(self.showGui, ['arrowImage']), Parallel(Func(self.arrowImageRotationInterval.start), Wait(2.2000000000000002)), Func(self.hideGui, ['arrowImage']), Func(self.arrowImage.setHpr, self.arrowImage.getHpr() + Point3(0.0, 0.0, 5.0)), name=self.gameObject.distributedFishingSpot.uniqueName( 'luiArrowRotatingSequence')) self.lineOneColorChange = LerpColorScaleInterval( self.lineOneTransitTextNodePath, FishingGlobals.legendaryTransitionTextDuration, (1.0, 1.0, 1.0, 0.0), (1.0, 1.0, 1.0, 1.0), blendType='easeOut') self.lineOnePosChange = LerpPosInterval( self.lineOneTransitTextNodePath, FishingGlobals.legendaryTransitionTextDuration, (0.0, 0.0, -0.20000000000000001), (0.0, 0.0, -0.80000000000000004), blendType='easeOut') self.lineTwoCholorChange = LerpColorScaleInterval( self.lineTwoTransitTextNodePath, FishingGlobals.legendaryTransitionTextDuration, (1.0, 1.0, 1.0, 1.0), (1.0, 1.0, 1.0, 1.0), blendType='easeOut') self.lineTwoPosChange = LerpPosInterval( self.lineTwoTransitTextNodePath, FishingGlobals.legendaryTransitionTextDuration, (0.0, 0.0, -0.32000000000000001), (0.0, 0.0, -0.94999999999999996), blendType='easeOut') self.transitionTextMovingSequence = Sequence( Func(self.lineOneTransitTextNodePath.show), Func(self.lineTwoTransitTextNodePath.show), Parallel(self.lineOnePosChange, self.lineTwoPosChange, self.lineOneColorChange, self.lineTwoCholorChange), Func(self.lineOneTransitTextNodePath.hide), Func(self.lineTwoTransitTextNodePath.hide), name=self.gameObject.distributedFishingSpot.uniqueName( 'transitionTextMovingSequence')) self.meterFadeInInterval = Sequence( Func(self.meterFrame.show), LerpColorScaleInterval( self.meterFrame, FishingGlobals.legendaryTransitionTextDuration, colorScale=(1.0, 1.0, 1.0, 1.0), startColorScale=(1.0, 1.0, 1.0, 0.0), blendType='easeOut'), name='FadeInLegendaryMeter') self.meterFadeOutInterval = Sequence(LerpColorScaleInterval( self.meterFrame, FishingGlobals.legendaryTransitionTextDuration, colorScale=(1.0, 1.0, 1.0, 0.0), startColorScale=(1.0, 1.0, 1.0, 1.0), blendType='easeOut'), Func(self.meterFrame.hide), name='FadeOutLegendaryMeter') self.rodFadeInInterval = Sequence( Func(self.fishingHandleBaseFrame.show), LerpColorScaleInterval( self.fishingHandleBaseFrame, FishingGlobals.legendaryTransitionTextDuration, colorScale=(1.0, 1.0, 1.0, 1.0), startColorScale=(1.0, 1.0, 1.0, 0.0), blendType='easeOut'), name='FadeInLegendaryRodInterface') self.rodFadeOutInterval = Sequence( LerpColorScaleInterval( self.fishingHandleBaseFrame, FishingGlobals.legendaryTransitionTextDuration, colorScale=(1.0, 1.0, 1.0, 0.0), startColorScale=(1.0, 1.0, 1.0, 1.0), blendType='easeOut'), Func(self.fishingHandleBaseFrame.hide), name='FadeOutLegendaryRodInterface') base.loadingScreen.tick() smallScale = self.fishingHandleButton['scale'] bigScale = self.fishingHandleButton['scale'] * 1.2 self.buttonGrowUpInterval = LerpScaleInterval(self.fishingHandleButton, 1.0, bigScale, smallScale) self.luiFightTransitSequence = Sequence( Parallel(Func(self.fishingHandleBaseFrame.show), Func(self.meterFadeOutInterval.start), Func(self.rodFadeInInterval.start), Func(self.buttonGrowUpInterval.start)), Wait(1.0), Func(self.meterFrame.hide), name=self.gameObject.distributedFishingSpot.uniqueName( 'luiFightTransitSequence')) self.luiReelTransitSequence = Sequence( Parallel(Func(self.fishingHandleBaseFrame.show), Func(self.meterFadeOutInterval.start), Func(self.rodFadeInInterval.start)), Wait(1.0), Func(self.meterFrame.hide), name=self.gameObject.distributedFishingSpot.uniqueName( 'luiReelTransitSequence')) self.luiStruggleTransitSequence = Sequence( Parallel(Func(self.meterFrame.show), Func(self.resetFishingRod), self.meterFadeInInterval, self.rodFadeOutInterval), Wait(1.0), Func(self.fishingHandleBaseFrame.hide), name=self.gameObject.distributedFishingSpot.uniqueName( 'luiStruggleTransitSequence')) self.meterFadeOutInterval.start() self.rodFadeOutInterval.start() self.hideAllGUI() base.loadingScreen.endStep('LegendaryGameGUI')
def enterFinalResults(self): lerpTrack = Parallel() lerpDur = 0.5 tY = 0.6 bY = -.05 lX = -.5 cX = 0 rX = 0.5 scorePanelLocs = (((cX, bY),), ((lX, bY), (rX, bY)), ((cX, tY), (lX, bY), (rX, bY)), ((lX, tY), (rX, tY), (lX, bY), (rX, bY))) scorePanelLocs = scorePanelLocs[self.numPlayers - 1] for i in xrange(self.numPlayers): panel = self.scorePanels[i] pos = scorePanelLocs[i] lerpTrack.append(Parallel(LerpPosInterval(panel, lerpDur, Point3(pos[0], 0, pos[1]), blendType='easeInOut'), LerpScaleInterval(panel, lerpDur, Vec3(panel.getScale()) * 2.0, blendType='easeInOut'))) self.showScoreTrack = Parallel(lerpTrack, Sequence(Wait(IceGameGlobals.ShowScoresDuration), Func(self.gameOver))) self.showScoreTrack.start()
def enterNeutral(self, ts=0): self.show() self.timestampAnimTrack = Sequence(Wait(ts), Func(self.loop, 'flyNeutral')) self.timestampAnimTrack.start()
def createOnePlayerSequence(self, index, duration): numVotes = self.votes[index] direction = self.directions[index] def ticketTicker(t, label=self.entryList[index][direction + 1], startVotes=0, endVotes=numVotes): label['text'] = str(int(t * endVotes + startVotes)) track = Parallel() startVotes = 0 for prev in xrange(index): if self.directions[prev] == direction: startVotes += self.votes[prev] def totalTicker(t, label=self.totalVotesLabels[direction], startVotes=startVotes, additionalVotes=numVotes): label['text'] = str(int(t * additionalVotes + startVotes)) track.append( LerpFunc(totalTicker, duration=duration, name='countTotal %d' % index)) if index in self.avVotesLabel: def avVotesTicker(t, label=self.avVotesLabel[index], startVotes=0, endVotes=numVotes, direction=direction): oldValue = label['text'] newValue = int(t * endVotes + startVotes) label['text'] = str(newValue) if not oldValue == label['text']: if newValue: if direction == 0: self.upArrowSfx[self.curArrowSfxIndex].play() else: self.downArrowSfx[self.curArrowSfxIndex].play() self.curArrowSfxIndex += 1 if self.curArrowSfxIndex >= len(self.upArrowSfx): self.curArrowSfxIndex = 0 label = self.avVotesLabel[index] track.append( Func(self.avVotesLabel[index].show, name='showName %d' % index)) if index in self.avArrows: track.append( Func(self.avArrows[index].show, name='showArrow %d' % index)) if direction == 0 and numVotes: pass elif direction == 1 and numVotes: pass else: track.append(SoundInterval(self.noVoteSfx)) track.append( LerpFunc(avVotesTicker, duration=duration, name='countAvVotes %d' % index)) return track
def setEveryoneDone(self): if not self.hasLocalToon: return if self.gameFSM.getCurrentState().getName() != 'play': self.notify.warning('ignoring setEveryoneDone msg') return self.notify.debug('setEveryoneDone') def endGame(task, self=self): if not PairingGameGlobals.EndlessGame: self.gameOver() return Task.done # hide the timer self.timer.hide() # hide the bonus self.bonusGlow.hide() # if it was a perfect game, let the players know if len(self.inactiveList) == len(self.cards): self.notify.debug("perfect game!") perfectTextSubnode = hidden.attachNewNode( self.__genText(TTLocalizer.PairingGamePerfect)) perfectText = hidden.attachNewNode('perfectText') perfectTextSubnode.reparentTo(perfectText) # offset the subnode so that the text is centered on both axes # we need the parent node so that the text will scale correctly frame = self.__textGen.getCardActual() offsetY = -abs(frame[2] + frame[3]) / 2. perfectTextSubnode.setPos(0, 0, offsetY) perfectText.setColor(1, .1, .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=.5, scale=.3, startScale=0.), LerpFunctionInterval( fadeFunc, fromData=0., toData=1., duration=.5, )), Wait(2.), Parallel( LerpScaleInterval(perfectText, duration=.5, scale=1.), LerpFunctionInterval(fadeFunc, fromData=1., toData=0., duration=.5, blendType="easeIn"), ), Func(destroyText), WaitInterval(.5), Func(endGame, None), ) soundTrack = SoundInterval(self.sndPerfect) self.perfectIval = Parallel(textTrack, soundTrack) self.perfectIval.start() else: taskMgr.doMethodLater(1, endGame, self.EndGameTaskName)
def startAttacking(self, task=None): if hasattr(self.suit, 'DELETED') or not hasattr(self, 'attacksThisSession'): self.stopAttacking() if task: return Task.done # Do we need to reset the avatars in-range? if self.attacksThisSession > 0: self.resetAvatarsInRange() # Stop attacking if low on health or if there's nothing around to attack. if hasattr(self.suit, 'DELETED'): self.stopAttacking() return # If there's nobody to attack or we're taking heavy damage, let's abandon mission. brain = self.suit.getBrain() if len(self.avatarsInRange) < 1 or self.isTimeToPanic(): self.stopAttacking() return # Let's check if we have a backup behavior if toons get out of control. from src.coginvasion.cog.SuitCallInBackupBehaviorAI import SuitCallInBackupBehaviorAI backupBehavior = brain.getBehavior(SuitCallInBackupBehaviorAI) if not backupBehavior is None: if backupBehavior.shouldStart(): brain.queueBehavior(SuitCallInBackupBehaviorAI) self.stopAttacking() return # Let's select a target and look at them. target = self.avatarsInRange[0] attack = SuitUtils.attack(self.suit, target) # Let's handle when we're attacking a turret. if target.__class__.__name__ == 'DistributedPieTurretAI': distance = self.suit.getDistance(target) speed = 50.0 if attack == 'glowerpower': speed = 100.0 timeUntilRelease = distance / speed if attack != 'glowerpower': if self.suit.getSuit()[0].getSuitType() == SuitType.C: timeUntilRelease += 2.2 else: timeUntilRelease += 3.0 else: timeUntilRelease += 1.0 turretPos = target.getPos(render) hp = int(self.suit.getMaxHealth() / SuitAttacks.SuitAttackDamageFactors[attack]) if self.suit.suitPlan.getName() == SuitGlobals.VicePresident: hp = int(200 / SuitAttacks.SuitAttackDamageFactors[attack]) self.suitAttackTurretTrack = Sequence( Wait(timeUntilRelease), Func(self.damageTurret, target, turretPos, hp)) self.suitAttackTurretTrack.start() self.isAttacking = True self.attacksThisSession += 1 self.attacksDone += 1 self.ATTACK_COOLDOWN = SuitAttacks.SuitAttackLengths[attack] # Are we allowed to continue attacking? if self.attacksThisSession < self.maxAttacksPerSession and not target.isDead( ): taskMgr.doMethodLater(self.ATTACK_COOLDOWN, self.startAttacking, self.suit.uniqueName('attackTask')) else: taskMgr.doMethodLater(self.ATTACK_COOLDOWN, self.stopAttacking, self.suit.uniqueName('finalAttack')) if task: return Task.done
def __showToonHitBySuit(self, avId, timestamp): toon = self.getAvatar(avId) if toon == None: return rng = self.toonRNGs[self.avIdList.index(avId)] curPos = toon.getPos(render) oldTrack = self.toonHitTracks[avId] if oldTrack.isPlaying(): oldTrack.finish() toon.setPos(curPos) toon.setZ(self.TOON_Z) parentNode = render.attachNewNode('mazeFlyToonParent-' + repr(avId)) parentNode.setPos(toon.getPos()) toon.reparentTo(parentNode) toon.setPos(0, 0, 0) startPos = parentNode.getPos() dropShadow = toon.dropShadow.copyTo(parentNode) dropShadow.setScale(toon.dropShadow.getScale(render)) trajectory = Trajectory.Trajectory(0, Point3(0, 0, 0), Point3(0, 0, 50), gravMult=1.0) flyDur = trajectory.calcTimeOfImpactOnPlane(0.0) while 1: endTile = [ rng.randint(2, self.maze.width - 1), rng.randint(2, self.maze.height - 1) ] if self.maze.isWalkable(endTile[0], endTile[1]): break endWorldCoords = self.maze.tile2world(endTile[0], endTile[1]) endPos = Point3(endWorldCoords[0], endWorldCoords[1], startPos[2]) def flyFunc(t, trajectory, startPos=startPos, endPos=endPos, dur=flyDur, moveNode=parentNode, flyNode=toon): u = t / dur moveNode.setX(startPos[0] + u * (endPos[0] - startPos[0])) moveNode.setY(startPos[1] + u * (endPos[1] - startPos[1])) flyNode.setPos(trajectory.getPos(t)) flyTrack = Sequence(LerpFunctionInterval(flyFunc, fromData=0.0, toData=flyDur, duration=flyDur, extraArgs=[trajectory]), name=toon.uniqueName('hitBySuit-fly')) if avId != self.localAvId: cameraTrack = Sequence() else: self.camParent.reparentTo(parentNode) startCamPos = camera.getPos() destCamPos = camera.getPos() zenith = trajectory.getPos(flyDur / 2.0)[2] destCamPos.setZ(zenith * 1.3) destCamPos.setY(destCamPos[1] * 0.3) def camTask(task, zenith=zenith, flyNode=toon, startCamPos=startCamPos, camOffset=destCamPos - startCamPos): u = flyNode.getZ() / zenith camera.setPos(startCamPos + camOffset * u) camera.lookAt(toon) return Task.cont camTaskName = 'mazeToonFlyCam-' + repr(avId) taskMgr.add(camTask, camTaskName, priority=20) def cleanupCamTask(self=self, toon=toon, camTaskName=camTaskName, startCamPos=startCamPos): taskMgr.remove(camTaskName) self.camParent.reparentTo(toon) camera.setPos(startCamPos) camera.lookAt(toon) cameraTrack = Sequence(Wait(flyDur), Func(cleanupCamTask), name='hitBySuit-cameraLerp') geomNode = toon.getGeomNode() startHpr = geomNode.getHpr() destHpr = Point3(startHpr) hRot = rng.randrange(1, 8) if rng.choice([0, 1]): hRot = -hRot destHpr.setX(destHpr[0] + hRot * 360) spinHTrack = Sequence(LerpHprInterval(geomNode, flyDur, destHpr, startHpr=startHpr), Func(geomNode.setHpr, startHpr), name=toon.uniqueName('hitBySuit-spinH')) parent = geomNode.getParent() rotNode = parent.attachNewNode('rotNode') geomNode.reparentTo(rotNode) rotNode.setZ(toon.getHeight() / 2.0) oldGeomNodeZ = geomNode.getZ() geomNode.setZ(-toon.getHeight() / 2.0) startHpr = rotNode.getHpr() destHpr = Point3(startHpr) pRot = rng.randrange(1, 3) if rng.choice([0, 1]): pRot = -pRot destHpr.setY(destHpr[1] + pRot * 360) spinPTrack = Sequence(LerpHprInterval(rotNode, flyDur, destHpr, startHpr=startHpr), Func(rotNode.setHpr, startHpr), name=toon.uniqueName('hitBySuit-spinP')) i = self.avIdList.index(avId) soundTrack = Sequence(Func(base.playSfx, self.sndTable['hitBySuit'][i]), Wait(flyDur * (2.0 / 3.0)), SoundInterval(self.sndTable['falling'][i], duration=flyDur * (1.0 / 3.0)), name=toon.uniqueName('hitBySuit-soundTrack')) def preFunc(self=self, avId=avId, toon=toon, dropShadow=dropShadow): forwardSpeed = toon.forwardSpeed rotateSpeed = toon.rotateSpeed if avId == self.localAvId: self.orthoWalk.stop() else: toon.stopSmooth() if forwardSpeed or rotateSpeed: toon.setSpeed(forwardSpeed, rotateSpeed) toon.dropShadow.hide() def postFunc(self=self, avId=avId, oldGeomNodeZ=oldGeomNodeZ, dropShadow=dropShadow, parentNode=parentNode): if avId == self.localAvId: base.localAvatar.setPos(endPos) if hasattr(self, 'orthoWalk'): if self.gameFSM.getCurrentState().getName() == 'play': self.orthoWalk.start() dropShadow.removeNode() del dropShadow toon.dropShadow.show() geomNode = toon.getGeomNode() rotNode = geomNode.getParent() baseNode = rotNode.getParent() geomNode.reparentTo(baseNode) rotNode.removeNode() del rotNode geomNode.setZ(oldGeomNodeZ) toon.reparentTo(render) toon.setPos(endPos) parentNode.removeNode() del parentNode if avId != self.localAvId: toon.startSmooth() preFunc() hitTrack = Sequence(Parallel(flyTrack, cameraTrack, spinHTrack, spinPTrack, soundTrack), Func(postFunc), name=toon.uniqueName('hitBySuit')) self.toonHitTracks[avId] = hitTrack hitTrack.start(globalClockDelta.localElapsedTime(timestamp))
def doActivity(self): return Sequence(Func(self.avatar.animFSM.request, 'died'), Wait(7.0))
def enterThrow(self): self.ival = Parallel( Sequence(Wait(0.4), Func(self.mySnowball.b_throw)), Sequence(ActorInterval(self.vModel, "throw"), Func(self.fsm.request, 'off'))) self.ival.start()
def changeDinerToDead(self, chairIndex): def removeDeathSuit(suit, deathSuit): if not deathSuit.isEmpty(): deathSuit.detachNode() suit.cleanupLoseActor() self.removeFoodModel(chairIndex) indicator = self.dinerStatusIndicators.get(chairIndex) if indicator: indicator.request('Dead') diner = self.diners[chairIndex] deathSuit = diner locator = self.tableGroup.find('**/chair_%d' % (chairIndex + 1)) deathSuit = diner.getLoseActor() ival = Sequence( Func(self.notify.debug, 'before actorinterval sit-lose'), ActorInterval(diner, 'sit-lose'), Func(self.notify.debug, 'before deathSuit.setHpr'), Func(deathSuit.setHpr, diner.getHpr()), Func(self.notify.debug, 'before diner.hide'), Func(diner.hide), Func(self.notify.debug, 'before deathSuit.reparentTo'), Func(deathSuit.reparentTo, self.chairLocators[chairIndex]), Func(self.notify.debug, 'befor ActorInterval lose'), ActorInterval(deathSuit, 'lose', duration=MovieUtil.SUIT_LOSE_DURATION), Func(self.notify.debug, 'before remove deathsuit'), Func(removeDeathSuit, diner, deathSuit, name='remove-death-suit-%d-%d' % (chairIndex, self.index)), Func(self.notify.debug, 'diner.stash'), Func(diner.stash)) spinningSound = base.loader.loadSfx( 'phase_3.5/audio/sfx/Cog_Death.ogg') deathSound = base.loader.loadSfx( 'phase_3.5/audio/sfx/ENC_cogfall_apart_%s.ogg' % random.randint(1, 6)) deathSoundTrack = Sequence( Wait(0.8), SoundInterval(spinningSound, duration=1.2, startTime=1.5, volume=0.2, node=deathSuit), SoundInterval(spinningSound, duration=3.0, startTime=0.6, volume=0.8, node=deathSuit), SoundInterval(deathSound, volume=0.32, node=deathSuit)) intervalName = 'dinerDie-%d-%d' % (self.index, chairIndex) deathIval = Parallel(ival, deathSoundTrack) deathIval.start() self.activeIntervals[intervalName] = deathIval
def setHillType(self, type): if self.isUp: if (self.hillType == MoleFieldBase.HILL_MOLE or type == MoleFieldBase.HILL_BOMB or self.hillType == MoleFieldBase.HILL_BOMB ) and type == MoleFieldBase.HILL_MOLE: return None self.hillType = type self.moleHead.remove() if type == MoleFieldBase.HILL_MOLE: self.moleHead = loader.loadModel( 'phase_12/models/bossbotHQ/mole_norm') self.moleColNodePath.setScale(3.0) self.moleHead.setH(0) self.mole.setBillboardAxis(localAvatar, 0) if type == MoleFieldBase.HILL_BOMB or type == MoleFieldBase.HILL_COGWHACKED: self.moleHead = loader.loadModel( 'phase_12/models/bossbotHQ/mole_cog') self.moleColNodePath.setScale(1.0) self.mole.setBillboardAxis(localAvatar, 0) if type == MoleFieldBase.HILL_COGWHACKED: self.doMoleDown() BattleParticles.loadParticles() singleGear = BattleParticles.createParticleEffect( 'GearExplosion', numParticles=1) smallGearExplosion = BattleParticles.createParticleEffect( 'GearExplosion', numParticles=10) bigGearExplosion = BattleParticles.createParticleEffect( 'BigGearExplosion', numParticles=30) gears2MTrack = Track( (0.0, ParticleInterval(singleGear, self.hill, worldRelative=1, duration=5.7000000000000002, cleanup=True)), (0.0, ParticleInterval(smallGearExplosion, self.hill, worldRelative=0, duration=1.2, cleanup=True)), (0.29999999999999999, ParticleInterval(bigGearExplosion, self.hill, worldRelative=0, duration=1.0, cleanup=True)), name='gears2MTrack') gears2MTrack.start() self.popIval = Sequence( Parallel( Sequence( LerpPosInterval( self.moleHead, 0.050000000000000003, Point3(0.28000000000000003, 0.0, 0.0)), LerpPosInterval( self.moleHead, 0.050000000000000003, Point3(0.0, -0.23000000000000001, 0.0)), LerpPosInterval( self.moleHead, 0.050000000000000003, Point3(0.0, 0.0, 0.28000000000000003)), LerpPosInterval( self.moleHead, 0.050000000000000003, Point3(-0.34999999999999998, 0.0, 0.0)), LerpPosInterval( self.moleHead, 0.050000000000000003, Point3(0.0, 0.28000000000000003, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.31, 0.0, 0.0)), LerpPosInterval( self.moleHead, 0.050000000000000003, Point3(0.0, -0.32000000000000001, 0.0)), LerpPosInterval( self.moleHead, 0.050000000000000003, Point3(0.0, 0.0, 0.47999999999999998)), LerpPosInterval( self.moleHead, 0.050000000000000003, Point3(-0.28000000000000003, 0.0, 0.0)), LerpPosInterval( self.moleHead, 0.050000000000000003, Point3(0.0, 0.28999999999999998, 0.0)))), LerpPosInterval(self.mole, 0.5, Point3(0, 0, -2.5)), Func(self.setHillType, MoleFieldBase.HILL_BOMB)) self.popIval.start() else: self.moleHead.setH(0) if type == MoleFieldBase.HILL_WHACKED: self.moleHead = loader.loadModel( 'phase_12/models/bossbotHQ/mole_hit') self.mole.setBillboardAxis(0) self.moleColNodePath.setScale(0.0) if self.popIval: self.popIval.finish() if self.downIval: self.downIval.finish() self.mole.setPos(0.0, 0.0, 0.0) self.popIval = Sequence( Parallel( Sequence( LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.17999999999999999, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.0, -0.13, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.0, 0.0, 0.17999999999999999)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(-0.14999999999999999, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.0, 0.17999999999999999, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.11, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.0, -0.12, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.0, 0.0, 0.17999999999999999)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(-0.17999999999999999, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.0, 0.13, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.17999999999999999, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.0, -0.14999999999999999, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.0, 0.0, 0.17999999999999999)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(-0.16, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.0, 0.17999999999999999, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.11, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.0, -0.17999999999999999, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.0, 0.0, 0.17000000000000001)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(-0.17999999999999999, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.050000000000000003, Point3(0.0, 0.0, 0.0))), Sequence(LerpScaleInterval(self.moleHead, 0.5, 3.5), LerpScaleInterval(self.moleHead, 0.5, 1.0))), LerpPosInterval(self.mole, 0.5, Point3(0, 0, -2.5)), Func(self.setHillType, MoleFieldBase.HILL_MOLE)) self.popIval.start() self.moleHead.reparentTo(self.mole)
def getSprayTrack(self, color, origin, target, dScaleUp, dHold, dScaleDown, horizScale=1.0, vertScale=1.0, parent=render): track = Sequence() SPRAY_LEN = 1.5 sprayProp = MovieUtil.globalPropPool.getProp('spray') sprayScale = hidden.attachNewNode('spray-parent') sprayRot = hidden.attachNewNode('spray-rotate') spray = sprayRot spray.setColor(color) if color[3] < 1.0: spray.setTransparency(1) def showSpray(sprayScale, sprayRot, sprayProp, origin, target, parent): if callable(origin): origin = origin() if callable(target): target = target() sprayRot.reparentTo(parent) sprayRot.clearMat() sprayScale.reparentTo(sprayRot) sprayScale.clearMat() sprayProp.reparentTo(sprayScale) sprayProp.clearMat() sprayRot.setPos(origin) sprayRot.lookAt(Point3(target)) track.append( Func(showSpray, sprayScale, sprayRot, sprayProp, origin, target, parent)) def calcTargetScale(target=target, origin=origin, horizScale=horizScale, vertScale=vertScale): if callable(target): target = target() if callable(origin): origin = origin() distance = Vec3(target - origin).length() yScale = distance / SPRAY_LEN targetScale = Point3(yScale * horizScale, yScale, yScale * vertScale) return targetScale track.append( LerpScaleInterval(sprayScale, dScaleUp, calcTargetScale, startScale=Point3(0.01, 0.01, 0.01))) track.append(Func(self.checkHitObject)) track.append(Wait(dHold)) def prepareToShrinkSpray(spray, sprayProp, origin, target): if callable(target): target = target() if callable(origin): origin = origin() sprayProp.setPos(Point3(0.0, -SPRAY_LEN, 0.0)) spray.setPos(target) track.append( Func(prepareToShrinkSpray, spray, sprayProp, origin, target)) track.append( LerpScaleInterval(sprayScale, dScaleDown, Point3(0.01, 0.01, 0.01))) def hideSpray(spray, sprayScale, sprayRot, sprayProp, propPool): sprayProp.detachNode() MovieUtil.removeProp(sprayProp) sprayRot.removeNode() sprayScale.removeNode() track.append( Func(hideSpray, spray, sprayScale, sprayRot, sprayProp, MovieUtil.globalPropPool)) return track
def changeDinerToEating(self, chairIndex): indicator = self.dinerStatusIndicators.get(chairIndex) eatingDuration = self.dinerInfo[chairIndex][1] if indicator: indicator.request('Eating', eatingDuration) diner = self.diners[chairIndex] intervalName = 'eating-%d-%d' % (self.index, chairIndex) eatInTime = 32.0 / 24.0 eatOutTime = 21.0 / 24.0 eatLoopTime = 19 / 24.0 rightHand = diner.getRightHand() waitTime = 5 loopDuration = eatingDuration - eatInTime - eatOutTime - waitTime serviceLoc = self.serviceLocs[chairIndex] def foodAttach(self = self, diner = diner): if self.serviceLocs[chairIndex].getNumChildren() < 1: return foodModel = self.serviceLocs[chairIndex].getChild(0) (foodModel.reparentTo(diner.getRightHand()),) (foodModel.setHpr(Point3(0, -94, 0)),) (foodModel.setPos(Point3(-0.15, -0.7, -0.4)),) scaleAdj = 1 if SuitDNA.getSuitBodyType(diner.dna.name) == 'c': scaleAdj = 0.6 (foodModel.setPos(Point3(0.1, -0.25, -0.31)),) else: scaleAdj = 0.8 (foodModel.setPos(Point3(-0.25, -0.85, -0.34)),) oldScale = foodModel.getScale() newScale = oldScale * scaleAdj foodModel.setScale(newScale) def foodDetach(self = self, diner = diner): if diner.getRightHand().getNumChildren() < 1: return foodModel = diner.getRightHand().getChild(0) (foodModel.reparentTo(serviceLoc),) (foodModel.setPosHpr(0, 0, 0, 0, 0, 0),) scaleAdj = 1 if SuitDNA.getSuitBodyType(diner.dna.name) == 'c': scaleAdj = 0.6 else: scakeAdj = 0.8 oldScale = foodModel.getScale() newScale = oldScale / scaleAdj foodModel.setScale(newScale) eatIval = Sequence(ActorInterval(diner, 'sit', duration=waitTime), ActorInterval(diner, 'sit-eat-in', startFrame=0, endFrame=6), Func(foodAttach), ActorInterval(diner, 'sit-eat-in', startFrame=6, endFrame=32), ActorInterval(diner, 'sit-eat-loop', duration=loopDuration, loop=1), ActorInterval(diner, 'sit-eat-out', startFrame=0, endFrame=12), Func(foodDetach), ActorInterval(diner, 'sit-eat-out', startFrame=12, endFrame=21)) eatIval.start() self.activeIntervals[intervalName] = eatIval
def timeUp(self): self.sendUpdate('timeUp', []) Sequence(Wait(10.0), Func(self.d_gameOver)).start()
def showToonHitBySuit(self, avId, timestamp): toon = self.getAvatar(avId) if toon == None: return rng = self.toonRNGs[self.avIdList.index(avId)] curPos = toon.getPos(render) oldTrack = self.toonHitTracks[avId] if oldTrack.isPlaying(): oldTrack.finish() toon.setPos(curPos) toon.setZ(self.TOON_Z) parentNode = render.attachNewNode('mazeFlyToonParent-' + ` avId `) parentNode.setPos(toon.getPos()) toon.reparentTo(parentNode) toon.setPos(0, 0, 0) startPos = parentNode.getPos() dropShadow = toon.dropShadow.copyTo(parentNode) dropShadow.setScale(toon.dropShadow.getScale(render)) trajectory = Trajectory.Trajectory(0, Point3(0, 0, 0), Point3(0, 0, 50), gravMult=1.0) oldFlyDur = trajectory.calcTimeOfImpactOnPlane(0.0) trajectory = Trajectory.Trajectory(0, Point3(0, 0, 0), Point3(0, 0, 40), gravMult=1.0) flyDur = trajectory.calcTimeOfImpactOnPlane(0.0) avIndex = self.avIdList.index(avId) endPos = CTGG.ToonStartingPositions[avIndex] def flyFunc(t, trajectory, startPos=startPos, endPos=endPos, dur=flyDur, moveNode=parentNode, flyNode=toon): u = t / dur moveNode.setX(startPos[0] + u * (endPos[0] - startPos[0])) moveNode.setY(startPos[1] + u * (endPos[1] - startPos[1])) flyNode.setPos(trajectory.getPos(t)) flyTrack = Sequence(LerpFunctionInterval(flyFunc, fromData=0.0, toData=flyDur, duration=flyDur, extraArgs=[trajectory]), name=toon.uniqueName('hitBySuit-fly')) geomNode = toon.getGeomNode() startHpr = geomNode.getHpr() destHpr = Point3(startHpr) hRot = rng.randrange(1, 8) if rng.choice([0, 1]): hRot = -hRot destHpr.setX(destHpr[0] + hRot * 360) spinHTrack = Sequence(LerpHprInterval(geomNode, flyDur, destHpr, startHpr=startHpr), Func(geomNode.setHpr, startHpr), name=toon.uniqueName('hitBySuit-spinH')) parent = geomNode.getParent() rotNode = parent.attachNewNode('rotNode') geomNode.reparentTo(rotNode) rotNode.setZ(toon.getHeight() / 2.0) oldGeomNodeZ = geomNode.getZ() geomNode.setZ(-toon.getHeight() / 2.0) startHpr = rotNode.getHpr() destHpr = Point3(startHpr) pRot = rng.randrange(1, 3) if rng.choice([0, 1]): pRot = -pRot destHpr.setY(destHpr[1] + pRot * 360) spinPTrack = Sequence(LerpHprInterval(rotNode, flyDur, destHpr, startHpr=startHpr), Func(rotNode.setHpr, startHpr), name=toon.uniqueName('hitBySuit-spinP')) i = self.avIdList.index(avId) soundTrack = Sequence(Func(base.playSfx, self.sndTable['hitBySuit'][i]), Wait(flyDur * (2.0 / 3.0)), SoundInterval(self.sndTable['falling'][i], duration=flyDur * (1.0 / 3.0)), name=toon.uniqueName('hitBySuit-soundTrack')) def preFunc(self=self, avId=avId, toon=toon, dropShadow=dropShadow): forwardSpeed = toon.forwardSpeed rotateSpeed = toon.rotateSpeed if avId == self.localAvId: self.stopGameWalk() else: toon.stopSmooth() if forwardSpeed or rotateSpeed: toon.setSpeed(forwardSpeed, rotateSpeed) toon.dropShadow.hide() def postFunc(self=self, avId=avId, oldGeomNodeZ=oldGeomNodeZ, dropShadow=dropShadow, parentNode=parentNode): if avId == self.localAvId: base.localAvatar.setPos(endPos) if hasattr(self, 'gameWalk'): toon = base.localAvatar toon.setSpeed(0, 0) self.startGameWalk() dropShadow.removeNode() del dropShadow toon = self.getAvatar(avId) if toon: toon.dropShadow.show() geomNode = toon.getGeomNode() rotNode = geomNode.getParent() baseNode = rotNode.getParent() geomNode.reparentTo(baseNode) rotNode.removeNode() del rotNode geomNode.setZ(oldGeomNodeZ) if toon: toon.reparentTo(render) toon.setPos(endPos) parentNode.removeNode() del parentNode if avId != self.localAvId: if toon: toon.startSmooth() preFunc() slipBack = Parallel( Sequence(ActorInterval(toon, 'slip-backward', endFrame=24), ActorInterval(toon, 'slip-backward', startFrame=24))) if toon.doId == self.localAvId: slipBack.append(SoundInterval(self.sndOof)) hitTrack = Sequence(Parallel(flyTrack, spinHTrack, spinPTrack, soundTrack), slipBack, Func(postFunc), name=toon.uniqueName('hitBySuit')) self.notify.debug('hitTrack duration = %s' % hitTrack.getDuration()) self.toonHitTracks[avId] = hitTrack hitTrack.start(globalClockDelta.localElapsedTime(timestamp)) return
def teamScored(self, team): self.scoreByTeam[team] += 1 self.sendUpdate('incrementTeamScore', [team]) if self.scoreByTeam[team] >= GGG.CTF_SCORE_CAP: self.sendUpdate('teamWon', [team, 0]) Sequence(Wait(10.0), Func(self.d_gameOver)).start()
def enterScoring(self): sortedByDistance = [] for avId in self.avIdList: np = self.getTireNp(avId) pos = np.getPos() pos.setZ(0) sortedByDistance.append((avId, pos.length())) def compareDistance(x, y): if x[1] - y[1] > 0: return 1 elif x[1] - y[1] < 0: return -1 else: return 0 sortedByDistance.sort(cmp=compareDistance) self.scoreMovie = Sequence() curScale = 0.01 curTime = 0 self.scoreCircle.setScale(0.01) self.scoreCircle.show() self.notify.debug('newScores = %s' % self.newScores) circleStartTime = 0 for index in xrange(len(sortedByDistance)): distance = sortedByDistance[index][1] avId = sortedByDistance[index][0] scorePanelIndex = self.avIdList.index(avId) time = (distance - curScale) / IceGameGlobals.ExpandFeetPerSec if time < 0: time = 0.01 scaleXY = distance + IceGameGlobals.TireRadius self.notify.debug('circleStartTime = %s' % circleStartTime) self.scoreMovie.append( Parallel( LerpScaleInterval(self.scoreCircle, time, Point3(scaleXY, scaleXY, 1.0)), SoundInterval(self.scoreCircleSound, duration=time, startTime=circleStartTime))) circleStartTime += time startScore = self.scorePanels[scorePanelIndex].getScore() destScore = self.newScores[scorePanelIndex] self.notify.debug('for avId %d, startScore=%d, newScores=%d' % (avId, startScore, destScore)) def increaseScores(t, scorePanelIndex=scorePanelIndex, startScore=startScore, destScore=destScore): oldScore = self.scorePanels[scorePanelIndex].getScore() diff = destScore - startScore newScore = int(startScore + diff * t) if newScore > oldScore: base.playSfx(self.countSound) self.scorePanels[scorePanelIndex].setScore(newScore) self.scores[scorePanelIndex] = newScore duration = (destScore - startScore) * IceGameGlobals.ScoreCountUpRate tireNp = self.tireDict[avId]['tireNodePath'] self.scoreMovie.append( Parallel( LerpFunctionInterval(increaseScores, duration), Sequence( LerpColorScaleInterval(tireNp, duration / 6.0, VBase4(1, 0, 0, 1)), LerpColorScaleInterval(tireNp, duration / 6.0, VBase4(1, 1, 1, 1)), LerpColorScaleInterval(tireNp, duration / 6.0, VBase4(1, 0, 0, 1)), LerpColorScaleInterval(tireNp, duration / 6.0, VBase4(1, 1, 1, 1)), LerpColorScaleInterval(tireNp, duration / 6.0, VBase4(1, 0, 0, 1)), LerpColorScaleInterval(tireNp, duration / 6.0, VBase4(1, 1, 1, 1))))) curScale += distance self.scoreMovie.append( Func(self.sendUpdate, 'reportScoringMovieDone', [])) self.scoreMovie.start()
def __getGeyserTrack(): track = Sequence(Func(showEntity, geyserMound, cog), Func(showEntity, geyserWater, cog), LerpScaleInterval(geyserWater, 1.0, scaleUpPoint, startScale=GagGlobals.PNT3NEAR0), Wait(0.5 * geyserHold), LerpScaleInterval(geyserWater, 0.5, GagGlobals.PNT3NEAR0, startScale=scaleUpPoint), LerpScaleInterval(geyserMound, 0.5, GagGlobals.PNT3NEAR0), Func(geyserWater.removeNode), Func(geyserMound.removeNode), Func(self.removeEntity, entity)) return track