def __init__(self): self._serialNum = -1 self._memoModel = CogdoUtil.loadModel('memo', 'shared').find('**/memo') self._propellerModel = CogdoUtil.loadFlyingModel('propellers').find('**/mesh') self._powerUpModels = {} for type, modelName in Globals.Level.PowerupType2Model.items(): model = CogdoUtil.loadFlyingModel(modelName).find('**/' + Globals.Level.PowerupType2Node[type]) self._powerUpModels[type] = model model.setTransparency(True) model.setScale(0.5)
def __init__(self, serialNum, model = None, pitch = 0, triggerRadius = 1.0, spinRate = 60): if model is None: model = CogdoUtil.loadModel('joke', 'shared') model.setP(pitch) self._spinRate = spinRate CogdoGameGatherable.__init__(self, serialNum, model, triggerRadius, name='CogdoMemo') return
def initFlash(self): model = CogdoUtil.loadFlyingModel('gatherableFlash_card') texName = Globals.Level.GatherableType2TextureName[self.type] tex = model.findTexture(texName) tex.setWrapU(Texture.WMRepeat) tex.setWrapV(Texture.WMRepeat) del model self.ts = TextureStage('ts') self.ts.setMode(TextureStage.MCombine) self.ts.setSort(1) self.ts.setCombineRgb(TextureStage.CMInterpolate, TextureStage.CSPrevious, TextureStage.COSrcColor, TextureStage.CSTexture, TextureStage.COSrcColor, TextureStage.CSConstant, TextureStage.COSrcColor) self.ts.setCombineAlpha( TextureStage.CMInterpolate, TextureStage.CSPrevious, TextureStage.COSrcAlpha, TextureStage.CSTexture, TextureStage.COSrcAlpha, TextureStage.CSConstant, TextureStage.COSrcAlpha) self._model.setTexture(self.ts, tex) dur = Globals.Gameplay.GatherableFlashTime self.flashLoop = Sequence( LerpFunctionInterval(self.setTextureAlphaFunc, fromData=1.0, toData=0.25, duration=dur / 2.0, blendType='easeInOut'), LerpFunctionInterval(self.setTextureAlphaFunc, fromData=0.25, toData=1.0, duration=dur / 2.0, blendType='easeInOut'), Wait(1.0), name='%s.flashLoop-%s' % (self.__class__.__name__, self.serialNum))
def __init__(self, game, id, x, y): NodePath.__init__(self, 'dropNode%s' % id) self.game = game self.id = id self.reparentTo(hidden) self.setPos(x, y, 0) shadow = loader.loadModel('phase_3/models/props/square_drop_shadow') shadow.setZ(0.2) shadow.setBin('ground', 10) shadow.setColor(1, 1, 1, 1) shadow.reparentTo(self) self.shadow = shadow drop = CogdoUtil.loadMazeModel('cabinetSmFalling') roll = random.randint(-15, 15) drop.setHpr(0, 0, roll) drop.setZ(Globals.DropHeight) self.collTube = CollisionTube(0, 0, 0, 0, 0, 4, Globals.DropCollisionRadius) self.collTube.setTangible(0) name = Globals.DropCollisionName self.collNode = CollisionNode(name) self.collNode.addSolid(self.collTube) self.collNodePath = drop.attachNewNode(self.collNode) self.collNodePath.hide() self.collNodePath.setTag('isFalling', str('True')) drop.reparentTo(self) self.drop = drop self._dropSfx = base.cogdoGameAudioMgr.createSfxIval('drop', volume=0.6)
def createRedTapeRing(self): self.redTapeRing = CogdoUtil.loadFlyingModel('redTapeRing') self.redTapeRing.setTwoSided(True) self.redTapeRing.reparentTo(self.toon) self.redTapeRing.hide() self.redTapeRing.setScale(1.25) self.redTapeRing.setZ(self.toon.getHeight() / 2.0)
def _initModel(self): codeFrameGap = Globals.BossCodeFrameGap codeFrameWidth = Globals.BossCodeFrameWidth self._model = CogdoUtil.loadMazeModel('bossCog', group='gui') self._model.reparentTo(self) self._model.find('**/frame').setBin('fixed', 1) titleLabelPos = self._model.find('**/title_label_loc').getPos() self._titleLabel = DirectLabel( parent=self, relief=None, scale=Globals.BossGuiTitleLabelScale, text=TTLocalizer.CogdoMazeGameBossGuiTitle.upper(), pos=titleLabelPos, text_align=TextNode.ACenter, text_fg=(0, 0, 0, 1), text_shadow=(0, 0, 0, 0), text_font=ToontownGlobals.getSuitFont()) self._titleLabel.setBin('fixed', 1) bossCard = self._model.find('**/bossCard') self._openDoor = self._model.find('**/doorOpen') self._closedDoor = self._model.find('**/doorClosed') self._openDoor.stash() spacingX = codeFrameWidth + codeFrameGap startX = -0.5 * ((self._codeLength - 1) * spacingX - codeFrameGap) for i in xrange(self._codeLength): marker = CogdoMazeBossCodeFrame(i, self._code[i], bossCard) marker.reparentTo(self) marker.setPos(bossCard, startX + spacingX * i, 0, 0) self._markers.append(marker) bossCard.removeNode()
def _initModel(self): baseName = '**/tt_t_gui_cmg_miniMap_' cardModel = CogdoUtil.loadMazeModel('miniMap_cards', group='gui') cm = CardMaker('bg') cm.setFrame(-1.1, 1.1, -1.1, 1.1) bg = self.attachNewNode(cm.generate()) bg.setColor(*self._bgColor) bg.setBin('fixed', 0) frame = cardModel.find(baseName + 'frame') frame.reparentTo(self) frame.setScale(2.5) frame.setPos(0.01, 0, -0.01) self._entrance = cardModel.find(baseName + 'entrance') self._entrance.reparentTo(self) self._entrance.setScale(0.35) self._entrance.hide() self._exit = NodePath('exit') self._exit.setScale(0.35) self._exit.reparentTo(self) self._exitOpen = cardModel.find(baseName + 'exitOpen') self._exitOpen.reparentTo(self._exit) self._exitClosed = cardModel.find(baseName + 'exitClosed') self._exitClosed.reparentTo(self._exit) self._suitMarkerTemplate = cardModel.find(baseName + 'cogIcon') self._suitMarkerTemplate.detachNode() self._suitMarkerTemplate.setScale(0.225) self._waterCoolerTemplate = cardModel.find(baseName + 'waterDrop') self._waterCoolerTemplate.detachNode() self._waterCoolerTemplate.setScale(0.225) self._exit.hide() cardModel.removeNode()
def _initModel(self): self._laffMeterModel = loader.loadModel( 'phase_3/models/gui/laff_o_meter') self._model = CogdoUtil.loadFlyingModel('progressMeter', group='gui') self._model.reparentTo(self) self._model.setBin('fixed', 0) self._lineStart = self._model.find('**/start_loc').getZ() self._lineEnd = self._model.find('**/end_loc').getZ() self._lineDistance = abs(self._lineEnd - self._lineStart)
def __init__(self, object, name, collisionRadius): self.object = object self.splat = CogdoUtil.loadMazeModel('splash') self.splat.setBillboardPointEye() self.splat.setBin('fixed', 40) self.splat.setDepthTest(False) self.splat.setDepthWrite(False) self.splatTrack = None self._splatSfxIval = base.cogdoGameAudioMgr.createSfxIval('splat') self.initGagCollision(name, collisionRadius)
def _initModel(self): self.setPos(Globals.Gui.FuelPos2D[0], 0.0, Globals.Gui.FuelPos2D[1]) self.gui = CogdoUtil.loadFlyingModel('propellerMeter', group='gui') self.gui.reparentTo(self) self.gui.setBin('fixed', 0) self.healthBar = self.gui.find('**/healthBar') self.healthBar.setBin('fixed', 1) self.healthBar.setColor(*Globals.Gui.FuelNormalColor) bottomBarLocator = self.gui.find('**/bottomOfBar_loc') bottomBarPos = bottomBarLocator.getPos(render) topBarLocator = self.gui.find('**/topOfBar_loc') topBarPos = topBarLocator.getPos(render) zDist = topBarPos.getZ() - bottomBarPos.getZ() self.fuelLowIndicator = self.gui.find('**/fuelLowIndicator') self.fuelLowIndicator.setBin('fixed', 2) pos = self.fuelLowIndicator.getPos(render) newPos = pos newPos.setZ(bottomBarPos.getZ() + zDist * Globals.Gameplay.FuelLowAmt) self.fuelLowIndicator.setPos(render, newPos) self.fuelVeryLowIndicator = self.gui.find('**/fuelVeryLowIndicator') self.fuelVeryLowIndicator.setBin('fixed', 2) pos = self.fuelVeryLowIndicator.getPos(render) newPos = pos newPos.setZ(bottomBarPos.getZ() + zDist * Globals.Gameplay.FuelVeryLowAmt) self.fuelVeryLowIndicator.setPos(render, newPos) self.propellerMain = self.gui.find('**/propellers') self.propellerMain.setBin('fixed', 3) self.propellerHead = self.gui.find('**/propellerHead') self.propellerHead.setBin('fixed', 4) self.blades = [] self.activeBlades = [] index = 1 blade = self.propellerMain.find('**/propeller%d' % index) while not blade.isEmpty(): self.blades.append(blade) index += 1 blade = self.propellerMain.find('**/propeller%d' % index) for blade in self.blades: self.activeBlades.append(blade) self.bladeNumberLabel = DirectLabel( parent=self.propellerHead, relief=None, pos=(Globals.Gui.FuelNumBladesPos2D[0], 0, Globals.Gui.FuelNumBladesPos2D[1]), scale=Globals.Gui.FuelNumBladesScale, text=str(len(self.activeBlades)), text_align=TextNode.ACenter, text_fg=(0.0, 0.0, -0.002, 1), text_shadow=(0.75, 0.75, 0.75, 1), text_font=ToontownGlobals.getInterfaceFont()) self.bladeNumberLabel.setBin('fixed', 5) return
def createPropeller(self): self.propellerSmoke = DustCloud.DustCloud(self.toon, wantSound=False) self.propellerSmoke.setBillboardPointEye() self.propellerSmoke.setBin('fixed', 5002) self.backpack = CogdoUtil.loadFlyingModel('propellerPack') self.backpack.setScale(1.3) self.backpack.setHpr(180.0, 0.0, 0.0) self.backpackInstances = [] self.backpackTextureCard = CogdoUtil.loadFlyingModel( 'propellerPack_card') parts = self.toon.getTorsoParts() for part in parts: backpackInstance = part.attachNewNode('backpackInstance') animal = self.toon.style.getAnimal() bodyScale = ToontownGlobals.toonBodyScales[animal] backpackHeight = ToontownGlobals.torsoHeightDict[ self.toon.style.torso] * bodyScale - 0.5 backpackInstance.setPos(0.0, -0.325, backpackHeight) self.backpackInstances.append(backpackInstance) self.backpack.instanceTo(backpackInstance) self.propInstances = [] self.propeller = CogdoUtil.loadFlyingModel('toonPropeller') for part in self.backpackInstances: propInstance = part.attachNewNode('propInstance') propInstance.setPos(0.0, -0.275, 0.0) propInstance.setHpr(0.0, 20.0, 0.0) propInstance.setScale(1.0, 1.0, 1.25) self.propInstances.append(propInstance) self.propeller.instanceTo(propInstance) self.blades = [] self.activeBlades = [] index = 1 blade = self.propeller.find('**/propeller%d' % index) while not blade.isEmpty(): self.blades.append(blade) index += 1 blade = self.propeller.find('**/propeller%d' % index) for blade in self.blades: self.activeBlades.append(blade)
def __init__(self, nest, index, suitDnaName='le'): FSM.__init__(self, 'CogdoFlyingLegalEagle') self.defaultTransitions = { 'Off': ['Roost'], 'Roost': ['TakeOff', 'Off'], 'TakeOff': ['LockOnToon', 'LandOnNest', 'Off'], 'LockOnToon': ['RetreatToNest', 'ChargeUpAttack', 'Off'], 'ChargeUpAttack': ['RetreatToNest', 'Attack', 'Off'], 'Attack': ['RetreatToSky', 'Off'], 'RetreatToSky': ['Cooldown', 'Off'], 'Cooldown': ['LockOnToon', 'LandOnNest', 'Off'], 'RetreatToNest': ['LandOnNest', 'Off'], 'LandOnNest': ['Roost', 'Off'] } self.index = index self.nest = nest self.target = None self.isEagleInterested = False self.collSphere = None self.suit = Suit.Suit() d = SuitDNA.SuitDNA() d.newSuit(suitDnaName) self.suit.setDNA(d) self.suit.reparentTo(render) swapAvatarShadowPlacer(self.suit, 'legalEagle-%sShadowPlacer' % index) self.suit.setPos(self.nest.getPos(render)) self.suit.setHpr(-180, 0, 0) self.suit.stash() self.prop = None self.attachPropeller() head = self.suit.find('**/joint_head') self.interestConeOrigin = self.nest.attachNewNode('fakeHeadNodePath') self.interestConeOrigin.setPos( render, head.getPos(render) + Vec3(0, Globals.LegalEagle.InterestConeOffset, 0)) self.attackTargetPos = None self.startOfRetreatToSkyPos = None pathModel = CogdoUtil.loadFlyingModel('legalEaglePaths') self.chargeUpMotionPath = Mopath.Mopath(name='chargeUpMotionPath-%i' % self.index) self.chargeUpMotionPath.loadNodePath(pathModel.find('**/charge_path')) self.retreatToSkyMotionPath = Mopath.Mopath( name='retreatToSkyMotionPath-%i' % self.index) self.retreatToSkyMotionPath.loadNodePath( pathModel.find('**/retreat_path')) audioMgr = base.cogdoGameAudioMgr self._screamSfx = audioMgr.createSfx('legalEagleScream', self.suit) self.initIntervals() self.suit.nametag.setNametag2d(None) self.suit.nametag.setNametag3d(None) return
def _initModel(self, type='joke_card'): self._countLabel = DirectLabel( parent=self, relief=None, pos=(0.0625, 0, -0.025), scale=CogdoGameConsts.MemoGuiTextScale, text=str(0), text_fg=CogdoGameConsts.MemoGuiTextColor, text_shadow=(0.2, 0.2, 0.2, 1), text_align=TextNode.ALeft, text_font=ToontownGlobals.getToonFont()) self._memoIcon = CogdoUtil.loadModel(type, game='shared', group='gui') self._memoIcon.reparentTo(self) self._memoIcon.setScale(MEMOICON_SCALE) return
def __init__(self, openSfx = None, closeSfx = None): NodePath.__init__(self, 'CogdoGameExit') self._model = CogdoUtil.loadModel('exitDoor') self._model.reparentTo(self) self._leftDoor = self._model.find('**/left_door') self._rightDoor = self._model.find('**/right_door') self._openSfx = openSfx or base.loader.loadSfx('phase_9/audio/sfx/CHQ_VP_door_open.ogg') self._closeSfx = closeSfx or base.loader.loadSfx('phase_9/audio/sfx/CHQ_VP_door_close.ogg') self._elevatorPoints = [] for point in ElevatorConstants.ElevatorPoints: self._elevatorPoints.append(point[0]) self._currentSlot = 0 self._ival = None self._open = True self._toon2track = {} self.close(animate=False)
def __init__(self, serialNum, model=None, pitch=0, triggerRadius=1.0, spinRate=60): if model is None: node = CogdoUtil.loadModel('memo', 'shared') model = node.find('**/memo') model.detachNode() node.removeNode() model.setP(pitch) self._spinRate = spinRate CogdoGameGatherable.__init__(self, serialNum, model, triggerRadius, name='CogdoMemo') return
def __init__(self, id, toon): FSM.__init__(self, 'CogdoMazePlayer') CogdoMazeSplattable.__init__( self, toon, '%s-%i' % (Globals.PlayerCollisionName, id), 0.5) self.id = id self.toon = toon self.defaultTransitions = { 'Off': ['Ready'], 'Ready': ['Normal', 'Off'], 'Normal': ['Hit', 'Done', 'Off'], 'Hit': ['Normal', 'Done', 'Off'], 'Done': ['Off'] } self.toon.reparentTo(render) self.gagModel = CogdoUtil.loadMazeModel('waterBalloon') self.equippedGag = None self._toonHitSfx = base.cogdoGameAudioMgr.createSfx( 'toonHit', self.toon) self._throwSfx = base.cogdoGameAudioMgr.createSfxIval('throw') self.accept(toon.getDisableEvent(), self.removed) self.request('Off')
def loadAndBuildLevel(self, safezoneId): levelNode = NodePath('level') frameModel = CogdoUtil.loadFlyingModel('level') startPlatformModel = CogdoUtil.loadFlyingModel('levelStart') ver = '_org' if self.isOrg else '' endPlatformModel = CogdoUtil.loadFlyingModel('levelEnd%s' % ver) for fan in frameModel.findAllMatches('**/*wallFan'): fan.flattenStrong() frameModel.find('**/fogOpaque').setBin('background', 1) frameModel.find('**/ceiling').setBin('background', 2) frameModel.find('**/fogTranslucent_bm').setBin('fixed', 1) frameModel.find('**/wallR').setBin('opaque', 2) frameModel.find('**/wallL').setBin('opaque', 2) frameModel.find('**/fogTranslucent_top').setBin('fixed', 2) frameModel.getChildren().reparentTo(levelNode) if not self.isOrg: levelNode.hide() self._level = CogdoFlyingLevel(self._parent, levelNode, startPlatformModel, endPlatformModel, self.quadLengthUnits, self.quadVisibiltyAhead, self.quadVisibiltyBehind) if Globals.Dev.WantTempLevel: quads = Globals.Dev.DevQuadsOrder else: levelInfo = Globals.Level.DifficultyOrder[safezoneId] quads = [] for difficulty in levelInfo: quadList = Globals.Level.QuadsByDifficulty[difficulty] quads.append(quadList[self._rng.randint(0, len(quadList) - 1)]) for i in quads: ver = '_org' if self.isOrg else '' filePath = CogdoUtil.getModelPath('quadrant%i%s' % (i, ver), 'flying') quadModel = loader.loadModel(filePath) for np in quadModel.findAllMatches('**/*lightCone*'): CogdoUtil.initializeLightCone(np, 'fixed', 3) self._level.appendQuadrant(quadModel) self._level.ready()
def __init__(self): self._index = -1 self._whirlwindModel = CogdoUtil.loadFlyingModel('whirlwind').find( '**/whirlwind') self._fanModel = CogdoUtil.loadFlyingModel('streamer').find( '**/streamer')
def _loadAndBuildMazeModel(self, flatten=False): self.getMazeData() self._model = NodePath('CogdoMazeModel') levelModel = CogdoUtil.loadMazeModel('level') self.quadrants = [] quadrantUnitSize = int(self.quadrantSize * self.cellWidth) frameActualSize = self.frameWallThickness * self.cellWidth size = quadrantUnitSize + frameActualSize halfWidth = int(self.width / 2) halfHeight = int(self.height / 2) i = 0 for y in xrange(self.height): for x in xrange(self.width): ax = (x - halfWidth) * size ay = (y - halfHeight) * size extension = '' if hasattr(getBase(), 'air'): extension = '.bam' filepath = self.quadrantData[i][0] + extension angle = self.quadrantData[i][2] m = self._createQuadrant(filepath, i, angle, quadrantUnitSize) m.setPos(ax, ay, 0) m.reparentTo(self._model) self.quadrants.append(m) i += 1 quadrantHalfUnitSize = quadrantUnitSize * 0.5 barrierModel = CogdoUtil.loadMazeModel('grouping_blockerDivider').find( '**/divider') y = 3 for x in xrange(self.width): if x == (self.width - 1) / 2: continue ax = (x - halfWidth) * size ay = (y - halfHeight) * size - quadrantHalfUnitSize - ( self.cellWidth - 0.5) b = NodePath('barrier') barrierModel.instanceTo(b) b.setPos(ax, ay, 0) b.reparentTo(self._model) offset = self.cellWidth - 0.5 for x in (0, 3): for y in xrange(self.height): ax = ( x - halfWidth ) * size - quadrantHalfUnitSize - frameActualSize + offset ay = (y - halfHeight) * size b = NodePath('barrier') barrierModel.instanceTo(b) b.setPos(ax, ay, 0) b.setH(90) b.reparentTo(self._model) offset -= 2.0 barrierModel.removeNode() levelModel.getChildren().reparentTo(self._model) for np in self._model.findAllMatches('**/*lightCone*'): CogdoUtil.initializeLightCone(np, 'fixed', 3) if flatten: self._model.flattenStrong() return self._model
def _getRandomLine(self, lineList): return CogdoUtil.getRandomDialogueLine(lineList, self._rng)
def load(self, cogdoMazeFactory, numSuits, bossCode): self._initAudio() self.maze = cogdoMazeFactory.createCogdoMaze() suitSpawnSpot = self.maze.createRandomSpotsList(numSuits, self.distGame.randomNumGen) self.guiMgr = CogdoMazeGuiManager(self.maze, bossCode) self.suits = [] self.suitsById = {} self.shakers = [] self.toonsThatRevealedDoor = [] self.quake = 0 self.dropCounter = 0 self.drops = {} self.gagCounter = 0 self.gags = [] self.hackTemp = False self.dropGen = RandomNumGen(self.distGame.doId) self.gagTimeoutTasks = [] self.finished = False self.lastBalloonTimestamp = None difficulty = self.distGame.getDifficulty() serialNum = 0 for i in xrange(numSuits[0]): suitRng = RandomNumGen(self.distGame.doId + serialNum * 10) suit = CogdoMazeBossSuit(serialNum, self.maze, suitRng, difficulty, startTile=suitSpawnSpot[0][i]) self.addSuit(suit) self.guiMgr.mazeMapGui.addSuit(suit.suit) serialNum += 1 for i in xrange(numSuits[1]): suitRng = RandomNumGen(self.distGame.doId + serialNum * 10) suit = CogdoMazeFastMinionSuit(serialNum, self.maze, suitRng, difficulty, startTile=suitSpawnSpot[1][i]) self.addSuit(suit) serialNum += 1 for i in xrange(numSuits[2]): suitRng = RandomNumGen(self.distGame.doId + serialNum * 10) suit = CogdoMazeSlowMinionSuit(serialNum, self.maze, suitRng, difficulty, startTile=suitSpawnSpot[2][i]) self.addSuit(suit) serialNum += 1 self.toonId2Door = {} self.keyIdToKey = {} self.players = [] self.toonId2Player = {} cellPos = (int(self.maze.width / 2), self.maze.height - 1) pos = self.maze.tile2world(*cellPos) self._exit = CogdoMazeExit() self._exit.reparentTo(render) self._exit.setPos(self.maze.exitPos) self._exit.stash() self.guiMgr.mazeMapGui.placeExit(*cellPos) self._collNode2waterCooler = {} for waterCooler in self.maze.getWaterCoolers(): pos = waterCooler.getPos(render) tpos = self.maze.world2tile(pos[0], pos[1]) self.guiMgr.mazeMapGui.addWaterCooler(*tpos) self._collNode2waterCooler[waterCooler.collNode] = waterCooler self.pickups = [] self.gagModel = CogdoUtil.loadMazeModel('waterBalloon') self._movie = CogdoMazeGameIntro(self.maze, self._exit, self.distGame.randomNumGen) self._movie.load()