def getLocationText(location, objective=None, verbose=True): # Let's handle when the location is None, this means we want to go # to the objective's assigner. OR if we're looking for an HQ officer. if location == 0 or not location and objective: # Let's figure out where the assigner is at, fam. if location == 0 or objective.assigner == 0: return 'Any Street\nAny Neighborhood' else: return getLocationText( NPCGlobals.NPCToonDict[objective.assigner][0], verbose=verbose) if location in ZoneUtil.ZoneId2Hood.keys(): if location == ZoneUtil.MinigameAreaId: return ZoneUtil.ZoneId2Hood.get(location) return '%s\n%s' % ('Any Street', ZoneUtil.ZoneId2Hood.get(location)) elif location in ZoneUtil.BranchZone2StreetName.keys(): streetName = ZoneUtil.BranchZone2StreetName.get(location) playground = ZoneUtil.ZoneId2Hood.get(location - (location % 1000)) return '%s\n%s' % (streetName, playground) elif location in ZoneUtil.zone2TitleDict.keys(): shop = ZoneUtil.zone2TitleDict.get(location)[0] streetZone = ZoneUtil.getBranchZone(location) if streetZone % 1000 >= 100: streetName = ZoneUtil.BranchZone2StreetName[streetZone] else: streetName = PLAYGROUND hoodName = ZoneUtil.getHoodId(streetZone, 1) if verbose: return '%s\n%s\n%s' % (shop, streetName, hoodName) else: return shop elif not location: return 'Any Street\nAny Playground'
def headOff(self): if self.index == 1: zoneId = base.localAvatar.getLastHood() hoodId = ZoneUtil.getHoodId(zoneId) else: zoneId = self.toZone hoodId = ZoneUtil.getHoodId(self.toZone) requestStatus = {'zoneId': zoneId, 'hoodId': hoodId, 'where': 'playground', 'avId': base.localAvatar.doId, 'loader': 'safeZoneLoader', 'shardId': None, 'wantLaffMeter': 1, 'how': 'teleportIn', 'prevZoneId': base.localAvatar.zoneId, 'slot': self.mySlot} self.cr.playGame.getPlace().doneStatus = requestStatus messenger.send(self.cr.playGame.getPlace().doneEvent) base.localAvatar.reparentTo(render) base.localAvatar.setPos(0, 0, 0) base.localAvatar.setHpr(0, 0, 0) base.localAvatar.walkControls.setCollisionsActive(1) self.localAvOnTrolley = False
def getTaskInfo(self, objective, speech=False): """ Returns a string that could be used as speech or for a quest note. It gives information about the quest and what you have to do. """ taskInfo = "" if speech: # If it's speech, add the objective's header (e.g Defeat, Recover, Deliver) to the beginning of the sentence. taskInfo += objective.Header + " " # Add objective specific task info taskInfo += objective.getTaskInfo(speech) if objective.AreaSpecific: # This objective is sometimes area specific. if objective.area == QuestGlobals.Anywhere: taskInfo += "\nAnywhere" if not speech else " anywhere" else: # Say what area the objective must be completed in. taskInfo += "\nin " + ZoneUtil.getHoodId( objective.area ) if not speech else " in " + ZoneUtil.getHoodId( objective.area) if speech: # Always put a period at the end of the sentence if it's speech! taskInfo += "." return taskInfo
def updateInfo(self): # Setup the location text. if (self.location in CIGlobals.ZoneId2Hood.keys()): self.quest.setLocationText( '%s\n%s' % (QuestGlobals.ANYWHERE, CIGlobals.ZoneId2Hood.get(self.location))) self.quest.setLocationY(0) elif (self.location in CIGlobals.BranchZone2StreetName.keys()): self.quest.setLocationText( '%s\n%s' % (CIGlobals.BranchZone2StreetName.get(self.location), CIGlobals.ZoneId2Hood.get(self.location - (self.location % 1000)))) self.quest.setLocationY(0) elif (self.location in CIGlobals.zone2TitleDict.keys()): shop = CIGlobals.zone2TitleDict.get(self.location)[0] streetZone = ZoneUtil.getBranchZone(self.location) if streetZone % 1000 >= 100: streetName = CIGlobals.BranchZone2StreetName[streetZone] else: streetName = QuestGlobals.PLAYGROUND hoodName = ZoneUtil.getHoodId(streetZone, 1) self.quest.setLocationText('%s\n%s\n%s' % (shop, streetName, hoodName)) self.quest.setLocationY(0.025) elif not self.location: self.quest.setLocationText(QuestGlobals.ANYWHERE)
def enter(self, hoodId, zoneId, avId): StateData.enter(self) whereName = ZoneUtil.getWhereName(zoneId) loaderName = ZoneUtil.getLoaderName(zoneId) self.fsm.request('quietZone', [{'zoneId': zoneId, 'hoodId': hoodId, 'where': whereName, 'how': 'teleportIn', 'avId': avId, 'shardId': None, 'loader': loaderName}])
def headBackToMinigameArea(self): whereName = ZoneUtil.getWhereName(ZoneUtil.MinigameAreaId) loaderName = ZoneUtil.getLoaderName(ZoneUtil.MinigameAreaId) requestStatus = { 'zoneId': ZoneUtil.MinigameAreaId, 'hoodId': ZoneUtil.MinigameArea, 'where': whereName, 'how': 'teleportIn', 'avId': base.localAvatar.doId, 'shardId': None, 'loader': loaderName } self.cr.playGame.hood.fsm.request('quietZone', [requestStatus])
def teleportToCT(self): toZone = ZoneUtil.CogTropolisId hood = ZoneUtil.CogTropolis requestStatus = { 'zoneId': toZone, 'hoodId': hood, 'where': ZoneUtil.getWhereName(toZone), 'avId': self.doId, 'loader': ZoneUtil.getLoaderName(toZone), 'shardId': None, 'wantLaffMeter': 1, 'how': 'teleportIn' } self.cr.playGame.getPlace().fsm.request('teleportOut', [requestStatus])
def createWorld(self): self.deleteWorld() self.arena = loader.loadModel( "phase_4/models/minigames/dodgeball_arena.egg") self.arena.reparentTo(render) self.arena.setScale(0.75) self.arena.find('**/team_divider').setBin('ground', 18) self.arena.find('**/floor').setBin('ground', 18) self.arena.find('**/team_divider_coll').setCollideMask( CIGlobals.FloorBitmask) for data in DistributedDodgeballGame.TreeData: code = data[0] pos = data[1] tree = self.__getSnowTree(code) tree.reparentTo(self.arena) tree.setPos(pos) self.trees.append(tree) for i in xrange(len(DistributedDodgeballGame.SnowballData)): snowdata = DistributedDodgeballGame.SnowballData[i] snowball = Snowball(self, i) snowball.load() snowball.reparentTo(render) snowball.setPos(snowdata) self.snowballs.append(snowball) self.olc = ZoneUtil.getOutdoorLightingConfig(ZoneUtil.TheBrrrgh) self.olc.setupAndApply()
def makeInterior(self, roomIndex=None): self.dnaStore = self.cr.playGame.dnaStore self.generator = random.Random() self.generator.seed(self.zoneId) self.interior = loader.loadModel( 'phase_4/models/modules/gagShop_interior.bam') self.interior.reparentTo(render) hoodId = ZoneUtil.getHoodId(self.zoneId, 1) self.colors = ToonInteriorColors.colors[hoodId] self.replaceRandomInModel(self.interior) door = self.dnaStore.findNode('door_double_round_ur') doorOrigin = render.find('**/door_origin;+s') doorNP = door.copyTo(doorOrigin) doorOrigin.setScale(0.8, 0.8, 0.8) doorOrigin.setPos(doorOrigin, 0, -0.025, 0) doorColor = self.generator.choice(self.colors['TI_door']) DNADoor.setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, self.block, doorColor) doorFrame = doorNP.find('door_*_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(doorColor) del self.colors del self.dnaStore del self.generator self.addLightsForLamps()
def makeMoreDetailsPanel(self): self.actionFSM.request('off') self.removeMoreDetailsPanel() self.removeActionPanel() self.makeActionPanel() zoneId = self.avatarInfo[5] shardId = self.avatarInfo[6] isOnline = self.avatarInfo[7] shardName = 'Unknown District' hoodName = ZoneUtil.getHoodId(zoneId, 1) for district in base.cr.activeDistricts.values(): if district.doId == shardId: shardName = district.getDistrictName() break if not isOnline: hoodName = 'Offline' shardName = 'Offline' self.locationText = OnscreenText('Location: {0}'.format(hoodName), parent=self.actionFrame, pos=(-0.3, 0.05, 0), align=TextNode.ALeft, scale=0.04) self.shardText = OnscreenText('District: {0}'.format(shardName), parent=self.actionFrame, pos=(-0.3, 0.0, 0), align=TextNode.ALeft, scale=0.04) self.detailsExitBtn = DirectButton(geom=CIGlobals.getCancelBtnGeom(), parent=self.actionFrame, relief=None, scale=0.8, pos=(-0.3, 0.0, -0.175), command=self.removeMoreDetailsPanel)
def setupSuitBuilding(self, nodePath): if nodePath.isEmpty(): return dnaStore = self.cr.playGame.dnaStore level = int(self.difficulty / 2) + 1 suitNP = dnaStore.findNode( 'suit_landmark_' + self.getDeptClassFromAbbr(self.suitDept).getClothingPrefix() + str(level)) zoneId = dnaStore.getZoneFromBlockNumber(self.block) zoneId = ZoneUtil.getTrueZoneId(zoneId, self.interiorZoneId) newParentNP = base.cr.playGame.hood.loader.zoneDict[zoneId] suitBuildingNP = suitNP.copyTo(newParentNP) base.createPhysicsNodes(suitBuildingNP) buildingTitle = dnaStore.getTitleFromBlockNumber(self.block) if not buildingTitle: buildingTitle = "Cogs, Inc." else: buildingTitle += ", Inc." buildingTitle += "\n%s" % self.getDeptClassFromAbbr( self.suitDept).getName() textNode = TextNode('sign') textNode.setTextColor(1.0, 1.0, 1.0, 1.0) textNode.setFont(CIGlobals.getSuitFont()) textNode.setAlign(TextNode.ACenter) textNode.setWordwrap(17.0) textNode.setText(buildingTitle) textHeight = textNode.getHeight() zScale = (textHeight + 2) / 3.0 signOrigin = suitBuildingNP.find('**/sign_origin;+s') backgroundNP = loader.loadModel(self.SIGN_MDL) backgroundNP.reparentTo(signOrigin) backgroundNP.setPosHprScale(0.0, 0.0, textHeight * 0.8 / zScale, 0.0, 0.0, 0.0, 8.0, 8.0, 8.0 * zScale) #backgroundNP.node().setEffect(DecalEffect.make()) signTextNodePath = backgroundNP.attachNewNode(textNode.generate()) signTextNodePath.setPosHprScale(0.0, -0.02, -0.21 + textHeight * 0.1 / zScale, 0.0, 0.0, 0.0, 0.1, 0.1, 0.1 / zScale) signTextNodePath.setColor(1.0, 1.0, 1.0, 1.0) frontNP = suitBuildingNP.find('**/*_front/+GeomNode;+s') backgroundNP.wrtReparentTo(frontNP) frontNP.node().setEffect(DecalEffect.make()) suitBuildingNP.setName('sb' + str(self.block) + ':_landmark__DNARoot') suitBuildingNP.setPosHprScale(nodePath, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0) suitBuildingNP.flattenStrong() self.loadElevator(suitBuildingNP) #CIGlobals.replaceDecalEffectsWithDepthOffsetAttrib(suitBuildingNP) #CIGlobals.flattenModelNodes(suitBuildingNP) base.enablePhysicsNodes(suitBuildingNP) #suitBuildingNP.ls() return suitBuildingNP
def getLocationText(location): if location in CIGlobals.ZoneId2Hood.keys(): return '%s\n%s' % ('Any Street', CIGlobals.ZoneId2Hood.get(location)) elif location in CIGlobals.BranchZone2StreetName.keys(): streetName = CIGlobals.BranchZone2StreetName.get(location) playground = CIGlobals.ZoneId2Hood.get(location - (location % 1000)) return '%s\n%s' % (streetName, playground) elif location in CIGlobals.zone2TitleDict.keys(): shop = CIGlobals.zone2TitleDict.get(location)[0] streetZone = ZoneUtil.getBranchZone(location) if streetZone % 1000 >= 100: streetName = CIGlobals.BranchZone2StreetName[streetZone] else: streetName = PLAYGROUND hoodName = ZoneUtil.getHoodId(streetZone, 1) return '%s\n%s\n%s' % (shop, streetName, hoodName) elif not location: return 'Any Street\nAny Playground'
def onPlayerDied(self): """ Called upon the local avatar dying. """ from src.coginvasion.hood import ZoneUtil if (base.cr.playGame.hood.id != ZoneUtil.getHoodId( base.localAvatar.zoneId)): base.cr.playGame.getPlace().fsm.request( 'died', [{}, base.localAvatar.diedStateDone])
def handleTeleportResponse(self, avatarId, shardId, zoneId): if self.avatarInfo[0] == avatarId: requestStatus = {} whereName = ZoneUtil.getWhereName(zoneId) loaderName = ZoneUtil.getLoaderName(zoneId) requestStatus['zoneId'] = zoneId if base.localAvatar.parentId == shardId: requestStatus['shardId'] = None else: requestStatus['shardId'] = shardId requestStatus['hoodId'] = ZoneUtil.getHoodId(zoneId, 1) requestStatus['where'] = whereName requestStatus['loader'] = loaderName requestStatus['how'] = 'teleportIn' requestStatus['avId'] = avatarId base.cr.playGame.getPlace().fsm.request('teleportOut', [requestStatus]) self.cleanup()
def handleToonInteriorDone(self): status = self.place.doneStatus if (status['loader'] == 'townLoader' and ZoneUtil.getBranchZone(status['zoneId']) == self.branchZone and status['shardId'] is None or status['how'] == 'doorOut'): self.fsm.request('quietZone', [status]) else: self.doneStatus = status messenger.send(self.doneEvent) return
def streetDone(self): self.requestStatus = self.place.doneStatus status = self.place.doneStatus if (status['loader'] == 'townLoader' and ZoneUtil.getBranchZone(status['zoneId']) == self.branchZone and status['shardId'] is None or status['how'] == 'doorOut' or status['where'] == 'suitInterior'): self.fsm.request('quietZone', [status]) else: self.doneStatus = status messenger.send(self.doneEvent)
def diedStateDone(self, requestStatus): hood = self.cr.playGame.hood.id if hood == ZoneUtil.BattleTTC: hood = ZoneUtil.ToontownCentral toZone = ZoneUtil.getZoneId(hood) if self.zoneId != toZone: requestStatus = { 'zoneId': toZone, 'hoodId': hood, 'where': ZoneUtil.getWhereName(toZone), 'avId': self.doId, 'loader': ZoneUtil.getLoaderName(toZone), 'shardId': None, 'wantLaffMeter': 1, 'how': 'teleportIn' } self.cr.playGame.getPlace().doneStatus = requestStatus messenger.send(self.cr.playGame.getPlace().doneEvent) else: return
def handleToonData(self, avatarList): for av in avatarList: avId = av[0] dna = av[1] name = av[2] slot = av[3] lastHood = av[4] choice = AvChoice(dna, name, slot, avId, ZoneUtil.getHoodId(lastHood)) self.avChoices.append(choice) self.avChooseFSM.request('avChoose')
def onDoorCloseFinish(self): if self.index == 1: if self.localAvOnElevator: self.thebldg.d_readyForNextFloor() self.localAvOnElevator = False else: # NOTE: we can't use self.zoneId because the elevator is in the ent zone, not the branch zone zoneId = ZoneUtil.getZoneId( ZoneUtil.getHoodId(base.localAvatar.zoneId, street=1)) requestStatus = { 'zoneId': zoneId, 'hoodId': self.cr.playGame.hood.hoodId, 'where': 'playground', 'avId': base.localAvatar.doId, 'loader': 'safeZoneLoader', 'shardId': None, 'wantLaffMeter': 1, 'world': base.cr.playGame.getCurrentWorldName(), 'how': 'teleportIn' } self.cr.playGame.getPlace().doneStatus = requestStatus messenger.send(self.cr.playGame.getPlace().doneEvent)
def __async_loadSZTask(self, task=None): dnas = HOOD_ID_2_DNA[self.choice.lastHood] for i in xrange(len(dnas)): dnaFile = dnas[i] if i == len(dnas) - 1: node = loader.loadDNAFile(self.dnaStore, dnaFile) if node.getNumParents() == 1: self.szGeom = NodePath(node.getParent(0)) self.szGeom.reparentTo(render) else: self.szGeom = render.attachNewNode(node) # The 2D trees should not be flattened, to do that, we're going to traverse # the scene graph for all trees, use #wrtReparentTo(render) on them, flatten # the scene with #flattenStrong(), and finally #wrtReparentTo(self.szGeom) # the trees back to the main scene node so they get cleaned up properly. trees = self.szGeom.findAllMatches('**/*tree*') #self.szGeom.find("**/shadow").removeNode() #from panda3d.core import CullBinAttrib #self.szGeom.find("**/shadow_crack").setAttrib(CullBinAttrib.make("foreground", 10), 10) #shs = self.szGeom.findAllMatches("**/*shadow*") #for sh in shs: # sh.removeNode() # self.szGeom.ls() for tree in trees: tree.wrtReparentTo(render) self.szGeom.flattenStrong() for tree in trees: tree.wrtReparentTo(self.szGeom) else: loader.loadDNAFile(self.dnaStore, dnaFile) self.olc = ZoneUtil.getOutdoorLightingConfig(self.choice.lastHood) self.olc.setup() self.olc.apply() CIGlobals.preRenderScene(render) self.asyncSZLoadStatus = True #base.accept('l', render.ls) if task: return task.done
def load(self): self.deleteWorld() self.track = loader.loadModel(self.trackPath) self.track.reparentTo(render) self.olc = ZoneUtil.getOutdoorLightingConfig(ZoneUtil.ToontownCentral) self.olc.setupAndApply() self.setMinigameMusic("phase_4/audio/bgm/MG_toontag.ogg") self.setDescription("Tap the left and right arrow keys repeatedly, in turns, as fast as " + \ "you can to win the race! Every time your power bar hits the top, the boost bar starts" + \ " to fill. When the boost bar is full, press CTRL to boost for a few seconds.") self.setWinnerPrize(100) self.setLoserPrize(5) self.d_requestToonLane() camera.reparentTo(render) camera.setPos(self.initialCamPos["pos"]) camera.setHpr(self.initialCamPos["hpr"]) DistributedMinigame.DistributedMinigame.load(self)
def getNPCLocationSpeech(self, nextObjective = False): if nextObjective: objective = self.currentQuest.getNextObjectiveData() else: objective = self.currentQuest.getCurrObjectiveData() npcId = objective[Quests.args][0] npcZone = NPCGlobals.NPCToonDict[npcId][0] name = NPCGlobals.NPCToonNames[npcId] shopName = ZoneUtil.zone2TitleDict[npcZone][0] chat = random.choice(NPCDialogue.FindNPC) if "[p]" in chat: chat = chat.replace("[p]", getPossessive(name)) chat = chat % (name, shopName) chat += "\x07" locationSpeech = NPCDialogue.WhichIs if ZoneUtil.isOnCurrentPlayground(npcZone): # The NPC is in the same playground that the quest is being assigned on. locationSpeech = locationSpeech % "in this playground." elif ZoneUtil.isOnSameStreet(npcZone): # The NPC is on the same street that the quest is being assigned on. locationSpeech = locationSpeech % "on this street." elif ZoneUtil.isAtSamePlaygroundButDifferentBranch(npcZone): # The NPC is in the same playground but in a different branch zone. locationSpeech = (locationSpeech % "on %s." % ZoneUtil.getStreetName(npcZone)) else: # NPC is in a completely different playground from where we are. if ZoneUtil.isStreet(ZoneUtil.getBranchZone(npcZone)): loc = "on %s" % ZoneUtil.getStreetName(npcZone) else: loc = "at the playground" locationSpeech = (locationSpeech % "%s in %s." % (loc, ZoneUtil.getHoodId(npcZone, 1))) chat += locationSpeech chat += "\x07" return chat
def announceGenerate(self): DistributedBattleZone.announceGenerate(self) base.transitions.fadeScreen(0.0) self.guide = Toon(base.cr) self.guide.autoClearChat = False self.guide.parseDNAStrand(NPCGlobals.NPCToonDict[self.GUIDE_NPCID][2]) self.guide.setName(NPCGlobals.NPCToonDict[self.GUIDE_NPCID][1]) self.guide.generateToon() self.guide.nametag.setNametagColor( NametagGlobals.NametagColors[NametagGlobals.CCNPC]) self.guide.nametag.setActive(0) self.guide.nametag.updateAll() self.guide.nametag.getNametag3d().setClickEvent('tutGuide-click') self.guide.nametag.getNametag2d().setClickEvent('tutGuide-click') self.guide.reparentTo(render) base.localAvatar.reparentTo(render) loader.loadDNAFile(self.dnaStore, 'phase_3.5/dna/storage_tutorial.pdna') node = loader.loadDNAFile(self.dnaStore, 'phase_3.5/dna/tutorial_street.pdna') if node.getNumParents() == 1: self.streetGeom = NodePath(node.getParent(0)) self.streetGeom.reparentTo(hidden) else: self.streetGeom = hidden.attachNewNode(node) self.streetGeom.flattenMedium() gsg = base.win.getGsg() if gsg: self.streetGeom.prepareScene(gsg) self.streetGeom.reparentTo(render) self.streetGeom.setPos(20.5, -20, 0) self.streetGeom.setH(90) self.olc = ZoneUtil.getOutdoorLightingConfig(ZoneUtil.ToontownCentral) self.olc.setupAndApply() base.playMusic('TC_SZ') self.fsm.request('newPlayerEmerge') base.localAvatar.inTutorial = True
def load(self): spawn = random.choice(DGG.SpawnPoints) base.localAvatar.setPos(spawn) base.localAvatar.setHpr(0, 0, 0) self.soundPickUpBarrel = base.loadSfx( 'phase_6/audio/sfx/SZ_MM_gliss.ogg') self.soundDropOff = base.loadSfx( 'phase_4/audio/sfx/MG_sfx_travel_game_bell_for_trolley.ogg') self.soundBeep = base.loadSfx( 'phase_4/audio/sfx/MG_delivery_truck_beep.ogg') self.soundDoorOpen = base.loadSfx( "phase_9/audio/sfx/CHQ_VP_door_open.ogg") self.setMinigameMusic('phase_4/audio/bgm/MG_Delivery.ogg') self.setDescription('A new supply of Gags were just shipped to Toontown! ' + \ 'Run over to a truck with Gag barrels to take a barrel out. Then, carry it over to the Gag Shop. ' + \ 'Try to unload and deliver as many barrels as you can to the Gag Shop. ' + \ 'Watch out for the Cogs - they might try to snatch a barrel!') self.setWinnerPrize(100) self.setLoserPrize(0) self.gagShop = loader.loadModel( 'phase_4/models/modules/gagShop_TT.bam') self.gagShop.reparentTo(base.render) self.gagShop.setY(-70) sphere = CollisionSphere(0, 0, 0, 3) sphere.setTangible(0) node = CollisionNode('MGDeliveryGagShop') node.addSolid(sphere) self.gagShopCollNP = self.gagShop.attachNewNode(node) self.world = loader.loadModel( 'phase_4/models/minigames/delivery_area.egg') self.world.setY(-5) self.world.reparentTo(base.render) self.world.find('**/ground').setBin('ground', 18) self.olc = ZoneUtil.getOutdoorLightingConfig(ZoneUtil.ToontownCentral) self.olc.setupAndApply() base.camera.setPos(20, 50, 30) base.camera.lookAt(20, 0, 7.5) DistributedMinigame.load(self)
def load(self, zoneId): StateData.load(self) self.zoneId = zoneId self.branchZone = ZoneUtil.getBranchZone(zoneId) self.canonicalBranchZone = ZoneUtil.getCanonicalBranchZone(zoneId)
def getVisZoneId(self): exteriorZoneId = self.cr.playGame.dnaStore.getZoneFromBlockNumber( self.block) visZoneId = ZoneUtil.getTrueZoneId(exteriorZoneId, self.zoneId) return visZoneId
def isValidLocation(self, hood): return (self.area == QuestGlobals.Anywhere or ZoneUtil.getHoodId(self.area, 1) == hood or ZoneUtil.getHoodId(self.area, 1) == ZoneUtil.ToontownCentral and hood == ZoneUtil.BattleTTC)
def makeDictionaries(self, dnaStore): self.nodeDict = {} self.zoneDict = {} self.zoneVisDict = {} self.nodeList = [] self.fadeInDict = {} self.fadeOutDict = {} a1 = Vec4(1, 1, 1, 1) a0 = Vec4(1, 1, 1, 0) numVisGroups = dnaStore.getNumDNAVisGroupsAI() for i in xrange(numVisGroups): groupFullName = dnaStore.getDNAVisGroupName(i) visGroup = dnaStore.getDNAVisGroupAI(i) groupName = base.cr.hoodMgr.extractGroupName(groupFullName) zoneId = int(groupName) zoneId = ZoneUtil.getTrueZoneId(zoneId, self.zoneId) groupNode = self.geom.find('**/' + groupFullName) if groupNode.isEmpty(): continue else: if ':' in groupName: groupName = '%s%s' % (zoneId, groupName[groupName.index(':'):]) else: groupName = '%s' % zoneId groupNode.setName(groupName) CIGlobals.replaceDecalEffectsWithDepthOffsetAttrib(groupNode) #group all the flat walls block2flatwall = {} flatwalls = groupNode.findAllMatches("**/tb*:*_DNARoot;+s") for flatwall in flatwalls: if "toon_landmark" in flatwall.getName(): print "Skipping", flatwall.getName() continue if flatwall.hasTag("DNACode") and flatwall.hasMat(): continue block = int(flatwall.getName().split(":")[0][2:]) if not block2flatwall.has_key(block): block2flatwall[block] = groupNode.attachNewNode( ModelNode('toonBuildingsBlock' + str(block))) flatwall.wrtReparentTo(block2flatwall[block]) for node in block2flatwall.values(): for child in node.findAllMatches("**"): child.clearEffect(DecalEffect.getClassType()) child.clearTag("DNACode") child.clearTag("cam") CIGlobals.clearModelNodesBelow(node) node.flattenStrong() flattenGroup = groupNode.attachNewNode('optim') flattens = ['street*_DNARoot'] removes = ['interactive_prop*_DNARoot'] for remove in removes: for np in groupNode.findAllMatches("**/" + remove): np.removeNode() for flatten in flattens: for np in groupNode.findAllMatches("**/" + flatten): if np.hasTag("DNACode") and np.hasMat(): continue for child in np.findAllMatches("**"): child.clearEffect(DecalEffect.getClassType()) child.clearTag("DNACode") child.clearTag("cam") np.wrtReparentTo(flattenGroup) flattenGroup.clearModelNodes() flattenGroup.flattenStrong() CIGlobals.flattenModelNodes(groupNode) groupNode.flattenStrong() #groupNode.ls() self.nodeDict[zoneId] = [] self.nodeList.append(groupNode) self.zoneDict[zoneId] = groupNode visibles = [] for i in xrange(visGroup.getNumVisibles()): visibles.append(int(visGroup.get_visible(i))) visibles.append(ZoneUtil.getBranchZone(zoneId)) self.zoneVisDict[zoneId] = visibles fadeDuration = 0.5 self.fadeOutDict[groupNode] = Sequence( Func(groupNode.setTransparency, 1), LerpColorScaleInterval(groupNode, fadeDuration, a0, startColorScale=a1), Func(groupNode.clearColorScale), Func(groupNode.clearTransparency), Func(groupNode.stash), Func(base.disablePhysicsNodes, groupNode), name='fadeZone-' + str(zoneId), autoPause=1) self.fadeInDict[groupNode] = Sequence( Func(base.enablePhysicsNodes, groupNode), Func(groupNode.unstash), Func(groupNode.setTransparency, 1), LerpColorScaleInterval(groupNode, fadeDuration, a1, startColorScale=a0), Func(groupNode.clearColorScale), Func(groupNode.clearTransparency), name='fadeZone-' + str(zoneId), autoPause=1) for i in xrange(numVisGroups): groupFullName = dnaStore.getDNAVisGroupName(i) zoneId = int(base.cr.hoodMgr.extractGroupName(groupFullName)) zoneId = ZoneUtil.getTrueZoneId(zoneId, self.zoneId) for j in xrange(dnaStore.getNumVisiblesInDNAVisGroup(i)): visName = dnaStore.getVisibleName(i, j) groupName = base.cr.hoodMgr.extractGroupName(visName) nextZoneId = int(groupName) nextZoneId = ZoneUtil.getTrueZoneId(nextZoneId, self.zoneId) visNode = self.zoneDict[nextZoneId] self.nodeDict[zoneId].append(visNode) self.hood.dnaStore.resetPlaceNodes() self.hood.dnaStore.resetDNAGroups() self.hood.dnaStore.resetDNAVisGroups() self.hood.dnaStore.resetDNAVisGroupsAI()
def enterPlayingGame(self): zoneId = localAvatar.getLastHood() hoodId = ZoneUtil.getHoodId(zoneId) status = {"hoodId": hoodId, "zoneId": zoneId, "avId": self.localAvId} shardId = self.myDistrict.doId self.gameFSM.request('waitForGameEnterResponse', [status, shardId])
def __init__(self): self.gui = None self.mopath = None self.platform = None self.platformNode = None self.lLineSeg = None self.rLineSeg = None self.crates = [] self.music = base.loadMusic('phase_4/audio/bgm/MG_Crash_brrrgh.ogg') self.dnaStore = DNAStorage() loadDNAFile(self.dnaStore, 'phase_4/dna/storage.pdna') loadDNAFile(self.dnaStore, 'phase_5/dna/storage_town.pdna') loadDNAFile(self.dnaStore, 'phase_8/dna/storage_BR.pdna') loadDNAFile(self.dnaStore, 'phase_8/dna/storage_BR_town.pdna') node = loadDNAFile(self.dnaStore, 'phase_4/dna/test_brrrgh_ch_lvl.pdna') if node.getNumParents() == 1: geom = NodePath(node.getParent(0)) geom.reparentTo(hidden) else: geom = hidden.attachNewNode(node) gsg = base.win.getGsg() if gsg: geom.prepareScene(gsg) geom.setName('test_level') geom.reparentTo(render) self.olc = ZoneUtil.getOutdoorLightingConfig(CIGlobals.TheBrrrgh) self.olc.setupAndApply() self.area = geom self.area.setH(90) self.lastCamPos = Point3(0, 0, 0) self.lastCamHpr = Vec3(0, 0, 0) self.lastCamNodeH = 0.0 self.camNode = render.attachNewNode('crashCamNode') camera.reparentTo(self.camNode) base.minigame = self #self.camCurve = loader.loadModel('crash_test_cam_path.egg') #self.camMoPath = NURBSMopath(self.camCurve) #self.camMoPath.node = camera #self.camNodes = self.camMoPath.evaluator.getVertices() # X Y Z H self.camNodes = [VBase4(-20, 0, 7.5, 0), VBase4(-20, 130, 7.5, -90), VBase4(60, 130, 7.5, -90)] self.localAv = LocalCrashToon(base.localAvatar) #base.transitions.noTransitions() #base.enableMouse() #base.localAvatar.stopSmartCamera() #base.localAvatar.detachCamera() #self.cra = Actor('phase_4/models/minigames/crash_crate.egg', {'bounce': 'phase_4/models/minigames/crash_crate-bounce.egg'}) #self.cra.reparentTo(render) #self.cra.loop('bounce') #self.cra.setPos(100, 100, 0) #self.cra.ls() base.acceptOnce('s', self.start)