def loadAssets(self): """Load our assets.""" self.root = render.attachNewNode('golfSpot-%d' % self.index) self.root.setPos(*self.positions[self.index]) self.ballModel = loader.loadModel('phase_6/models/golf/golf_ball') self.ballColor = VBase4(1, 1, 1, 1) if self.index < len(GolfGlobals.PlayerColors): self.ballColor = VBase4(*GolfGlobals.PlayerColors[self.index]) self.ballModel.setColorScale(self.ballColor) self.ballModel.reparentTo(self.root) self.club = loader.loadModel('phase_6/models/golf/putter') self.clubLookatSpot = self.root.attachNewNode('clubLookat') self.clubLookatSpot.setY(-(GolfGlobals.GOLF_BALL_RADIUS + 0.1)) # create a collision sphere to trigger when we touch the ball # Make a trigger sphere so we can detect when the local avatar # runs up to the controls. We bury the sphere mostly under # the floor to minimize accidental collisions. cs = CollisionSphere(0, 0, 0, 1) cs.setTangible(0) cn = CollisionNode(self.triggerName) cn.addSolid(cs) cn.setIntoCollideMask(ToontownGlobals.WallBitmask) self.trigger = self.root.attachNewNode(cn) self.trigger.stash() self.hitBallSfx = loader.loadSfx('phase_6/audio/sfx/Golf_Hit_Ball.mp3')
def getFadeInTrack(): fadeInTrack = LerpColorScaleInterval(self.nodePath, 0.5, colorScale=VBase4(1, 1, 1, 1), startColorScale=VBase4( 0, 0, 0, 0), blendType='easeOut') return fadeInTrack
def __init__(self, model, data, cellWidth): MazeBase.__init__(self, model, data, cellWidth) self._initWaterCoolers() self.elevatorPos = self.maze.find('**/elevator_loc').getPos(render) self.exitPos = self.maze.find('**/exit_loc').getPos(render) self.maze.flattenStrong() self._clearColor = VBase4(base.win.getClearColor()) self._clearColor.setW(1.0) base.win.setClearColor(VBase4(0.0, 0.0, 0.0, 1.0)) if __debug__ and ConfigVariableBool('cogdomaze-dev', False).getValue(): self._initCollisionVisuals()
def _initFog(self): self.fog = Fog("FlyingFog") self.fog.setColor(VBase4(0.8, 0.8, 0.8, 1.0)) self.fog.setLinearRange(100.0, 400.0) self._renderFog = render.getFog() render.setFog(self.fog)
def load(self): self.maze = Maze(CogdoMazeGameGlobals.TempMazeFile) #self.maze.maze.setColorScale(0.0, 0, 5.0, 1.0) self.maze.setScale(2, 1.75) self.guiMgr = CogdoMazeGuiManager(self.maze) self.audioMgr = CogdoMazeAudioManager() self.toonId2Door = {} self.keyIdToKey = {} self.players = [] self.toonId2Player = {} self.lockId2Lock = {} self.localPlayer = CogdoMazeLocalPlayer(len(self.players), base.localAvatar, self, self.guiMgr) self._addPlayer(self.localPlayer) # TEMP... self.sprites = loader.loadModel("cogdominium/mazeSprites.egg") # Create door pos = self.maze.tile2world(int(self.maze.width / 2), self.maze.height - 1) gridPos = self.maze.world2tile(pos[0], pos[1]) # TEMP openDoorModel = self.sprites.find("**/door_open") openDoorModel.setScale(8) openDoorModel.setZ(0.25) closedDoorModel = self.sprites.find("**/door_closed") closedDoorModel.setScale(8) closedDoorModel.setZ(0.25) self.door = CogdoMazeDoor(closedDoorModel, openDoorModel) self.door.setPosition(pos[0], pos[1] - 0.05) self.door.offstage() self.guiMgr.mazeMapGui.addDoor(gridPos[0], gridPos[1], VBase4(1, 1, 1, 1)) # load key model, keys will be placed when everyone's there self.fuseModels = ( self.sprites.find("**/fuse_white"), self.sprites.find("**/fuse_blue"), self.sprites.find("**/fuse_yellow"), self.sprites.find("**/fuse_red"), ) for fuse in self.fuseModels: fuse.setScale(2) fuse.setBillboardPointEye() self.fuseBoxModels = ( (self.sprites.find("**/fusebox_white"), self.sprites.find("**/fusebox_white_plugged")), (self.sprites.find("**/fusebox_blue"), self.sprites.find("**/fusebox_blue_plugged")), (self.sprites.find("**/fusebox_yellow"), self.sprites.find("**/fusebox_yellow_plugged")), (self.sprites.find("**/fusebox_red"), self.sprites.find("**/fusebox_red_plugged")), ) for fuseBox in self.fuseBoxModels: fuseBox[0].setScale(4) fuseBox[1].setScale(4) #self._initFog() self.accept(self.distGame.getRemoteActionEventName(), self.handleRemoteAction)
def _initFog(self): self.fog = Fog("MazeFog") self.fog.setColor(VBase4(0.3, 0.3, 0.3, 1.0)) self.fog.setLinearRange(0.0, 100.0) self._renderFog = render.getFog() render.setFog(self.fog)
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 __displayGolfSpotAdvice(self, task): """Display golfSpot advice on the screen.""" if self.golfSpotAdviceLabel == None: self.golfSpotAdviceLabel = DirectLabel( text=TTLocalizer.BossbotGolfSpotAdvice, text_fg=VBase4(1, 1, 1, 1), text_align=TextNode.ACenter, relief=None, pos=(0, 0, 0.69), scale=0.1)
def createMeterInterval(self, icon, meter, time): """Create and return the meter interval.""" ivalDarkness = LerpScaleInterval(meter, time, scale=Vec3(1, 1, 1), startScale=Vec3(1, 0.001, 0.001)) flashingTrack = Sequence() flashDuration = 10 if time > flashDuration: flashingTrack.append(Wait(time - flashDuration)) for i in range(10): flashingTrack.append( Parallel( LerpColorScaleInterval(icon, 0.5, VBase4(1, 0, 0, 1)), icon.scaleInterval(0.5, 1.25))) flashingTrack.append( Parallel( LerpColorScaleInterval(icon, 0.5, VBase4(1, 1, 1, 1)), icon.scaleInterval(0.5, 1))) retIval = Parallel(ivalDarkness, flashingTrack) return retIval
def showExiting(self): """Indicate that we've sent an exiting message to AI.""" if self.closeButton: self.closeButton.destroy() self.closeButton = DirectLabel( relief=None, text=TTLocalizer.BossbotGolfSpotLeaving, pos=(1.05, 0, -0.88), text_pos=(0, 0), text_scale=0.06, text_fg=VBase4(1, 1, 1, 1), ) self.__cleanupGolfSpotAdvice()
def __enableControlInterface(self): """Enable the control interface.""" gui = loader.loadModel("phase_3.5/models/gui/avatar_panel_gui") self.closeButton = DirectButton( image=( gui.find("**/CloseBtn_UP"), gui.find("**/CloseBtn_DN"), gui.find("**/CloseBtn_Rllvr"), gui.find("**/CloseBtn_UP"), ), relief=None, scale=2, text=TTLocalizer.BossbotGolfSpotLeave, text_scale=0.04, text_pos=(0, -0.07), text_fg=VBase4(1, 1, 1, 1), pos=(1.05, 0, -0.82), command=self.__exitGolfSpot, ) self.accept('escape', self.__exitGolfSpot) self.accept('control', self.__controlPressed) self.accept('control-up', self.__controlReleased) self.accept('InputState-forward', self.__upArrow) self.accept('InputState-reverse', self.__downArrow) self.accept('InputState-turnLeft', self.__leftArrow) self.accept('InputState-turnRight', self.__rightArrow) taskMgr.add(self.__watchControls, 'watchGolfSpotControls') # In case they don't figure it out, hit them over the head # with it after a few seconds. taskMgr.doMethodLater(5, self.__displayGolfSpotAdvice, self.golfSpotAdviceName) #taskMgr.doMethodLater(10, self.__displayMagnetAdvice, # self.magnetAdviceName) # Up in the sky, it's hard to read what people are saying. #NametagGlobals.setOnscreenChatForced(1) self.arrowVert = 0 self.arrowHorz = 0 if self.powerBar: self.powerBar.show()
def __init__(self, cr): DistributedObject.__init__(self, cr) self._waitingStartLabel = DirectLabel( text=TTL.MinigameWaitingForOtherPlayers, text_fg=VBase4(1, 1, 1, 1), relief=None, pos=(-0.6, 0, -0.75), scale=0.075) self._waitingStartLabel.hide() self.loadFSM = ClassicFSM.ClassicFSM( 'DistCogdoGame.loaded', [ State.State('NotLoaded', self.enterNotLoaded, self.exitNotLoaded, ['Loaded']), State.State('Loaded', self.enterLoaded, self.exitLoaded, ['NotLoaded']) ], # Initial state 'NotLoaded', # Final state 'NotLoaded') self.fsm = ClassicFSM.ClassicFSM( 'DistCogdoGame', [ State.State('Intro', self.enterIntro, self.exitIntro, ['WaitServerStart']), State.State('WaitServerStart', self.enterWaitServerStart, self.exitWaitServerStart, ['Game']), State.State('Game', self.enterGame, self.exitGame, ['Finish']), State.State('Finish', self.enterFinish, self.exitFinish, ['Off']), State.State('Off', self.enterOff, self.exitOff, ['Intro']) ], # Initial state 'Off', # Final state 'Off') self.fsm.enterInitialState()
def _updateVictoryBar(self): if not ( hasattr(self, "_victoryBalanceBar") and self._victoryBalanceBar): return netDistance = 0 for cog in self.cogs: netDistance = netDistance + cog.targetDistance teamDistance = netDistance/6.0 self._victoryBalanceBarOrange.setScale(PartyGlobals.CogActivityBarStartScale + \ (teamDistance * 10 * PartyGlobals.CogActivityBarUnitScale),1.0,1.0) #self._victoryBalanceBar["value"] = 50 + (netDistance/6 * 100) self._victoryBalanceBarPie.setX(PartyGlobals.CogActivityVictoryBarPiePos[0] + \ (teamDistance * 10 *PartyGlobals.CogActivityBarPieUnitMove)) self._victoryBalanceBarPie.setY(PartyGlobals.CogActivityVictoryBarPiePos[1]) self._victoryBalanceBarPie.setZ(PartyGlobals.CogActivityVictoryBarPiePos[2]) if teamDistance>0.0: self._victoryBalanceBarArrow.setColor(PartyGlobals.CogActivityColors[1]) elif teamDistance<0.0: self._victoryBalanceBarArrow.setColor(PartyGlobals.CogActivityColors[0]) else: self._victoryBalanceBarArrow.setColor(VBase4(1.0,1.0,1.0,1.0))
def enterFree(self): """Handle entering the free state.""" assert self.notify.debugStateCall(self) if self.fadeTrack: self.fadeTrack.finish() self.fadeTrack = None # Wait a few seconds before neutralizing the scale; maybe the # same avatar wants to come right back (after his 5-second # timeout). self.restoreScaleTrack = Sequence(Wait(6), self.getRestoreScaleInterval(), name="restoreScaleTrack") self.restoreScaleTrack.start() if self.avId == localAvatar.doId: # Five second timeout on grabbing the same crane again. Go # get a different crane! if not self.isDisabled(): self.ballModel.setAlphaScale(0.3) self.ballModel.setTransparency(1) taskMgr.doMethodLater(5, self.__allowDetect, self.triggerName) self.fadeTrack = Sequence(Func(self.ballModel.setTransparency, 1), self.ballModel.colorScaleInterval( 0.2, VBase4(1, 1, 1, 0.3)), name='fadeTrack-enterFree') self.fadeTrack.start() else: # Other players can grab this crane immediately. self.trigger.unstash() self.accept(self.triggerEvent, self.__hitTrigger) self.avId = 0
def __init__(self, cr, doJellyBeans=True, doTricks=False, texture=None): DistributedPartyTrampolineActivity.notify.debug("__init__") DistributedPartyActivity.__init__( self, cr, PartyGlobals.ActivityIds.PartyTrampoline, PartyGlobals.ActivityTypes.GuestInitiated, wantLever=False, wantRewardGui=True, ) self.doJellyBeans = doJellyBeans self.doTricks = doTricks self.texture = texture self.toon = None self.trampHeight = 3.6 self.trampK = 400.0 # spring constant self.normalTrampB = 2.5 # spring damping self.leavingTrampB = 8.0 # increase damping to slow toon faster when leaving self.trampB = self.normalTrampB self.g = -32.0 # acceleration due to gravity self.jumpBoost = 330.0 self.beginningBoost = 500.0 self.beginningBoostThreshold = self.trampHeight + 1.5 self.earlyJumpThreshold = 75.0 self.boingThreshold = 300.0 self.turnFactor = 120.0 self.stepDT = 0.001 self.targetCameraPos = Point3(0.0, 40.0, 10.0) # relative to toon self.cameraSpeed = 2.0 self.hopOffPos = Point3(16.0, 0.0, 0.0) # relative to tramp self.indicatorFactor = 0.0095 self.dropShadowCutoff = 15.0 self.minHeightForText = 15.0 self.heightTextOffset = -0.065 self.beanOffset = 0.5 self.guiBeanOffset = -0.02 self.jumpTextShown = False self.toonJumped = False self.turnLeft = False self.turnRight = False self.leavingTrampoline = False self.toonVelocity = 0.0 self.topHeight = 0.0 self.lastPeak = 0.0 self.beginRoundInterval = None self.hopOnAnim = None self.hopOffAnim = None self.flashTextInterval = None # Jelly Beans self.numJellyBeans = PartyGlobals.TrampolineNumJellyBeans # These are in PartyGlobals so they can be available to the AI. self.jellyBeanBonus = PartyGlobals.TrampolineJellyBeanBonus self.jellyBeanStartHeight = 20.0 self.jellyBeanStopHeight = 90.0 self.jellyBeanColors = [ VBase4(1.0, 0.5, 0.5, 1.0), VBase4(0.5, 1.0, 0.5, 1.0), VBase4(0.5, 1.0, 1.0, 1.0), VBase4(1.0, 1.0, 0.4, 1.0), VBase4(0.4, 0.4, 1.0, 1.0), VBase4(1.0, 0.5, 1.0, 1.0), ] delta = (self.jellyBeanStopHeight - self.jellyBeanStartHeight) / (self.numJellyBeans - 1) self.jellyBeanPositions = [ self.jellyBeanStartHeight + n * delta for n in range(self.numJellyBeans) ] self.doSimulateStep = False
def __init__(self, cr): DistributedObject.__init__(self, cr) base.cogdoGame = self self._waitingStartLabel = DirectLabel( text = TTL.MinigameWaitingForOtherPlayers, text_fg = VBase4(1,1,1,1), relief = None, pos = (-0.6, 0, -0.75), scale = 0.075) self._waitingStartLabel.hide() self.loadFSM = ClassicFSM.ClassicFSM( 'DistCogdoGame.loaded', [State.State('NotLoaded', self.enterNotLoaded, self.exitNotLoaded, ['Loaded']), State.State('Loaded', self.enterLoaded, self.exitLoaded, ['NotLoaded'])], # Initial state 'NotLoaded', # Final state 'NotLoaded') self.fsm = ClassicFSM.ClassicFSM( 'DistCogdoGame', [State.State('Intro', self.enterIntro, self.exitIntro, ['WaitServerStart']), State.State('WaitServerStart', self.enterWaitServerStart, self.exitWaitServerStart, ['Game']), State.State('Game', self.enterGame, self.exitGame, ['Finish']), State.State('Finish', self.enterFinish, self.exitFinish, ['Off']), State.State('Off', self.enterOff, self.exitOff, ['Intro'])], # Initial state 'Off', # Final state 'Off') self.fsm.enterInitialState() self.difficultyOverride = None self.exteriorZoneOverride = None self._gotInterior = StateVar(False) self._toonsInEntranceElev = StateVar(False) self._wantStashElevator = StateVar(False) self._stashElevatorFC = FunctionCall(self._doStashElevator, self._toonsInEntranceElev, self._gotInterior, self._wantStashElevator, )
"Unlock", "EnterDoor", "RevealLock", "RevealDoor", "GameOver", )) GameDuration = 180.0 ToonRunSpeed = 9.778 OverheadCameraAngle = math.radians(60) OverheadCameraDistance = 30 LockColors = ( VBase4(1, 1, 1, 1), VBase4(0, 0, 1, 1), VBase4(1, 1, 0, 1), VBase4(1, 0, 0, 1), ) LockNames = ("White", "Blue", "Yellow", "Red") #=============================================================================== # AUDIO #=============================================================================== MusicFiles = { "normal": "phase_9/audio/bgm/CHQ_FACT_bg.ogg", "suspense": "phase_7/audio/bgm/encntr_general_bg_indoor.ogg", "timeRunningOut": "phase_7/audio/bgm/encntr_suit_winning_indoor.ogg",
'tigerStripe': 'phase_4/maps/BeanbodyZebraStripes6.png', 'turtle': 'phase_4/maps/BeanbodyTurtle.png', 'giraffe': 'phase_4/maps/BeanbodyGiraffe1.png', 'leopard': 'phase_4/maps/BeanbodyLepord2.png', 'tummy': 'phase_4/maps/BeanbodyTummy6.png', } FeetTextures = { 'normal': 'phase_4/maps/BeanFoot6.png', 'turtle': 'phase_4/maps/BeanFootTurttle.png', 'giraffe': 'phase_4/maps/BeanFootYellow3.png', 'leopard': 'phase_4/maps/BeanFootYellow3.png', } AllPetColors = ( VBase4(1.0, 1.0, 1.0, 1.0), VBase4(0.96875, 0.691406, 0.699219, 1.0), VBase4(0.933594, 0.265625, 0.28125, 1.0), VBase4(0.863281, 0.40625, 0.417969, 1.0), VBase4(0.710938, 0.234375, 0.4375, 1.0), VBase4(0.570312, 0.449219, 0.164062, 1.0), VBase4(0.640625, 0.355469, 0.269531, 1.0), VBase4(0.996094, 0.695312, 0.511719, 1.0), VBase4(0.832031, 0.5, 0.296875, 1.0), VBase4(0.992188, 0.480469, 0.167969, 1.0), VBase4(0.996094, 0.898438, 0.320312, 1.0), VBase4(0.996094, 0.957031, 0.597656, 1.0), VBase4(0.855469, 0.933594, 0.492188, 1.0), VBase4(0.550781, 0.824219, 0.324219, 1.0), VBase4(0.242188, 0.742188, 0.515625, 1.0), VBase4(0.304688, 0.96875, 0.402344, 1.0),
) TeamActivityNeitherTeam = 3 # special value indicating neither team TeamActivityTextScale = 0.135 # How long it counts down waiting for more players before it begins TeamActivityStartDelay = 8.0 TeamActivityDefaultMinPlayersPerTeam = 1 TeamActivityDefaultMaxPlayersPerTeam = 4 TeamActivityDefaultDuration = 60.0 # How long does the tallying up results lasts TeamActivityDefaultConclusionDuration = 4.0 TeamActivityStatusColor = VBase4(1.0, 1.0, 0.65, 1.0) #=============================================================================== # Cog-O-War (aka Party Cog "Pinata" Activity) #=============================================================================== CogActivityBalanceTeams = True CogActivityStartDelay = 15.0 CogActivityConclusionDuration = 12 CogActivityDuration = 90 CogActivityMinPlayersPerTeam = 1 CogActivityMaxPlayersPerTeam = 4 CogActivityColors = ( VBase4(0.22, 0.40, 0.98, 1.0), # Blue - R:55, G:101, B:248 VBase4(1.0, 0.43, 0.04, 1.0) # Orange - R:255, G:109, B:10
"dnaName": "cc", "cellWalkPeriod": 160, "toonDamage": 2.0, "scale": 1.33, "hp": 1, "memos": 2, } NumSuits = (4, 5, 5) BossSpinTime = 1.0 BossSpinCount = 2 BlinkFrequency = 1.0 BlinkSpeed = 0.5 BlinkColor = VBase4(1.0, 0.4, 0.4, 1.0) SuitsModifier = (0, 6, 9) DamageModifier = 9.0 DropShakeEnabled = True BossShakeEnabled = True DropShakeStrength = 4.0 DropMaxDistance = 20.0 BossShakeStrength = 1.2 BossMaxDistance = 25.0 BossShakeTime = 0.53
Level.ObstacleTypes = PythonUtil.Enum(('Whirlwind', 'Fan', 'Minion')) Level.PlatformTypes = PythonUtil.Enum( ('Platform', 'StartPlatform', 'EndPlatform')) Level.PlatformType2SpawnOffset = { Level.PlatformTypes.Platform: 2.5, Level.PlatformTypes.StartPlatform: 5.0, Level.PlatformTypes.EndPlatform: 5.0, } Level.QuadLengthUnits = 170 Level.QuadVisibilityAhead = 1 Level.QuadVisibilityBehind = 0 Level.StartPlatformLength = 55 Level.StartPlatformHeight = 20 Level.EndPlatformLength = 55 Level.EndPlatformHeight = 0 Level.FogColor = VBase4(0.18, 0.19, 0.32, 1.0) Level.RenderFogStartFactor = 0.22 Level.GatherablesDefaultSpread = 1.0 Level.NumMemosInRing = 6 Level.PropellerSpinDuration = 10.0 Level.QuadsByDifficulty = { 1: (2, 4, 5), 2: (1, 3, 7), 3: (6, 8), } Level.DifficultyOrder = { 2000: (1, 1, 1, 2, 1), 1000: (1, 1, 2, 2, 1), 5000: (1, 2, 1, 2, 2), 4000: (1, 2, 1, 2, 3, 2), 3000: (1, 2, 2, 3, 2, 3),