def enterFallBCK(self, ts=0, callback=None, extraArgs=[]): self.playingAnim = 'fallb' self.play('fallb') Sequence(Wait(0.5), SoundInterval(self.fallSfx, node=self)).start()
def enterReward(self): taskMgr.remove('shaderTickUpdate') self.loseCount = 0 base.cam.reparentTo(self.gameObject.fishingSpot) self.gameObject.tutorialManager.showTutorial( InventoryType.FishingCaughtFish) self.gameObject.lure.showHelpText(None) self.gameObject.distributedFishingSpot.showTutorial = False self.gameObject.sfx['ambience'].stop() if self.gameObject.fishManager.activeFish.myData['size'] in [ 'small', 'medium' ]: self.animationSequence = Sequence( Wait(0.40000000000000002), Func(localAvatar.loop, 'fsh_smallSuccess'), Wait(localAvatar.getDuration('fsh_smallSuccess')), Func(localAvatar.loop, 'fsh_idle'), Wait(1.0)) self.animationSequence.loop() else: localAvatar.loop('fsh_bigSuccess') i = random.randint(0, 2) if self.gameObject.fishManager.activeFish.myData['size'] == 'small': if i == 0: self.gameObject.sfx['fishOutSmall01'].play() elif i == 1: self.gameObject.sfx['fishOutSmall02'].play() else: self.gameObject.sfx['fishOutSmall03'].play() elif self.gameObject.fishManager.activeFish.myData['size'] == 'medium': if i == 0: self.gameObject.sfx['fishOutMedium01'].play() elif i == 1: self.gameObject.sfx['fishOutMedium02'].play() else: self.gameObject.sfx['fishOutMedium01'].play() elif self.gameObject.fishManager.activeFish.myData['size'] == 'large': if i == 0: self.gameObject.sfx['fishOutLarge01'].play() elif i == 1: self.gameObject.sfx['fishOutLarge02'].play() else: self.gameObject.sfx['fishOutLarge03'].play() self.gameObject.sfx['successCaught'].play() fishId = int(self.gameObject.fishManager.activeFish.myData['id']) self.gameObject.distributedFishingSpot.d_caughtFish( fishId, self.gameObject.fishManager.activeFish.weight) self.gameObject.oceanEye = False self.gameObject.playRewardSequence() self.gameObject.fishManager.activeFish.actor.loop('reelIdle') self.gameObject.fishManager.activeFish.setY(0.0) self.gameObject.fishManager.activeFish.setHpr(0.0, 0.0, 0.0) self.gameObject.fishManager.activeFish.fishStatusIconNodePath.hide() self.gameObject.hideFishAndBackdrop() self.gameObject.fishManager.activeFish.show() self.gameObject.fishManager.activeFish.actor.show() taskMgr.remove('%s_StartFighting' % self.gameObject.fishManager.activeFish.getName()) taskMgr.remove('%s_StopFighting' % self.gameObject.fishManager.activeFish.getName()) taskMgr.remove('%s_GoFighting' % self.gameObject.fishManager.activeFish.getName())
def updateAspectRatio(self): fadeSequence = Sequence(Func(base.transitions.fadeOut, .2), Wait(.2), Func(self.setRatio), Func(base.transitions.fadeIn, .2)).start()
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 elif numBarrelsSaved > 1: resultStr = TTLocalizer.CogThiefBarrelsSaved % { 'num': numBarrelsSaved } elif 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()
def addNewAttacker(self, suitId, length=5): if not suitId in self.attackers: self.attackers.append(suitId) Sequence(Wait(length), Func(self.removeAttacker, suitId)).start()
def doNextPlayerTurn(self, skip=0, draw=0, reversedNow=0): if self.turnOrder is None: return turns = 1 if self.currentTurn is None: self.currentTurn = 0 else: if skip: turns = 2 if self.turnsReversed: for _ in range(turns): self.__prevPlayerTurn() else: for _ in range(turns): self.__nextPlayerTurn() if draw: for _ in range(draw): ai = None if self.ais > 0 and self.playerMgr: ai = self.playerMgr.getPlayerByID( self.turnOrder[self.currentTurn]) if not ai: self.d_takeNewCard(self.turnOrder[self.currentTurn], self.pickNewCard()) else: card = self.pickNewCard() ai.addCard(card) self.stopTiming() seq = Sequence() if draw == 2: seq.append( Func( self.d_setPlayByPlay, UGG.EVENT_DRAWING_TWO % self.getAvatarName(self.turnOrder[self.currentTurn]))) seq.append(Wait(1.5)) if self.turnsReversed: self.__prevPlayerTurn() else: self.__nextPlayerTurn() elif draw == 4: seq.append( Func( self.d_setPlayByPlay, UGG.EVENT_DRAWING_FOUR % self.getAvatarName(self.turnOrder[self.currentTurn]))) seq.append(Wait(1.5)) elif skip: seq.append( Func(self.d_setPlayByPlay, UGG.EVENT_SKIPPED_TURN % self.getPrevAvatarName())) seq.append(Wait(1.5)) elif reversedNow: seq.append(Func(self.d_setPlayByPlay, UGG.EVENT_REVERSE)) seq.append(Wait(1.5)) seq.append( Func( self.d_setPlayByPlay, UGG.EVENT_NEW_TURN % self.getAvatarNamePossesive(self.turnOrder[self.currentTurn]))) seq.append(Func(self.d_setPlayerTurn, self.turnOrder[self.currentTurn])) seq.append(Func(self.startTiming)) seq.start() self.turnSeq = seq
def __blink(self, task): blink = Sequence(LerpColorScaleInterval(self.suit, Globals.BlinkSpeed, VBase4(1.0, 1.0, 1.0, 1.0)), LerpColorScaleInterval(self.suit, Globals.BlinkSpeed, Globals.BlinkColor)) blink.start() return Task.again
def teamScored(self, team): self.scoreByTeam[team] += 1 self.sendUpdate('incrementTeamScore', [team]) if self.scoreByTeam[team] >= GGG.CTF_SCORE_CAP: self.sendUpdate('teamWon', [team]) Sequence(Wait(10.0), Func(self.d_gameOver)).start()
def equip(self): if not BaseHitscan.equip(self): return False self.sprayParticleRoot = render.attachNewNode('sprayParticleRoot') self.sprayParticleRoot.setLightOff(1) self.sprayParticleRoot.hide(CIGlobals.ShadowCameraBitmask) if self.isLocal(): self.released = True self.waterBar = WaterBar() self.__updateWaterBar() self.waterBar.reparentTo(base.a2dLeftCenter) self.waterBar.setScale(0.6) self.waterBar.setX(0.166) self.hydrant = loader.loadModel('phase_5/models/props/battle_hydrant.bam') self.model.reparentTo(self.hydrant) self.model.pose('chan', 2) self.hoseJoint = self.model.controlJoint(None, "modelRoot", "joint_x") self.hydrantNode = self.avatar.attachNewNode('hydrantNode') self.hydrantNode.clearTransform(self.avatar.getGeomNode().getChild(0)) self.hydrantNode.setHpr(0, 0, 0) self.hydrantScale = self.hydrantNode.attachNewNode('hydrantScale') self.hydrant.reparentTo(self.hydrantScale) self.avatar.pose('firehose', 30) self.avatar.update(0) torso = self.avatar.getPart('torso') if 'dgm' in self.avatar.getTorso(): self.hydrant.setPos(torso, 0, 0, -1.85) else: self.hydrant.setPos(torso, 0, 0, -1.45) hbase = self.hydrant.find('**/base') hbase.setColor(1, 1, 1, 0.5) hbase.setPos(self.avatar, 0, 0, 0) self.avatar.loop('neutral') tAppearDelay = 0.7 dAnimHold = 5.1 dHoseHold = 0.7 tSprayDelay = 2.8 track = Parallel() toonTrack = Sequence(Wait(tAppearDelay), Func(self.avatar.setForcedTorsoAnim, 'firehose'), self.getAnimationTrack('firehose', endFrame = 30), Func(self.__doBob)) propTrack = Sequence(Func(self.hydrantNode.reparentTo, self.avatar), LerpScaleInterval(self.hydrantScale, tAppearDelay * 0.5, Point3(1, 1, 1.4), startScale=Point3(1, 1, 0.01)), LerpScaleInterval(self.hydrantScale, tAppearDelay * 0.3, Point3(1, 1, 0.8), startScale=Point3(1, 1, 1.4)), LerpScaleInterval(self.hydrantScale, tAppearDelay * 0.1, Point3(1, 1, 1.2), startScale=Point3(1, 1, 0.8)), LerpScaleInterval(self.hydrantScale, tAppearDelay * 0.1, Point3(1, 1, 1), startScale=Point3(1, 1, 1.2)), ActorInterval(self.model, 'chan', endFrame = 30)) track.append(toonTrack) track.append(propTrack) self.setAnimTrack(track, startNow = True) if self.isFirstPerson(): self.hydrantNode.hide() return True
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 start_move(self, dir): die = self.world.component_for_entity(self.player, components.Die) spatial = self.world.component_for_entity(self.player, components.Spatial) orig_pos = spatial.path.get_pos() orig_quat = spatial.path.get_quat() target_pos = spatial.path.get_pos() target_quat = spatial.path.get_quat() next_number = None vector = core.Vec2(0, 0) if dir == 'N': vector.y += 1 target_quat *= core.LRotation((1, 0, 0), -90) next_number = die.die.north_number elif dir == 'E': vector.x += 1 target_quat *= core.LRotation((0, 1, 0), 90) next_number = die.die.east_number elif dir == 'S': vector.y -= 1 target_quat *= core.LRotation((1, 0, 0), 90) next_number = die.die.south_number elif dir == 'W': vector.x -= 1 target_quat *= core.LRotation((0, 1, 0), -90) next_number = die.die.west_number z_scale = math.sqrt(0.5) - 0.5 target_pos.xy += vector x, y = int(target_pos[0]), int(target_pos[1]) type = self.world.level.get_tile(x, y) if not type.is_passable( next_number, self.world.toggle_state ) and not base.mouseWatcherNode.is_button_down('pause'): self.moving = True Sequence( Parallel( spatial.path.posInterval(0.05, orig_pos * 0.9 + target_pos * 0.1, blendType='easeInOut'), LerpFunctionInterval( lambda x: spatial.path.set_z(math.sin(x) * z_scale), 0.05, toData=math.pi * 0.1, blendType='easeInOut'), spatial.path.quatInterval(0.05, orig_quat * 0.9 + target_quat * 0.1, blendType='easeInOut'), ), Parallel( spatial.path.posInterval(0.05, orig_pos, blendType='easeIn'), LerpFunctionInterval( lambda x: spatial.path.set_z(math.sin(x) * z_scale), 0.05, fromData=math.pi * 0.1, toData=0, blendType='easeIn'), spatial.path.quatInterval(0.05, orig_quat, blendType='easeIn'), ), Func(self.stop_move)).start() if type.value and type.value in '123456': self.world.die_icon.flash((1, 0, 0, 1)) if base.impassable_sound: base.impassable_sound.play() return False # Build up the animation; the parallel gets prepended to the sequence parallel = [ spatial.path.posInterval(0.25, target_pos), LerpFunctionInterval( lambda x: spatial.path.set_z(math.sin(x) * z_scale), 0.25, toData=math.pi), spatial.path.quatInterval(0.25, target_quat), ] sequence = [] if type == TileType.ice: if base.slide_sound: sequence.append(Func(base.slide_sound.play)) else: if base.move_sound: sequence.append(Func(base.move_sound.play)) while type == TileType.ice: target_pos.xy += vector x, y = int(target_pos[0]), int(target_pos[1]) type = self.world.level.get_tile(x, y) if type == TileType.ice: sequence.append(spatial.path.posInterval(0.25, target_pos)) else: sequence.append( spatial.path.posInterval(0.5, target_pos, blendType='easeOut')) if type == TileType.teleporter: # Find other teleporter. x, y = int(target_pos[0]), int(target_pos[1]) others = set(self.world.teleporters) others.discard((x, y)) if others: new_xy = others.pop() new_target_pos = core.Point3(target_pos) new_target_pos.xy = new_xy tile1 = self.world.tiles[(x, y)] tile2 = self.world.tiles[new_xy] tile1_path = self.world.component_for_entity( tile1, components.Spatial).path tile2_path = self.world.component_for_entity( tile2, components.Spatial).path tile1_path.set_pos(new_target_pos) tile2_path.set_pos(target_pos) elevation = (0, 0, 0.65) time = max((target_pos.xy - new_target_pos.xy).length() * 0.15, 0.35) if base.transport_sound: sequence.append(Func(base.transport_sound.play)) sequence.append( Parallel( Sequence( spatial.path.posInterval(0.25, target_pos + elevation, blendType='easeInOut'), spatial.path.posInterval(time, new_target_pos + elevation, blendType='easeInOut'), spatial.path.posInterval(0.25, new_target_pos, blendType='easeInOut'), ), Sequence( tile2_path.posInterval(0.25, target_pos + elevation, blendType='easeInOut'), tile2_path.posInterval(time, new_target_pos + elevation, blendType='easeInOut'), tile2_path.posInterval(0.25, new_target_pos, blendType='easeInOut'), ), Sequence( tile1_path.posInterval(0.25, new_target_pos - elevation, blendType='easeInOut'), tile1_path.posInterval(time, target_pos - elevation, blendType='easeInOut'), tile1_path.posInterval(0.25, target_pos, blendType='easeInOut'), ), )) if self.button_tile: # Make the button raised again button_path = self.world.component_for_entity( self.button_tile, components.Spatial).path button_pos = core.LPoint3(button_path.get_pos()) button_pos.z = 0.07 parallel.append(button_path.posInterval(0.25, button_pos)) if self.cracked_tile: # Break away the cracked tile if base.collapse_sound: base.collapse_sound.play() self.world.add_component(self.cracked_tile, components.Falling(drag=5.0)) self.cracked_tile = None if type == TileType.exit: self.winning_move = True self.lock() if type == TileType.cracked: self.cracked_tile = self.world.tiles[(x, y)] self.world.level.remove_tile(x, y) del self.world.tiles[(x, y)] sequence.append(Func(base.crack_sound.play)) if type == TileType.button: button_tile = self.world.tiles[(x, y)] button_path = self.world.component_for_entity( button_tile, components.Spatial).path button_pos = core.LPoint3(button_path.get_pos()) button_pos.z = 0.0 parallel.append(button_path.posInterval(0.25, button_pos)) parallel.append(Sequence(Wait(0.1), Func(self.world.toggle_button))) if base.button_sound: parallel.append(Func(base.button_sound.play)) self.button_tile = button_tile if dir == 'N': die.die.rotate_north() elif dir == 'E': die.die.rotate_east() elif dir == 'S': die.die.rotate_south() elif dir == 'W': die.die.rotate_west() self.moving = True sequence.insert(0, Parallel(*parallel)) sequence.append(Func(self.stop_move)) Sequence(*sequence).start() self.world.on_player_move() return True
def showSuit(self): self.show() fadeIn = Sequence(Func(self.setTransparency, 1), self.colorScaleInterval(0.6, colorScale=Vec4(1,1,1,1), startColorScale=Vec4(1,1,1,0)), Func(self.clearColorScale), Func(self.clearTransparency), Func(self.reparentTo, render)) fadeIn.start()
def enter_cube(self): self.play('exit', ['cube', 'hobot'], extra_interval=Sequence(Wait(3.0), Func(self.hide_scene_hobot)), callback=base.end_game, sound=self.sfx['exit'])
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 _initSfx(self): audioMgr = base.cogdoGameAudioMgr self._deathSoundIval = Sequence(audioMgr.createSfxIval('cogSpin', duration=1.6, startTime=0.6, volume=0.8, source=self.deathSuit), audioMgr.createSfxIval('cogDeath', volume=0.32, source=self.deathSuit))
def timeUp(self): self.sendUpdate('timeUp', []) Sequence(Wait(10.0), Func(self.d_gameOver)).start()
def __init__(self, gameObject=None): base.loadingScreen.beginStep('GameGUI', 3, 20) self.gameObject = gameObject gui = loader.loadModel('models/gui/toplevel_gui') guiIcons = loader.loadModel('models/textureCards/icons') weaponIcons = loader.loadModel('models/gui/gui_icons_weapon') fishingIcons = loader.loadModel('models/textureCards/fishing_icons') self.tackleBoxButton = DirectButton(parent=base.a2dBottomRight, relief=None, pos=(-0.53, 0.0, 0.1), scale=0.5, text=PLocalizer.FishingGui['Lures'], text_pos=(0, -0.15), text_scale=0.065, text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_font=PiratesGlobals.getPirateBoldOutlineFont(), image_pos=(0, 0, 0), image_scale=0.18, geom=(fishingIcons.find('**/pir_t_gui_fsh_tackleBasket'), fishingIcons.find('**/pir_t_gui_fsh_tackleBasket'), fishingIcons.find('**/pir_t_gui_fsh_tackleBasket_over')), geom_pos=(0, 0, 0), geom_scale=0.25, geom_color=(1.0, 1.0, 1.0, 1), sortOrder=2, command=self.toggleLureSelectionDialog) self.tackleBoxInterval = Sequence(self.tackleBoxButton.colorScaleInterval(0.5, Vec4(1.0, 0.6, 0.6, 1.0)), self.tackleBoxButton.colorScaleInterval(0.5, Vec4(1.0, 1.0, 1.0, 1.0))) self.exitButton = DirectButton(parent=base.a2dBottomRight, relief=None, pos=(-0.3, 0.0, 0.1), scale=0.5, text=PLocalizer.FishingGui['ExitButton'], text_pos=(0, -0.15), text_scale=0.065, text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_font=PiratesGlobals.getPirateBoldOutlineFont(), image_pos=(0, 0, 0), image_scale=0.18, geom=(fishingIcons.find('**/pir_t_gui_fsh_esc'), fishingIcons.find('**/pir_t_gui_fsh_esc'), fishingIcons.find('**/pir_t_gui_fsh_esc_over')), geom_pos=(0, 0, 0), geom_scale=0.25, geom_color=(1.0, 1.0, 1.0, 1), sortOrder=2, command=self.handleExitGame) self.OkDialog = None base.loadingScreen.tick() dialogText = PLocalizer.FishingGui['ChooseYourLure'] self.lureSelectionPanel = GuiPanel.GuiPanel(dialogText, 0.75, 0.5, True, 1) self.lureSelectionPanel.reparentTo(base.a2dBottomRight) self.lureSelectionPanel.setPos(-0.9, 0.0, 0.22) self.lureSelectionPanel.regularLureButton = DirectButton(parent=self.lureSelectionPanel, relief=None, pos=(0.2, 0, 0.25), scale=0.5, text='', text_pos=(0, 0), text_scale=PiratesGuiGlobals.TextScaleSmall, text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_font=PiratesGlobals.getPirateBoldOutlineFont(), image=fishingIcons.find('**/pir_t_gui_fsh_lureReg'), image_pos=(0, 0, 0), image_scale=0.18, geom=(gui.find('**/pir_t_gui_but_circle'), gui.find('**/pir_t_gui_but_circle'), gui.find('**/pir_t_gui_but_circle_over')), geom_pos=(0, 0, 0), geom_scale=1, geom_hpr=(0, 0, 90), geom_color=(1.0, 1.0, 1.0, 1), sortOrder=2, command=self.chooseRegularLure) self.lureSelectionPanel.regularLureButtonText = DirectLabel(parent=self.lureSelectionPanel, relief=None, text=PLocalizer.FishingGui['RegularLures'], text_align=TextNode.ARight, text_scale=PiratesGuiGlobals.TextScaleSmall, text_pos=(0.28, 0.15), text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_font=PiratesGlobals.getPirateBoldOutlineFont(), textMayChange=1) base.loadingScreen.tick() inv = localAvatar.getInventory() regQty = inv.getStackQuantity(InventoryType.RegularLure) self.lureSelectionPanel.regularLureQty = DirectLabel(parent=self.lureSelectionPanel, relief=None, text='x' + str(regQty), text_align=TextNode.ACenter, text_scale=PiratesGuiGlobals.TextScaleSmall, text_pos=(0.3, 0.2), text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_font=PiratesGlobals.getPirateBoldOutlineFont(), textMayChange=1) self.lureSelectionPanel.legendaryLureButton = DirectButton(parent=self.lureSelectionPanel, relief=None, pos=(0.55, 0.0, 0.25), scale=0.5, text='', text_pos=(0, 0), text_scale=PiratesGuiGlobals.TextScaleSmall, text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_font=PiratesGlobals.getPirateBoldOutlineFont(), image=fishingIcons.find('**/pir_t_gui_fsh_lureLegend'), image_pos=(0, 0, 0), image_scale=0.18, geom=(gui.find('**/pir_t_gui_but_circle'), gui.find('**/pir_t_gui_but_circle'), gui.find('**/pir_t_gui_but_circle_over')), geom_pos=(0, 0, 0), geom_scale=1, geom_hpr=(0, 0, 90), geom_color=(1.0, 1.0, 1.0, 1), sortOrder=2, command=self.chooseLegendaryLure) self.lureSelectionPanel.legendaryLureButtonText = DirectLabel(parent=self.lureSelectionPanel, relief=None, text=PLocalizer.FishingGui['LegendaryLures'], text_align=TextNode.ARight, text_scale=PiratesGuiGlobals.TextScaleSmall, text_pos=(0.65, 0.15), text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_font=PiratesGlobals.getPirateBoldOutlineFont(), textMayChange=1) inv = localAvatar.getInventory() legQty = inv.getStackQuantity(InventoryType.LegendaryLure) self.lureSelectionPanel.legendaryLureQty = DirectLabel(parent=self.lureSelectionPanel, relief=None, text='x' + str(legQty), text_align=TextNode.ACenter, text_scale=PiratesGuiGlobals.TextScaleSmall, text_pos=(0.66, 0.2), text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_font=PiratesGlobals.getPirateBoldOutlineFont(), textMayChange=1) self.lureSelectionPanel.hide() self.lureSelectionPanelShowing = False self.resultsScreen = FishingResults(self.gameObject) self.resultsScreen.hide() bestRod = self.gameObject.getAvatarsBestRod() if bestRod == -1: base.notify.error('Somehow the avatar got into the fishing game without a rod in their inventory!') if bestRod == ItemGlobals.FISHING_ROD_3: self.castPowerMeterModel = loader.loadModel('models/gui/pir_m_gui_fsh_fishingBarExpert') else: if bestRod == ItemGlobals.FISHING_ROD_2: self.castPowerMeterModel = loader.loadModel('models/gui/pir_m_gui_fsh_fishingBarNovice') else: self.castPowerMeterModel = loader.loadModel('models/gui/pir_m_gui_fsh_fishingBarBeginner') base.loadingScreen.tick() self.castPowerMeter = NodePath('castPowerMeter') self.castPowerMeter.reparentTo(base.a2dLeftCenter) self.castMeterBackground = self.castPowerMeterModel.find('**/background') self.castMeterBackground.setBin('fixed', 32) self.castMeterBackground.reparentTo(self.castPowerMeter) self.castMeterBar = self.castPowerMeterModel.find('**/meter') self.castMeterBar.setBin('fixed', 33) self.castMeterBar.reparentTo(self.castPowerMeter) self.castMeterBar.setColorScale(0.5, 0.5, 1.0, 1.0) self.castMeterFrame = self.castPowerMeterModel.find('**/bar') self.castMeterFrame.setBin('fixed', 34) self.castMeterFrame.reparentTo(self.castPowerMeter) self.castPowerMeter.setPos(0.137, 0, 0.228) self.castPowerMeter.setScale(1) self.lineHealthMeter = NodePath('lineHealthMeter') self.lineHealthMeter.reparentTo(base.a2dLeftCenter) self.lineHealthMeterModel = loader.loadModel('models/gui/pir_m_gui_fsh_fishingBarHealth') self.lineHealthMeterBackground = self.lineHealthMeterModel.find('**/background') self.lineHealthMeterBackground.setBin('fixed', 32) self.lineHealthMeterBackground.reparentTo(self.lineHealthMeter) self.lineHealthMeterBar = self.lineHealthMeterModel.find('**/meter') self.lineHealthMeterBar.setBin('fixed', 33) self.lineHealthMeterBar.reparentTo(self.lineHealthMeter) self.lineHealthMeterFrame = self.lineHealthMeterModel.find('**/bar') self.lineHealthMeterFrame.setBin('fixed', 34) self.lineHealthMeterFrame.reparentTo(self.lineHealthMeter) self.lineHealthMeter.setPos(0.137, 0, 0.25) self.lineHealthMeter.setScale(1) self.lineLengthLabel = TextPrinter() self.lineLengthLabel.text.setScale(1.2) self.lineLengthLabel.text.setHpr(0.0, 0.0, 0.0) self.lineLengthLabel.text['sortOrder'] = 200 self.lineLengthLabel.text.setBin('gui-fixed', 10) self.lineLengthLabel.text.setDepthTest(0) self.lineLengthLabel.text.setDepthWrite(0) self.lineLengthLabel.showText('0', (1, 1, 1, 1)) base.loadingScreen.endStep('GameGUI') return
def getDropIval(self): shadow = self.shadow drop = self.drop id = self.id hangTime = Globals.ShadowTime dropTime = Globals.DropTime dropHeight = Globals.DropHeight targetShadowScale = 0.5 targetShadowAlpha = 0.4 shadowScaleIval = LerpScaleInterval(shadow, dropTime, targetShadowScale, startScale=0) shadowAlphaIval = LerpColorScaleInterval( shadow, hangTime, Point4(1, 1, 1, targetShadowAlpha), startColorScale=Point4(1, 1, 1, 0)) shadowIval = Parallel(shadowScaleIval, shadowAlphaIval) startPos = Point3(0, 0, dropHeight) drop.setPos(startPos) dropIval = LerpPosInterval(drop, dropTime, Point3(0, 0, 0), startPos=startPos, blendType='easeIn') dropSoundIval = self._dropSfx dropSoundIval.node = self self.drop.setTransparency(1) def _setRandScale(t): self.drop.setScale(self, 1 - random.random() / 16, 1 - random.random() / 16, 1 - random.random() / 4) scaleChange = 0.4 + random.random() / 4 dropShakeSeq = Sequence( LerpScaleInterval(self.drop, 0.25, Vec3(1.0 + scaleChange, 1.0 + scaleChange / 2, 1.0 - scaleChange), blendType='easeInOut'), LerpScaleInterval(self.drop, 0.25, Vec3(1.0, 1.0, 1.0), blendType='easeInOut'), Func(self.disableCollisionDamage), LerpScaleInterval(self.drop, 0.2, Vec3(1.0 + scaleChange / 8, 1.0 + scaleChange / 8, 1.0 - scaleChange / 8), blendType='easeInOut'), LerpScaleInterval(self.drop, 0.2, Vec3(1.0, 1.0, 1.0), blendType='easeInOut'), LerpScaleInterval(self.drop, 0.15, Vec3(1.0 + scaleChange / 16, 1.0 + scaleChange / 16, 1.0 - scaleChange / 16), blendType='easeInOut'), LerpScaleInterval(self.drop, 0.15, Vec3(1.0, 1.0, 1.0), blendType='easeInOut'), LerpScaleInterval(self.drop, 0.1, Vec3(1.0 + scaleChange / 16, 1.0 + scaleChange / 8, 1.0 - scaleChange / 16), blendType='easeInOut'), LerpColorScaleInterval(self.drop, Globals.DropFadeTime, Vec4(1.0, 1.0, 1.0, 0.0))) ival = Sequence(Func(self.reparentTo, render), Parallel(Sequence(WaitInterval(hangTime), dropIval), shadowIval), Parallel(Func(self.game.dropHit, self, id), dropSoundIval, dropShakeSeq), Func(self.game.cleanupDrop, id), name='drop%s' % id) self.ival = ival return ival
def animToToon(self, timeStamp): self.stopTransition() if self.mode != 'suit': self.setToSuit() self.loadAnimToToonSfx() suitSoundPlayed = 0 toonSoundPlayed = 0 bldgNodes = self.getNodePaths() tracks = Parallel() for i in bldgNodes: name = i.getName() if name[0] == 's': hideTrack = Sequence(name=self.taskName('ToToonSuitFlatsTrack')) landmark = name.find('_landmark_') != -1 if not suitSoundPlayed: hideTrack.append(Func(base.playSfx, self.cogWeakenSound, 0, 1, None, 0.0)) hideTrack.append(self.createBounceTrack(i, 3, 1.2, TO_TOON_BLDG_TIME * 0.05, slowInitBounce=0.0)) hideTrack.append(self.createBounceTrack(i, 5, 0.8, TO_TOON_BLDG_TIME * 0.1, slowInitBounce=0.0)) hideTrack.append(self.createBounceTrack(i, 7, 1.2, TO_TOON_BLDG_TIME * 0.17, slowInitBounce=0.0)) hideTrack.append(self.createBounceTrack(i, 9, 1.2, TO_TOON_BLDG_TIME * 0.18, slowInitBounce=0.0)) realScale = i.getScale() hideTrack.append(LerpScaleInterval(i, TO_TOON_BLDG_TIME * 0.1, Vec3(realScale[0], realScale[1], 0.01))) if landmark: hideTrack.append(Func(i.removeNode)) else: hideTrack.append(Func(i.stash)) hideTrack.append(Func(i.setScale, Vec3(1))) if not suitSoundPlayed: suitSoundPlayed = 1 tracks.append(hideTrack) elif name[0] == 't': hideTrack = Sequence(name=self.taskName('ToToonFlatsTrack')) hideTrack.append(Wait(TO_TOON_BLDG_TIME * 0.5)) if not toonSoundPlayed: hideTrack.append(Func(base.playSfx, self.toonGrowSound, 0, 1, None, 0.0)) hideTrack.append(Func(i.unstash)) hideTrack.append(Func(i.setScale, Vec3(1, 1, 0.01))) if not toonSoundPlayed: hideTrack.append(Func(base.playSfx, self.toonSettleSound, 0, 1, None, 0.0)) hideTrack.append(self.createBounceTrack(i, 11, 1.2, TO_TOON_BLDG_TIME * 0.5, slowInitBounce=4.0)) tracks.append(hideTrack) if not toonSoundPlayed: toonSoundPlayed = 1 self.stopTransition() bldgMTrack = tracks localToonIsVictor = self.localToonIsVictor() if localToonIsVictor: base.localAvatar.loop('neutral') camTrack = self.walkOutCameraTrack() victoryRunTrack, delayDeletes = self.getVictoryRunTrack() trackName = self.taskName('toToonTrack') self._deleteTransitionTrack() if localToonIsVictor: freedomTrack1 = Func(self.cr.playGame.getPlace().fsm.request, 'walk') freedomTrack2 = Func(base.localAvatar.d_setParent, CIGlobals.SPRender) self.transitionTrack = Parallel(camTrack, Sequence(victoryRunTrack, bldgMTrack, freedomTrack1, freedomTrack2), name=trackName) else: self.transitionTrack = Sequence(victoryRunTrack, bldgMTrack, name=trackName) self.transitionTrack.delayDeletes = delayDeletes if localToonIsVictor: self.transitionTrack.start(0) else: self.transitionTrack.start(timeStamp) return
def requestPlaceCard(self, id, doId=None): if self.gameStarted: if doId is None: doId = self.air.getAvatarIdFromSender() if (self.isAvatarPresent(doId) and self.turnOrder[self.currentTurn] == doId and not self.winnerAnnounced): self.currentCard = id self.d_placeCard(doId, id) self.stopTiming() seq = Sequence() seq.append(Wait(1.2)) shouldSkip = 0 shouldDraw = 0 reversedNow = 0 isWild = 0 ai = None if self.ais > 0 and self.playerMgr: for player in self.playerMgr.getPlayers(): if player.getID() == doId: ai = player break if ai: ai.setDrawsThisTurn(0) if len(ai.getCards()) == 0: self.__handleAIWin(ai) return if (id[:2] == str(UGG.CARD_SKIP)): shouldSkip = 1 elif (id[:2] == str(UGG.CARD_REVERSE)): reversedNow = 1 if self.turnsReversed: self.turnsReversed = False else: self.turnsReversed = True elif (id[:2] == str(UGG.CARD_DRAW_TWO)): shouldDraw = 2 elif (id == str(UGG.CARD_WILD_DRAW_FOUR)): shouldDraw = 4 isWild = 1 elif (id == str(UGG.CARD_WILD)): isWild = 1 if isWild == 1: if not ai: seq.append( Func( self.d_setPlayByPlay, UGG.EVENT_CHOOSING_NEW_COLOR % self.getAvatarName( self.turnOrder[self.currentTurn]))) seq.append(Func(self.d_requestNewCardColor, doId)) else: seq.append( Func(self.d_setPlayByPlay, UGG.EVENT_CHOOSING_NEW_COLOR % ai.getName())) waitTime = random.uniform(2, 4) track = Sequence() track.append(Wait(waitTime)) track.append(Func(self.__handleWildCard, ai, id)) track.start() self.aiTrack = track else: seq.append( Func(self.doNextPlayerTurn, shouldSkip, shouldDraw, reversedNow)) self.turnSeq = seq seq.start() elif (self.isAvatarPresent(doId) and self.turnOrder[self.currentTurn] != doId and not self.winnerAnnounced): # Oops, the avatar must have selected their card at the last second, # and we missed it! Give them back the card they selected. self.d_takeNewCard(doId, id)
def walkOutCameraTrack(self): track = Sequence(Func(camera.reparentTo, render), Func(camera.setPosHpr, self.elevatorNodePath, 0, -32.5, 9.4, 0, 348, 0), Func(base.camLens.setMinFov, 52.0 / (4.0 / 3.0)), Wait(VICTORY_RUN_TIME), Func(camera.setPosHpr, self.elevatorNodePath, 0, -32.5, 17, 0, 347, 0), Func(base.camLens.setMinFov, 75.0 / (4.0 / 3)), Wait(TO_TOON_BLDG_TIME), Func(base.camLens.setMinFov, 52.0 / (4.0 / 3.0))) return track
def __handleAITurn(self, player): if len(player.getCards()) > 0: currentColor = self.currentCard[-2:] currentId = self.currentCard[:2] def hasPlaceableCardBeingDealt(): placeable = False for card in player.getDealingCards(): if (card[:2] == currentId or card[:2] == UGG.CARD_WILD or card[:2] == UGG.CARD_WILD_DRAW_FOUR or card[-2:] == currentColor or card[-2:] == self.newColor): placeable = True break return placeable for card in player.getCards(): if card[: 2] == UGG.CARD_WILD or card[:2] == UGG.CARD_WILD_DRAW_FOUR or card[:2] == currentId or card[ -2:] == currentColor or card[-2:] == self.newColor: if self.time >= 4: if player.getDrawsThisTurn() > 0: # It takes some time for the brain to realize that this is a good card to use # after drawing it. waitTime = random.uniform(0.6, 0.9) else: # We already have a good card to use in the deck, it takes some time # for a regular player to look through the deck and decide if it's a # good card or not. waitTime = random.uniform(0.45, self.time - 2.0) track = Sequence() track.append(Wait(waitTime)) track.append( Func(self.requestPlaceCard, card, player.getID())) track.start() self.turnSeq = track else: self.requestPlaceCard(card, doId=player.getID()) return placeableCard = hasPlaceableCardBeingDealt() if not placeableCard and player.getMaxDrawsPerTurn( ) == -1 or not placeableCard and player.getDrawsThisTurn( ) < player.getMaxDrawsPerTurn(): new_card = self.pickNewCard() player.addDealingCard(new_card) player.setDrawsThisTurn(player.getDrawsThisTurn() + 1) if self.time >= 2: waitTime = random.uniform(0.5, 1.5) track = Sequence() track.append(Wait(waitTime)) track.append(Func(player.addCard, new_card)) track.append(Func(player.removeDealingCard, new_card)) track.start() self.turnSeq = track else: waitTime = random.uniform(0.15, 0.45) track = Sequence() track.append(Wait(waitTime)) track.append(Func(player.addCard, new_card)) track.start() self.turnSeq = track placeable = hasPlaceableCardBeingDealt() self.__handleAITurn(player) elif player.getDrawsThisTurn() == self.maxDrawsPerTurn: # Wait out the clock, can't draw anymore. seq = Sequence() seq.append(Wait(self.time)) seq.append(Func(player.setDrawsThisTurn, 0)) seq.start() self.turnSeq = seq return elif hasPlaceableCardBeingDealt(): seq = Sequence() seq.append(Wait(0.75)) seq.append(Func(self.__handleAITurn, player)) seq.start() self.turnSeq = seq
def getDropIval(self, x, y, dropObjName, generation, num): objType = PartyGlobals.Name2DropObjectType[dropObjName] id = (generation, num) dropNode = hidden.attachNewNode('catchDropNode%s' % (id, )) dropNode.setPos(x, y, 0) shadow = self.dropShadow.copyTo(dropNode) shadow.setZ(PartyGlobals.CatchDropShadowHeight) shadow.setColor(1, 1, 1, 1) object = self.getObjModel(dropObjName) object.reparentTo(hidden) if dropObjName in ['watermelon', 'anvil']: objH = object.getH() absDelta = {'watermelon': 12, 'anvil': 15}[dropObjName] delta = (self.randomNumGen.random() * 2.0 - 1.0) * absDelta newH = objH + delta else: newH = self.randomNumGen.random() * 360.0 object.setH(newH) sphereName = 'FallObj%s' % (id, ) radius = self.ObjRadius if objType.good: radius *= lerp(1.0, 1.3, 0.5) collSphere = CollisionSphere(0, 0, 0, radius) collSphere.setTangible(0) collNode = CollisionNode(sphereName) collNode.setCollideMask(PartyGlobals.CatchActivityBitmask) collNode.addSolid(collSphere) collNodePath = object.attachNewNode(collNode) collNodePath.hide() if self.ShowObjSpheres: collNodePath.show() catchEventName = 'ltCatch' + sphereName def eatCollEntry(forward, collEntry): forward() self.accept( catchEventName, Functor(eatCollEntry, Functor(self.__handleCatch, id[0], id[1]))) def cleanup(self=self, dropNode=dropNode, id=id, event=catchEventName): self.ignore(event) dropNode.removeNode() duration = objType.fallDuration onscreenDuration = objType.onscreenDuration targetShadowScale = 0.3 if self.trickShadows: intermedScale = targetShadowScale * (self.OffscreenTime / self.BaselineDropDuration) shadowScaleIval = Sequence( LerpScaleInterval(shadow, self.OffscreenTime, intermedScale, startScale=0)) shadowScaleIval.append( LerpScaleInterval(shadow, duration - self.OffscreenTime, targetShadowScale, startScale=intermedScale)) else: shadowScaleIval = LerpScaleInterval(shadow, duration, targetShadowScale, startScale=0) targetShadowAlpha = 0.4 shadowAlphaIval = LerpColorScaleInterval( shadow, self.OffscreenTime, Point4(1, 1, 1, targetShadowAlpha), startColorScale=Point4(1, 1, 1, 0)) shadowIval = Parallel(shadowScaleIval, shadowAlphaIval) if self.useGravity: def setObjPos(t, objType=objType, object=object): z = objType.trajectory.calcZ(t) object.setZ(z) setObjPos(0) dropIval = LerpFunctionInterval(setObjPos, fromData=0, toData=onscreenDuration, duration=onscreenDuration) else: startPos = Point3(0, 0, self.MinOffscreenHeight) object.setPos(startPos) dropIval = LerpPosInterval(object, onscreenDuration, Point3(0, 0, 0), startPos=startPos, blendType='easeIn') ival = Sequence(Func(Functor(dropNode.reparentTo, self.root)), Parallel( Sequence( WaitInterval(self.OffscreenTime), Func(Functor(object.reparentTo, dropNode)), dropIval), shadowIval), Func(cleanup), name='drop%s' % (id, )) if objType == PartyGlobals.Name2DropObjectType['anvil']: ival.append(Func(self.playAnvil)) return ival
def showToonHitBySuit(self, avId, timestamp): toon = self.getAvatar(avId) if toon == None: return else: 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, 50), gravMult=0.55) 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), Wait(CTGG.LyingDownDuration - (flyDur - oldFlyDur)), 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 getRestoreScaleInterval(self): return Sequence()
def lerpLookAt(self, head, hpr, time = 1.0): self.lookAtTrack = Parallel(Sequence(LerpHprInterval(head, time, hpr, blendType='easeInOut'))) self.lookAtTrack.start() return 1
def accomodateToon(self, toon): toon.wrtReparentTo(self.root) toon.setPos(self.toonGolfOffsetPos) toon.setHpr(self.toonGolfOffsetHpr) return Sequence()
def enterRaceTransition(self): self.raceTrans = Sequence(Wait(0.5), Func(self.moveCameraToToon), Wait(4.5), Func(self.moveCameraToTop), Wait(4.5), Func(self.startCountdown)) self.raceTrans.start()
def getFlyBallSplatInterval(self, x, y, z, flyBallCode, throwerId): from toontown.toonbase import ToontownBattleGlobals from toontown.battle import BattleProps splatName = 'dust' splat = BattleProps.globalPropPool.getProp(splatName) splat.setBillboardPointWorld(2) color = ToontownGlobals.PieCodeColors.get(flyBallCode) if color: splat.setColor(*color) if flyBallCode == ToontownGlobals.PieCodeBossCog: self.notify.debug('changing color to %s' % self.ballColor) splat.setColor(self.ballColor) sound = loader.loadSfx('phase_11/audio/sfx/LB_evidence_miss.ogg') vol = 1.0 if flyBallCode == ToontownGlobals.PieCodeBossCog: sound = loader.loadSfx('phase_4/audio/sfx/Golf_Hit_Barrier_1.ogg') soundIval = SoundInterval(sound, node=splat, volume=vol) if flyBallCode == ToontownGlobals.PieCodeBossCog and localAvatar.doId == throwerId: vol = 1.0 soundIval = SoundInterval(sound, node=localAvatar, volume=vol) ival = Parallel(Func(splat.reparentTo, render), Func(splat.setPos, x, y, z), soundIval, Sequence(ActorInterval(splat, splatName), Func(splat.detachNode))) return ival
def __init__(self, name='track'): Sequence.__init__(self) self.name = name
def createLevel(self): self.tex1 = loader.loadTexture("tile1.png") self.tex2 = loader.loadTexture("tile2.png") self.tex3 = loader.loadTexture("tile3.png") self.tex_tile_nm = loader.loadTexture("tile2nm.png") self.tex_fs = loader.loadTexture("rnbw.png") self.ts_fs = TextureStage('ts_fs') self.tex1.setMagfilter(Texture.FTLinearMipmapLinear) self.tex1.setMinfilter(Texture.FTLinearMipmapLinear) self.tex2.setMagfilter(Texture.FTLinearMipmapLinear) self.tex2.setMinfilter(Texture.FTLinearMipmapLinear) self.tex3.setMagfilter(Texture.FTLinearMipmapLinear) self.tex3.setMinfilter(Texture.FTLinearMipmapLinear) self.tex_tile_nm.setMagfilter(Texture.FTLinearMipmapLinear) self.tex_tile_nm.setMinfilter(Texture.FTLinearMipmapLinear) ts = TextureStage('ts') for x in xrange(0, self.level.maxX): for y in xrange(0, self.level.maxY): if self.level.getHeight((x, y)) == 0: model = loader.loadModel('flattile') model.setScale(utils.TILE_SIZE) model.setPos(x * utils.TILE_SIZE, y * utils.TILE_SIZE, utils.GROUND_LEVEL) """ if (x == 0 or x == self.level.maxX-1) or (y==0 or y==self.level.maxY-1): model = loader.loadModel('halfcube') model.setScale(utils.TILE_SIZE) model.setPos(x*utils.TILE_SIZE, y*utils.TILE_SIZE, utils.GROUND_LEVEL) else: model = loader.loadModel('flattile') model.setScale(utils.TILE_SIZE) model.setPos(x*utils.TILE_SIZE, y*utils.TILE_SIZE, utils.GROUND_LEVEL) """ #model = loader.loadModel('halfcube') #model.setPos(x, y, 0) model.reparentTo(self.floor_np_list[int( x / self.chunk_size[0])][int(y / self.chunk_size[1])]) self.floor_tile_dict[(x, y)] = model elif self.level.getHeight((x, y)) == 1: model = loader.loadModel('halfcube') model.setScale(utils.TILE_SIZE) model.setPos(x * utils.TILE_SIZE, y * utils.TILE_SIZE, 0) model.reparentTo(self.floor_np_list[int( x / self.chunk_size[0])][int(y / self.chunk_size[1])]) self.floor_tile_dict[(x, y)] = model model = loader.loadModel('halfcube') model.setScale(utils.TILE_SIZE) model.setPos(x * utils.TILE_SIZE, y * utils.TILE_SIZE, utils.GROUND_LEVEL) model.setTexture(ts, self.tex1) #model.setTexture(self.ts_nm, self.tex_tile_nm) model.reparentTo(self.node_wall_original) else: for i in xrange(0, self.level.getHeight((x, y))): if i == 0: if (x == 0 or x == self.level.maxX - 1) or (y == 0 or y == self.level.maxY - 1): model = loader.loadModel('halfcube') model.setScale(utils.TILE_SIZE) model.setPos(x * utils.TILE_SIZE, y * utils.TILE_SIZE, utils.GROUND_LEVEL) else: model = loader.loadModel('flattile') model.setScale(utils.TILE_SIZE) model.setPos(x * utils.TILE_SIZE, y * utils.TILE_SIZE, utils.GROUND_LEVEL) model.reparentTo(self.floor_np_list[int( x / self.chunk_size[0])][int( y / self.chunk_size[1])]) self.floor_tile_dict[(x, y)] = model else: model = loader.loadModel('cube') model.setScale(utils.TILE_SIZE) model.setPos( x * utils.TILE_SIZE, y * utils.TILE_SIZE, (i - 1) * utils.TILE_SIZE + utils.GROUND_LEVEL) model.setTexture(ts, self.tex2) #model.setTexture(self.ts_nm, self.tex_tile_nm) model.reparentTo(self.node_wall_original) self.floor_np.setTexture(self.tex3) #Calculate and place walls between tiles for x, val in enumerate(self.level._grid): for y, val2 in enumerate(val): if val2 != None: # prvi parni, drugi neparni tile2_x, tile2_y, h = self.getWallPosition(x, y) if tile2_x == None: continue my_x = tile2_x my_y = tile2_y if val2.name == "Wall1": model = loader.loadModel("wall") model.setScale(utils.TILE_SIZE) model.setPos(my_x * utils.TILE_SIZE, my_y * utils.TILE_SIZE, utils.GROUND_LEVEL) model.setH(h) self.wall_dict[(my_x, my_y, h)] = model model.reparentTo(self.node_wall_original) elif val2.name == "Wall2": model = loader.loadModel("wall2") model.setScale(utils.TILE_SIZE) model.setPos(my_x * utils.TILE_SIZE, my_y * utils.TILE_SIZE, utils.GROUND_LEVEL) model.setH(h) model.setColor(0, 1, 0, 1) self.wall_dict[(my_x, my_y, h)] = model model.reparentTo(self.node_wall_original) elif val2.name == "HalfWall": model = loader.loadModel("wall2") model.setScale(utils.TILE_SIZE) model.flattenLight() model.setPos(my_x * utils.TILE_SIZE, my_y * utils.TILE_SIZE, utils.GROUND_LEVEL) model.setH(h) model.setColor(0, 0, 0, 1) model.setScale(1, 1, 0.4) self.wall_dict[(my_x, my_y, h)] = model model.reparentTo(self.node_wall_original) elif val2.name == "Ruin": model = loader.loadModel("wall2") model.setScale(utils.TILE_SIZE) model.setPos(my_x * utils.TILE_SIZE, my_y * utils.TILE_SIZE, utils.GROUND_LEVEL) model.setH(h) model.setColor(0.5, 0.8, 1, 0.6) model.setTransparency(TransparencyAttrib.MAlpha) model.reparentTo(self.node_forcewall_usable) s = Sequence( LerpColorInterval(model, 1, (0.13, 0.56, 0.78, 0.6)), LerpColorInterval(model, 1, (0.5, 0.8, 1, 0.6)), ) s.loop() model.setLightOff() elif val2.name == "ClosedDoor": model = loader.loadModel("door") model.setScale(utils.TILE_SIZE) model.setPos(my_x * utils.TILE_SIZE, my_y * utils.TILE_SIZE, utils.GROUND_LEVEL) model.setH(h) model.setColor(1, 0.0, 0, 0.0) self.dynamic_wall_dict[(my_x, my_y, h)] = model model.reparentTo(self.node_dynamic_wall_usable) elif val2.name == "OpenedDoor": model = loader.loadModel("door") model.setScale(utils.TILE_SIZE) model.setPos(my_x * utils.TILE_SIZE, my_y * utils.TILE_SIZE, utils.GROUND_LEVEL) model.setH(h) model.setScale(0.2, 1, 1) model.setColor(0.7, 0.2, 0.2, 0.0) self.dynamic_wall_dict[(my_x, my_y, h)] = model model.reparentTo(self.node_dynamic_wall_usable) elif val2.name == "ForceField": model = loader.loadModel("wall_fs") model.setScale(utils.TILE_SIZE) model.setPos(my_x * utils.TILE_SIZE, my_y * utils.TILE_SIZE, utils.GROUND_LEVEL) model.setH(h) model.setTexture(self.ts_fs, self.tex_fs) model.setTransparency(TransparencyAttrib.MAlpha) model.reparentTo(self.node_forcewall_usable) self.dynamic_wall_dict[(my_x, my_y, h)] = model model.setLightOff() #self.floor_usable_np.setShaderAuto() self.floor_usable_np.setTexture(self.tex3) self.markAllChunksDirty() self.dirty_walls = 1