def impact(self, pos, lastPos): pos = Point3(pos) lastPos = Point3(lastPos) CIGlobals.makeSplat(pos, self.SplatColor, self.SplatScale, self.impactSound) dir = (pos - lastPos).normalized() base.bspLoader.traceDecal("phase_14/materials/pie_splat.mat", 5, random.randint(1, 360), lastPos, pos + dir)
def suitExplode(self): pos = self.getPart('body').find('**/joint_head').getPos(render) + ( 0, 0, 2) # Force the loser suit to use UnlitGeneric shader, workaround for the has_mat() assertion BSPUtility.applyUnlitOverride(self) CIGlobals.makeExplosion(pos, 0.5, soundVol=0.32, smoke=False)
def addPrimaryPressData(self, dg): BaseHitscan.addPrimaryPressData(self, dg) model = self.model if self.isFirstPerson(): model = self.getVMGag() CIGlobals.putVec3(dg, model.find('**/Emitter1').getPos(render))
def doFlatten(self): self.makeDictionaries(self.hood.dnaStore) self.reparentLandmarkBlockNodes() base.createPhysicsNodes(self.geom) self.renameFloorPolys(self.nodeList) self.geom.flattenLight() CIGlobals.preRenderScene(self.geom)
def enterDisplayPage(self): dialog_gui = loader.loadModel( "phase_3/models/gui/dialog_box_buttons_gui.bam") width, height, fs, music, sfx, tex_detail, model_detail, aa, af = SettingsManager( ).getSettings("settings.json") self.width = width self.height = height self.windowType = [fs] self.buttons = [ DirectRadioButton(text="Windowed", variable=self.windowType, value=[False], scale=0.1, pos=(-0.45, 0.15, 0.15)), DirectRadioButton(text="Fullscreen", variable=self.windowType, value=[True], scale=0.1, pos=(-0.45, -0.15, -0.15)) ] for button in self.buttons: button.setOthers(self.buttons) self.resoLbl = DirectLabel(text="%sx%s" % (width, height), scale=0.08, relief=None, pos=(0.25, 0, 0)) self.resSlider = DirectSlider(range=(0, 200), pageSize=50, command=self.setResoText, scale=0.3, orientation=DGG.VERTICAL, pos=(0.6, 0, 0)) self.okBtn = DirectButton(text="OK", geom=CIGlobals.getOkayBtnGeom(), relief=None, pos=(-0.5, -0.5, -0.5), text_scale=0.05, text_pos=(0, -0.11), command=self.applyDisplaySettings) self.cancelBtn = DirectButton(text="Cancel", geom=CIGlobals.getCancelBtnGeom(), relief=None, pos=(-0.3, -0.5, -0.5), text_scale=0.05, text_pos=(0, -0.11), command=self.cancelDisplaySettings) if self.resoLbl['text'] == "640x480": self.resSlider['value'] = 0 elif self.resoLbl['text'] == "800x600": self.resSlider['value'] = 50 elif self.resoLbl['text'] == "1024x768": self.resSlider['value'] = 100 elif self.resoLbl['text'] == "1280x1024": self.resSlider['value'] = 150 elif self.resoLbl['text'] == "1600x1200": self.resSlider['value'] = 200
def makeDecalTrace(self, material, scale, rot, start, end): dg = PyDatagram() dg.addString(material) dg.addFloat64(scale) dg.addFloat64(rot) CIGlobals.putVec3(dg, start) CIGlobals.putVec3(dg, end) self.sendTempEnt(TE_DECAL_TRACE, dg)
def handleHealthChange(self, hp, oldHp): BaseLocalAvatar.handleHealthChange(self, hp, oldHp) delta = hp - oldHp if delta == 0: return CIGlobals.makeDeltaTextEffect(delta, base.a2dBottomLeft, (0.07, 0, 0.1))
def primaryFirePress(self, data): if not self.canUse(): return dg = PyDatagram(data) dgi = PyDatagramIterator(dg) self.traceOrigin = CIGlobals.getVec3(dgi) self.traceVector = CIGlobals.getVec3(dgi) self.setNextAction(self.StateFire)
def __init__(self): self.defaultLogoScale = 1 self.defaultLogoZ = 0.65 self.bgm = loader.loadModel( "phase_3/models/gui/progress-background.bam") self.bgm.find('**/logo').stash() self.barShadow = OnscreenImage(image=self.bgm.find("**/bar_shadow"), parent=hidden) self.bgm.find("**/bar_shadow").removeNode() self.bg = self.bgm.find('**/bg') self.defaultBgTexture = self.bg.findTexture('*') self.logoNode, self.logoImg = CIGlobals.getLogoImage( hidden, self.defaultLogoScale, (0, 0, self.defaultLogoZ)) self.bg_img = OnscreenImage(image=self.bg, parent=hidden) self.bg_img.setSx(1.35) self.bg_img.hide() self.progress_bar = DirectWaitBar(value=0, pos=(0, 0, -0.85), parent=hidden, text_pos=(0, 0, 0.2)) self.progress_bar.setSx(1.064) self.progress_bar.setSz(0.38) toontipgui = loader.loadModel( 'phase_3.5/models/gui/stickerbook_gui.bam') poster = toontipgui.find('**/questCard') self.toontipFrame = DirectFrame(image=poster, image_scale=(1.4, 1, 1), parent=hidden, relief=None, pos=(0, 0, -0.1), scale=0.85) self.toontipLbl = OnscreenText(text="", parent=self.toontipFrame, fg=(89.0 / 255, 95.0 / 255, 98.0 / 255, 1), font=CIGlobals.getToonFont(), wordwrap=13, pos=(-0.59, 0.25), align=TextNode.ALeft, scale=0.08) self.loading_lbl = DirectLabel(text="", relief=None, scale=0.08, pos=(-1.0725, 0, -0.79), text_align=TextNode.ALeft, sortOrder=100, text_fg=(1, 1, 1, 1), text_font=CIGlobals.getMinnieLogoFont(), parent=hidden, text_shadow=(0, 0, 0, 0)) # This is useful when the user has chosen to hide aspect2d before the loading screen. # However, we want to show the loading screen all the time, so we need to restore the # previous state after the loading screen ends. self.mustRestoreHiddenAspect2d = False
def handleHitWallOrPlayer(self): self.pauseThrowIval() CIGlobals.makeSplat(self.getPos(render), (1, 1, 1, 1), 0.25) self.reparentTo(render) self.setPos(self.mg.SnowballData[self.index]) self.setHpr(0, 0, 0) self.shadow.show() self.isAirborne = False self.owner = None
def makeExplosion(self, dgi): pos = CIGlobals.getVec3(dgi) scale = dgi.getFloat64() sound = bool(dgi.getUint8()) shakeCam = bool(dgi.getUint8()) duration = dgi.getFloat64() soundVol = dgi.getFloat64() CIGlobals.makeExplosion(pos, scale, sound, shakeCam, duration, soundVol)
def handleSplat(self): base.audio3d.detachSound(self.woosh) if self.woosh: self.woosh.stop() CIGlobals.makeSplat(self.splatPos, self.splatColor, self.splatScale, self.hitSfx) self.cleanupEntity(self.splatPos) self.splatPos = None
def cleanupGag(self): print "cleanupGag" if self.state == GagState.LOADED or self.state == GagState.RECHARGING: Gag.cleanupGag(self) if CIGlobals.isNodePathOk(self.megaphone): if CIGlobals.isNodePathOk(self.avatar): copies = self.avatar.findAllMatches('**/%s' % self.megaphone.getName()) for copy in copies: copy.removeNode() self.megaphone = None
def impact(self, pos, lastPos): pos = Point3(pos) lastPos = Point3(lastPos) CIGlobals.makeSplat(pos, self.color, self.SplatScale, self.impactSound) dir = (pos - lastPos).normalized() base.bspLoader.traceDecal(self.SplatMaterialPath, 1.5, random.randint(1, 360), lastPos, pos + (dir * 2), self.color)
def isSameLeafAsPlayer(self, plyr): if not CIGlobals.isNodePathOk(plyr) or not CIGlobals.isNodePathOk( self): return False plLeaf = self.battleZone.bspLoader.findLeaf(plyr.getPos() + (0, 0, 0.05)) myLeaf = self.battleZone.bspLoader.findLeaf(self.getPos() + (0, 0, 0.05)) return plLeaf == myLeaf
def isPlayerInPVS(self, plyr): if not CIGlobals.isNodePathOk(plyr) or not CIGlobals.isNodePathOk( self): return False plLeaf = self.battleZone.bspLoader.findLeaf(plyr.getPos() + (0, 0, 0.05)) myLeaf = self.battleZone.bspLoader.findLeaf(self.getPos() + (0, 0, 0.05)) return self.battleZone.bspLoader.isClusterVisible(myLeaf, plLeaf)
def isPlayerInVisionCone(self, plyr): # Is the player in my angle of vision? toPlyr = plyr.getPos() - self.getPos() yaw = CIGlobals.angleMod(CIGlobals.vecToYaw(toPlyr)) diff = CIGlobals.angleDiff(yaw, CIGlobals.angleMod(self.getYaw())) #print("Vision cone from self->player:", diff) return abs(diff) <= self.MAX_VISION_ANGLE
def isPlayerInVisionCone_FromPlayer(self, plyr): # Am I in the player's vision cone? toSelf = self.getPos() - plyr.getPos() yaw = CIGlobals.angleMod(CIGlobals.vecToYaw(toSelf)) diff = CIGlobals.angleDiff(yaw, CIGlobals.angleMod(plyr.getH())) #print("Vision cone from player->self:", diff) return abs(diff) <= self.MAX_VISION_ANGLE
def handleSplat(self): origSize = GagGlobals.splatSizes.get(self.getName()) if self.splatDist is not None and self.sprayParticleDist is not None: size = origSize * (self.splatDist / self.sprayParticleDist) else: size = origSize size = max(origSize / 3.0, size) CIGlobals.makeSplat(self.splatPos, GagGlobals.WATER_SPRAY_COLOR, size) self.splatPos = None self.splatDist = None
def impact(self, pos, lastPos): pos = Point3(pos) lastPos = Point3(lastPos) CIGlobals.makeSplat(pos, self.color, self.SplatScale, self.impactSound) dir = (pos - lastPos).normalized() splatDecal = base.bspLoader.traceDecal("phase_14/materials/pie_splat.mat", 2, random.randint(1, 360), lastPos, pos + (dir * 2)) if not splatDecal.isEmpty(): splatDecal.setColorScale(self.color, 1)
def enterTrolleyOut(self, requestStatus): base.localAvatar.walkControls.setCollisionsActive(0) base.transitions.fadeScreen(1.0) prevZone = requestStatus['prevZoneId'] slot = requestStatus['slot'] for trolley in base.cr.doFindAll("DistributedBattleTrolley"): if trolley.toZone == prevZone: trolley.localAvOnTrolley = True CIGlobals.showWaitForOthers() trolley.sendUpdate('arrivedInTrolley', [slot])
def __doSplat(self, distance, pos): self.splatDist = distance self.splatPos = pos origSize = GagGlobals.splatSizes.get(self.getName()) if self.splatDist is not None and self.sprayParticleDist is not None: size = origSize * (self.splatDist / self.sprayParticleDist) else: size = origSize size = max(origSize / 3.0, size) CIGlobals.makeSplat(self.splatPos, GagGlobals.WATER_SPRAY_COLOR, size)
def makeBulletRicochet(self, pos, bulletDirection, surfaceNormal, scale=3): dg = PyDatagram() CIGlobals.putVec3(dg, pos) CIGlobals.putVec3( dg, CIGlobals.reflect(bulletDirection, surfaceNormal) + Vec3(random.uniform(-0.15, 0.15), random.uniform(-0.15, 0.15), random.uniform(-0.15, 0.15))) dg.addFloat64(scale * random.uniform(0.15, 1.3)) self.sendTempEnt(TE_BULLET_RICOCHET, dg)
def enterAvChoose(self): if base.cr.holidayManager.getHoliday() == HolidayType.CHRISTMAS: base.playMusic(CIGlobals.getHolidayTheme()) # Create message. whisper = WhisperPopup(HolidayGlobals.CHRISTMAS_TIME, CIGlobals.getToonFont(), ChatGlobals.WTSystem) whisper.manage(base.marginManager) self.pickAToon = CharSelection(self) self.pickAToon.load(self.newToonSlot)
def __init__(self, parent = None, style = NoButtons, **kw): if parent is None: parent = aspect2d self.style = style if self.style == YesNo or self.style == YesCancel: okButtons = CIGlobals.getOkayBtnGeom() cancelButtons = CIGlobals.getCancelBtnGeom() buttonImage = [okButtons, cancelButtons] buttonValues = [DGG.DIALOG_OK, DGG.DIALOG_CANCEL] if 'buttonText' in kw: buttonText = kw['buttonText'] del kw['buttonText'] else: buttonText = [CIGlobals.DialogYes] if self.style == YesNo: buttonText.append(CIGlobals.DialogNo) elif self.style == YesCancel: buttonText.append(CIGlobals.DialogCancel) elif self.style == Ok: okButtons = CIGlobals.getOkayBtnGeom() buttonImage = [okButtons] buttonText = [CIGlobals.DialogOk] buttonValues = [DGG.DIALOG_OK] elif self.style == Cancel: cancelButtons = CIGlobals.getCancelBtnGeom() buttonImage = [cancelButtons] buttonText = [CIGlobals.DialogCancel] buttonValues = [DGG.DIALOG_CANCEL] elif self.style == NoButtons: buttonImage = [] buttonText = [] buttonValues = [] else: self.notify.error("Style %s does not exist." % self.style) optiondefs = (('buttonImageList', buttonImage, DGG.INITOPT), ('buttonTextList', buttonText, DGG.INITOPT), ('buttonValueList', buttonValues, DGG.INITOPT), ('buttonPadSF', 2.2, DGG.INITOPT), ('text_font', DGG.getDefaultFont(), None), ('text_wordwrap', 18, None), ('text_scale', 0.07, None), ('buttonSize', (-.05, 0.05, -.05, 0.05), None), ('button_pad', (0, 0), None), ('button_relief', None, None), ('button_text_pos', (0, -0.1), None), ('fadeScreen', 0.5, None), ('image_color', CIGlobals.DialogColor, None), ('image', DGG.getDefaultDialogGeom(), None), ('relief', None, None)) self.defineoptions(kw, optiondefs) DirectDialog.__init__(self, parent) self.initialiseoptions(Dialog) return
def createGui(self): """ Create the GUI that will tell the client how much running power they have. """ self.powerFrame = DirectFrame() self.powerBg = OnscreenImage(image=DGG.getDefaultDialogGeom(), scale=(0.5, 1.0, 0.5), pos=(1.02, 0, 0.7), parent=self.powerFrame, color=CIGlobals.DialogColor) self.powerBar = DirectWaitBar(barColor=(0, 0.7, 0, 1), range=20.0, value=0, parent=self.powerFrame, scale=(0.15, 0, 1.1), pos=(1.02, 0, 0.66)) self.powerBar.setR(-90) self.powerTitle = DirectLabel(text="POWER", text_scale=0.08, pos=(1.02, 0, 0.85), relief=None, parent=self.powerFrame, text_fg=(1, 1, 0, 1), text_font=CIGlobals.getMickeyFont()) self.boostFrame = DirectFrame() self.boostBg = OnscreenImage(image=DGG.getDefaultDialogGeom(), scale=(0.5, 1.0, 0.5), pos=(0.45, 0, 0.7), parent=self.boostFrame, color=CIGlobals.DialogColor) self.boostBar = DirectWaitBar(barColor=self.defaultBoostBarColor, range=10, value=0, parent=self.boostFrame, scale=(0.15, 0, 1.1), pos=(0.45, 0, 0.66)) self.boostBar.setR(-90) self.boostTitle = DirectLabel(text="BOOST", text_scale=0.08, pos=(0.45, 0, 0.85), relief=None, parent=self.boostFrame, text_fg=(1, 1, 0, 1), text_font=CIGlobals.getMickeyFont()) self.boostFullLbl = DirectLabel(text="BOOST READY", text_scale=0.065, pos=(0.45, 0, 0.3), relief=None, parent=self.boostFrame, text_fg=self.fullBoostBarColor, text_shadow=(0.4, 0.4, 0.4, 1.0), text_font=CIGlobals.getToonFont()) self.boostFullLbl.hide()
def __init__(self, page): OptionsCategory.__init__(self, page) DirectObject.__init__(self) self.logoNode, self.logoImg = CIGlobals.getLogoImage( self.page.book, 0.75, (0, 0, 0.48)) self.creditsScreen = None self.exitConfirmDlg = None font = CIGlobals.getToonLogoFont() self.gVersionText = OnscreenText(metadata.getBuildInformation(), parent=self.page.book, pos=(0, 0.15, 0.15), font=font, fg=(1, 1, 1, 1)) self.gBuildDate = OnscreenText(text=metadata.BUILD_DATE, parent=self.page.book, pos=(0, 0.085, 0.085), scale=0.06, font=font, fg=(1, 1, 1, 1)) self.eVersionText = OnscreenText(text="Engine Version {0}".format( PandaSystem.getVersionString()), parent=self.page.book, pos=(0, -0.05), font=font, fg=(1, 1, 1, 1)) self.eBuildDate = OnscreenText(text=PandaSystem.getBuildDate(), parent=self.page.book, pos=(0, -0.115), scale=0.06, font=font, fg=(1, 1, 1, 1)) self.exitToontown = CIGlobals.makeDefaultBtn( "Exit Toontown", pos=(-0.62, -0.62, -0.62), parent=self.page.book, scale=1.2, command=self.showConfirmDlg, geom_scale=(0.8, 0.8, 0.8)) self.credits = CIGlobals.makeDefaultBtn("Credits", pos=(0.0, 0.5, -0.62), parent=self.page.book, scale=1.2, command=self.rollCredits, geom_scale=(0.8, 0.8, 0.8))
def adjustWindowAspectRatio(self, aspectRatio): if (CIGlobals.getSettingsMgr() is None): ShowBase.adjustWindowAspectRatio(self, aspectRatio) self.credits2d.setScale(1.0 / aspectRatio, 1.0, 1.0) return if CIGlobals.getSettingsMgr().getSetting("maspr").getValue(): # Go ahead and maintain the aspect ratio if the user wants us to. ShowBase.adjustWindowAspectRatio(self, aspectRatio) self.credits2d.setScale(1.0 / aspectRatio, 1.0, 1.0) else: # The user wants us to keep a 4:3 ratio no matter what (old toontown feels). self.doOldToontownRatio()
def askTutorial(self): self.firstTimeMsg = YesNoDialog(text=CIGlobals.FirstTimeMsg, text_scale=0.07, text_wordwrap=18, buttonGeomList=[ CIGlobals.getOkayBtnGeom(), CIGlobals.getCancelBtnGeom() ], button_relief=None, button_text_pos=(0, -0.1), command=self.handleTutorialDecision, image_color=CIGlobals.DialogColor, fadeScreen=1)
def onHit(self, pos, intoNP): BaseProjectile.onHit(self, pos, intoNP) WATER_SPRAY_COLOR = Point4(0.3, 0.7, 0.9, 0.7) CIGlobals.makeSplat(pos, WATER_SPRAY_COLOR, 0.3) if self.local: avNP = intoNP.getParent() for obj in base.avatars: if CIGlobals.isAvatar(obj) and obj.getKey() == avNP.getKey(): gid = GagGlobals.getIDByName(GagGlobals.WaterGun) obj.handleHitByToon(base.localAvatar, gid, (self.getPos(render) - self.initialPos).length()) self.removeNode()