def load(self): minigameGui = loader.loadModel('phase_5/models/cogdominium/tt_m_gui_csa_flyThru') self.bg = minigameGui.find('**/background') self.chatBubble = minigameGui.find('**/chatBubble') self.chatBubble.setScale(6.5, 6.5, 7.3) self.chatBubble.setPos(0.32, 0, -0.78) self.bg.setScale(5.2) self.bg.setPos(0.14, 0, -0.6667) self.bg.reparentTo(aspect2d) self.chatBubble.reparentTo(aspect2d) self.frame = DirectFrame(geom=self.bg, relief=None, pos=(0.2, 0, -0.6667)) self.gameTitleText = DirectLabel(parent=self.frame, text=self.gameTitle, scale=TTLocalizer.CRPgameTitleText, text_align=TextNode.ACenter, text_font=getSignFont(), text_fg=(1.0, 0.33, 0.33, 1.0), pos=TTLocalizer.CRPgameTitleTextPos, relief=None) self.instructionsText = DirectLabel(parent=self.frame, text=self.instructions, scale=TTLocalizer.MRPinstructionsText, text_align=TextNode.ACenter, text_wordwrap=TTLocalizer.MRPinstructionsTextWordwrap, pos=TTLocalizer.MRPinstructionsTextPos, relief=None) self.playButton = DirectButton(parent=self.frame, relief=None, geom=(minigameGui.find('**/buttonUp'), minigameGui.find('**/buttonDown'), minigameGui.find('**/buttonHover')), pos=(0.74, 0, 0.1), scale=(4.2, 5, 5), command=self.playCallback) minigameGui.removeNode() self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(base.a2dTopRight) self.timer.setScale(0.4) self.timer.setPos(-0.155, 0, -0.155) self.frame.hide() return
def __init__(self): DirectFrame.__init__(self, relief = None, geom = DGG.getDefaultDialogGeom(), geom_color = Vec4(0.8,0.6,0.4,1), geom_scale = (1.85,1,0.9), geom_hpr = (0,0,-90), pos = (-0.85,0,0), ) self.initialiseoptions(QuestChoiceGui) self.questChoicePosters = [] guiButton = loader.loadModel("phase_3/models/gui/quit_button") self.cancelButton = DirectButton( parent = self, relief = None, image = (guiButton.find("**/QuitBtn_UP"), guiButton.find("**/QuitBtn_DN"), guiButton.find("**/QuitBtn_RLVR"), ), image_scale = (0.7,1,1), text = TTLocalizer.QuestChoiceGuiCancel, text_scale = 0.06, text_pos = (0,-0.02), command = self.chooseQuest, extraArgs = [0], ) guiButton.removeNode() self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(self) self.timer.setScale(0.3) # Reserve the left edge of the screen for the gui. base.setCellsAvailable(base.leftCells, 0) base.setCellsAvailable([base.bottomCells[0], base.bottomCells[1]], 0)
def __init__(self): DirectFrame.__init__(self, parent=aspect2d, relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=ToontownGlobals.GlobalDialogColor, geom_scale=(1.33, 1, 1.3), pos=(0, 0, 0), text='', text_scale=0.07, text_pos=(0, 0.475)) self.initialiseoptions(LaffShopGui) self.additionalLaff = 0 self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(aspect2d) self.timer.posInTopRightCorner() self.timer.countdown(LaffRestockGlobals.TIMER_SECONDS, self.__cancel, [LaffRestockGlobals.TIMER_END]) self.setupButtons() self.bindButtons() self.laffMeter = LaffMeter.LaffMeter(base.localAvatar.style, base.localAvatar.getHp(), base.localAvatar.getMaxHp()) self.laffMeter.reparentTo(self) self.laffMeter.setPos(0, 0, 0.065) self.laffMeter.setScale(0.13) self.__updateLaffMeter(1)
def enterPlay(self): self.notify.debug('enterPlay') for i in range(self.numPlayers): avId = self.avIdList[i] avName = self.getAvatarName(avId) scorePanel = MinigameAvatarScorePanel.MinigameAvatarScorePanel( avId, avName) scorePanel.setPos(1.12, 0.0, 0.5 - 0.28 * i) self.scorePanels.append(scorePanel) self.goalBar.show() self.goalBar['value'] = 0.0 base.setCellsAvailable(base.rightCells, 0) self.__spawnUpdateSuitsTask() orthoDrive = OrthoDrive( self.TOON_SPEED, maxFrameMove=self.MAX_FRAME_MOVE, customCollisionCallback=self.__doMazeCollisions, priority=1) self.orthoWalk = OrthoWalk(orthoDrive, broadcast=not self.isSinglePlayer()) self.orthoWalk.start() self.accept(MazeSuit.COLLISION_EVENT_NAME, self.__hitBySuit) self.accept(self.TREASURE_GRAB_EVENT_NAME, self.__treasureGrabbed) self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.setTime(MazeGameGlobals.GAME_DURATION) self.timer.countdown(MazeGameGlobals.GAME_DURATION, self.timerExpired) self.accept('resetClock', self.__resetClock) base.playMusic(self.music, looping=0, volume=0.8)
def load(self): purchaseModels = loader.loadModel( "phase_4/models/gui/gag_shop_purchase_gui") PurchaseBase.load(self, purchaseModels) self.backToPlayground = DirectButton( parent=self.frame, relief=None, scale=1.04, pos=(0.71, 0, -0.045), image=( purchaseModels.find("**/PurchScrn_BTN_UP"), purchaseModels.find("**/PurchScrn_BTN_DN"), purchaseModels.find("**/PurchScrn_BTN_RLVR"), ), text=TTLocalizer.GagShopDoneShopping, text_fg=(0, 0.1, 0.7, 1), text_scale=0.05, text_pos=(0, 0.015, 0), command=self.__handleBackToPlayground, ) # The timer self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(self.frame) self.timer.posInTopRightCorner() purchaseModels.removeNode()
def load(self): if self._isLoaded: return self.timer = ToontownTimer.ToontownTimer() self.timer.stash() self.model = loader.loadModel(CogdoBarrelRoomConsts.BarrelRoomModel) self.model.setPos(*CogdoBarrelRoomConsts.BarrelRoomModelPos) self.model.reparentTo(render) self.model.stash() self.entranceNode = self.model.attachNewNode('door-entrance') self.entranceNode.setPos(0, -65, 0) self.nearBattleNode = self.model.attachNewNode('near-battle') self.nearBattleNode.setPos(0, -25, 0) self.rewardUi = CogdoBarrelRoomRewardPanel.CogdoBarrelRoomRewardPanel() self.hideRewardUi() self.stomperSfx = base.loader.loadSfx(CogdoBarrelRoomConsts.StomperSound) self.fog = Fog('barrel-room-fog') self.fog.setColor(CogdoBarrelRoomConsts.BarrelRoomFogColor) self.fog.setLinearRange(*CogdoBarrelRoomConsts.BarrelRoomFogLinearRange) self.brBarrel = render.attachNewNode('@@CogdoBarrels') for i in range(len(CogdoBarrelRoomConsts.BarrelProps)): self.bPath = self.brBarrel.attachNewNode('%s%s' % (CogdoBarrelRoomConsts.BarrelPathName, i)) self.bPath.setPos(CogdoBarrelRoomConsts.BarrelProps[i]['pos']) self.bPath.setH(CogdoBarrelRoomConsts.BarrelProps[i]['heading']) self._isLoaded = True
def __init__(self): DirectFrame.__init__(self, relief=None, parent=base.a2dLeftCenter, geom=DGG.getDefaultDialogGeom(), geom_color=Vec4(0.8, 0.6, 0.4, 1), geom_scale=(1.85, 1, 0.9), geom_hpr=(0, 0, -90), pos=(0.5, 0, 0)) self.initialiseoptions(QuestChoiceGui) self.questChoicePosters = [] guiButton = loader.loadModel('phase_3/models/gui/quit_button') self.cancelButton = DirectButton( parent=self, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(0.7, 1, 1), text=TTLocalizer.QuestChoiceGuiCancel, text_scale=0.06, text_pos=(0, -0.02), command=self.chooseQuest, extraArgs=[0]) guiButton.removeNode() self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(self) self.timer.setScale(0.3) base.setCellsActive(base.leftCells, 0) base.setCellsActive([base.bottomCells[0], base.bottomCells[1]], 0)
def load(self): self.notify.debug('load') DistributedMinigame.load(self) self.sky = loader.loadModel('phase_3.5/models/props/TT_sky') self.ground = loader.loadModel('phase_4/models/minigames/toon_cannon_gameground') self.tower = loader.loadModel('phase_4/models/minigames/toon_cannon_water_tower') self.cannon = loader.loadModel('phase_4/models/minigames/toon_cannon') self.dropShadow = loader.loadModel('phase_3/models/props/drop_shadow') self.hill = loader.loadModel('phase_4/models/minigames/cannon_hill') self.sky.setScale(WORLD_SCALE) self.ground.setScale(GROUND_SCALE) self.cannon.setScale(CANNON_SCALE) self.dropShadow.setColor(0, 0, 0, 0.5) self.ground.setColor(0.85, 0.85, 0.85, 1.0) self.hill.setScale(1, 1, CANNON_Z / 20.0) self.dropShadow.setBin('fixed', 0, 1) self.splash = Splash.Splash(render) self.dustCloud = DustCloud.DustCloud(render) purchaseModels = loader.loadModel('phase_4/models/gui/purchase_gui') self.jarImage = purchaseModels.find('**/Jar') self.jarImage.reparentTo(hidden) self.rewardPanel = DirectLabel(parent=hidden, relief=None, pos=(-0.173, 0.0, -0.55), scale=0.65, text='', text_scale=0.2, text_fg=(0.95, 0.95, 0, 1), text_pos=(0, -.13), text_font=ToontownGlobals.getSignFont(), image=self.jarImage) self.rewardPanelTitle = DirectLabel(parent=self.rewardPanel, relief=None, pos=(0, 0, 0.06), scale=0.08, text=TTLocalizer.CannonGameReward, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1)) self.music = base.loadMusic('phase_4/audio/bgm/MG_cannon_game.ogg') self.sndCannonMove = base.loadSfx('phase_4/audio/sfx/MG_cannon_adjust.ogg') self.sndCannonFire = base.loadSfx('phase_4/audio/sfx/MG_cannon_fire_alt.ogg') self.sndHitGround = base.loadSfx('phase_4/audio/sfx/MG_cannon_hit_dirt.ogg') self.sndHitTower = base.loadSfx('phase_4/audio/sfx/MG_cannon_hit_tower.ogg') self.sndHitWater = base.loadSfx('phase_4/audio/sfx/MG_cannon_splash.ogg') self.sndWhizz = base.loadSfx('phase_4/audio/sfx/MG_cannon_whizz.ogg') self.sndWin = base.loadSfx('phase_4/audio/sfx/MG_win.ogg') self.sndRewardTick = base.loadSfx('phase_3.5/audio/sfx/tick_counter.ogg') guiModel = 'phase_4/models/gui/cannon_game_gui' cannonGui = loader.loadModel(guiModel) self.aimPad = DirectFrame(image=cannonGui.find('**/CannonFire_PAD'), relief=None, pos=(0.7, 0, -0.553333), scale=0.8) cannonGui.removeNode() self.aimPad.hide() self.fireButton = DirectButton(parent=self.aimPad, image=((guiModel, '**/Fire_Btn_UP'), (guiModel, '**/Fire_Btn_DN'), (guiModel, '**/Fire_Btn_RLVR')), relief=None, pos=(0.0115741, 0, 0.00505051), scale=1.0, command=self.__firePressed) self.upButton = DirectButton(parent=self.aimPad, image=((guiModel, '**/Cannon_Arrow_UP'), (guiModel, '**/Cannon_Arrow_DN'), (guiModel, '**/Cannon_Arrow_RLVR')), relief=None, pos=(0.0115741, 0, 0.221717)) self.downButton = DirectButton(parent=self.aimPad, image=((guiModel, '**/Cannon_Arrow_UP'), (guiModel, '**/Cannon_Arrow_DN'), (guiModel, '**/Cannon_Arrow_RLVR')), relief=None, pos=(0.0136112, 0, -0.210101), image_hpr=(0, 0, 180)) self.leftButton = DirectButton(parent=self.aimPad, image=((guiModel, '**/Cannon_Arrow_UP'), (guiModel, '**/Cannon_Arrow_DN'), (guiModel, '**/Cannon_Arrow_RLVR')), relief=None, pos=(-0.199352, 0, -0.000505269), image_hpr=(0, 0, -90)) self.rightButton = DirectButton(parent=self.aimPad, image=((guiModel, '**/Cannon_Arrow_UP'), (guiModel, '**/Cannon_Arrow_DN'), (guiModel, '**/Cannon_Arrow_RLVR')), relief=None, pos=(0.219167, 0, -0.00101024), image_hpr=(0, 0, 90)) self.aimPad.setColor(1, 1, 1, 0.9) def bindButton(button, upHandler, downHandler): button.bind(DGG.B1PRESS, lambda x, handler = upHandler: handler()) button.bind(DGG.B1RELEASE, lambda x, handler = downHandler: handler()) bindButton(self.upButton, self.__upPressed, self.__upReleased) bindButton(self.downButton, self.__downPressed, self.__downReleased) bindButton(self.leftButton, self.__leftPressed, self.__leftReleased) bindButton(self.rightButton, self.__rightPressed, self.__rightReleased) self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.hide() self.DEBUG_TOWER_RANGE = 0 self.DEBUG_CANNON_FAR_LEFT = 0 self.DEBUG_TOWER_NEAR = 1 self.DEBUG_TOWER_FAR_LEFT = 1 return
def load(self): self.timer = ToontownTimer.ToontownTimer() self.timer.setPos(1.1, 0, -0.15) self.timer.hide() self.geom = loader.loadModel('phase_5.5/models/estate/target') self.geom.reparentTo(base.cr.playGame.hood.loader.geom) self.geom.setPos(0, 0, 40) self.geom.setScale(3) self.geom.stash() self.hitSound = base.loadSfx('phase_4/audio/sfx/MG_Tag_A.mp3') self.rewardSound = base.loadSfx('phase_4/audio/sfx/MG_pos_buzzer.wav') self.scoreText = TextNode('scoreText') self.scoreText.setTextColor(1, 0, 0, 1) self.scoreText.setAlign(self.scoreText.ACenter) self.scoreText.setFont(getSignFont()) self.scoreText.setText('0') self.scoreNode = self.timer.attachNewNode(self.scoreText) self.scoreNode.setPos(0, 0, 0.35) self.scoreNode.setScale(0.25) self.curPinballScoreText = TextNode('pinballScoreText') self.curPinballScoreText.setTextColor(1, 0, 0, 1) self.curPinballScoreText.setAlign(self.scoreText.ACenter) self.curPinballScoreText.setFont(getSignFont()) self.curPinballScoreText.setText('') self.curPinballScoreNode = render.attachNewNode(self.curPinballScoreText) self.curPinballScoreNode.setPos(0.5, 0.5, 0.3) self.curPinballScoreNode.setScale(0.25) colSphere = CollisionSphere(0, 0, 0, 3.5) colSphere.setTangible(0) colNode = CollisionNode('targetSphere') colNode.addSolid(colSphere) colSphereNode = self.geom.attachNewNode(colNode) self.accept('hitTarget', self.handleHitTarget) self.accept('missedTarget', self.handleMissedTarget) self.accept('entertargetSphere', self.handleEnterTarget)
def enterSwim(self): self.notify.debug('enterSwim') base.playMusic(self.music, looping=1, volume=0.9) self.localLerp = Sequence() self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.setTime(self.TIME) self.timer.countdown(self.TIME, self.timerExpired) self.mapModel.show() self.mapAvatars = {} avatarScale = 0.025 * self.mapScaleRatio for avId in self.remoteAvIdList: avatar = base.cr.doId2do.get(avId, False) if avatar != False: self.mapAvatars[avId] = LaffMeter.LaffMeter(avatar.style, avatar.hp, avatar.maxHp) self.mapAvatars[avId].reparentTo(self.mapModel) self.mapAvatars[avId].setScale(avatarScale) self.mapAvatars[avId].start() avatar = base.cr.doId2do[self.localAvId] self.mapAvatars[self.localAvId] = LaffMeter.LaffMeter(avatar.style, avatar.hp, avatar.maxHp) self.mapAvatars[self.localAvId].reparentTo(self.mapModel) self.mapAvatars[self.localAvId].setScale(avatarScale) self.mapAvatars[self.localAvId].start() self.accept('resetClock', self.__resetClock) self.__spawnUpdateLocalToonTask() self.__spawnCrabTask() self.__spawnTreasureBoundsTask()
def announceGenerate(self): DistCogdoLevelGame.announceGenerate(self) self.timer = ToontownTimer.ToontownTimer( ) # Like in the Bossbot Field Offices, you would've been timed self.timer.stash() if __dev__: # What is this? self._durationChangedEvent = self.uniqueName('durationChanged')
def enterPlay(self): self.notify.debug('enterPlay') for i in range(self.numPlayers): avId = self.avIdList[i] avName = self.getAvatarName(avId) scorePanel = MinigameAvatarScorePanel.MinigameAvatarScorePanel( avId, avName) scorePanel.setPos(-0.213, 0.0, 0.28 * i + 0.66) scorePanel.reparentTo(base.a2dBottomRight) self.scorePanels.append(scorePanel) base.setCellsActive(base.rightCells, 0) self.walkStateData.enter() self.walkStateData.fsm.request('walking') if base.localAvatar.isIt: base.mouseInterfaceNode.setForwardSpeed( ToontownGlobals.ToonForwardSpeed * self.IT_SPEED_INCREASE) base.mouseInterfaceNode.setRotateSpeed( ToontownGlobals.ToonRotateSpeed * self.IT_ROT_INCREASE) self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.setTime(self.DURATION) self.timer.countdown(self.DURATION, self.timerExpired) base.playMusic(self.music, looping=1, volume=0.9) base.localAvatar.setIdealCameraPos(Point3(0, -24, 8))
def enterInputChoice(self): self.notify.debug('enterInputChoice') self.forceLocalToonToTire() self.controlKeyPressed = False if self.curRound == 0: self.setupStartOfMatch() else: self.notify.debug('self.curRound = %s' % self.curRound) self.timer = ToontownTimer.ToontownTimer() self.timer.hide() if self.timerStartTime != None: self.startTimer() self.showForceArrows(realPlayersOnly=True) self.localForceArrow().setPosHpr(0, 0, -1.0, 0, 0, 0) self.localForceArrow().reparentTo(self.localTireNp()) self.localForceArrow().setY(IceGameGlobals.TireRadius) self.localTireNp().headsUp(self.target) self.notify.debug('self.localForceArrow() heading = %s' % self.localForceArrow().getH()) self.curHeading = self.localTireNp().getH() self.curForce = 25 self.updateLocalForceArrow() for avId in self.forceArrowDict: forceArrow = self.forceArrowDict[avId] forceArrow.setPosHpr(0, 0, -1.0, 0, 0, 0) tireNp = self.tireDict[avId]['tireNodePath'] forceArrow.reparentTo(tireNp) forceArrow.setY(IceGameGlobals.TireRadius) tireNp.headsUp(self.target) self.updateForceArrow(avId, tireNp.getH(), 25) taskMgr.add(self.__aimTask, self.uniqueName('aimtask')) if base.localAvatar.laffMeter: base.localAvatar.laffMeter.stop() self.sendForceArrowUpdateAsap = False return
def __init__(self, tracks, timeout): DirectFrame.__init__(self, relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=Vec4(0.8, 0.6, 0.4, 1), geom_scale=(1.5, 1, 1.5), geom_hpr=(0, 0, -90), pos=(-0.85, 0, 0)) gui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_mainGui') arrowImage = (gui.find('**/tt_t_gui_mat_shuffleArrowUp'), gui.find('**/tt_t_gui_mat_shuffleArrowDown')) self.downArrow = DirectButton(parent=self, relief=None, image=arrowImage, pos=(-0.30, 0, -0.5), command=self.setPage, extraArgs=[-1]) self.upArrow = DirectButton(parent=self, relief=None, image=arrowImage, pos=(0.30, 0, -0.5), scale=-1, command=self.setPage, extraArgs=[1]) gui.removeNode() self.initialiseoptions(TrackChoiceGui) guiButton = loader.loadModel('phase_3/models/gui/quit_button') self.cancelButton = DirectButton(parent=self, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(0.7, 1, 1), text=TTLocalizer.TrackChoiceGuiCancel, pos=(0.4, 0, -0.625), text_scale=0.06, text_pos=(0, -0.02), command=self.chooseTrack, extraArgs=[-1]) self.randomButton = DirectButton(parent=self, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(1.5, 1, 1), text=TTLocalizer.TrackChoiceGuiRandom, pos=(0.4, 0, 0.625), text_scale=0.06, text_pos=(0, -0.02), command=self.areYouSure, extraArgs=[-2]) guiButton.removeNode() self.trackName = DirectLabel(parent=self, relief=None, pos=(0, 0, -0.55), text='', text_font=ToontownGlobals.getBuildingNametagFont(), text_scale=0.1, text_fg=(1,1,1,1)) self.index = 0 self.choices = [] self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(self) self.timer.setScale(0.35) self.timer.setPos(0, 0, 0.6) self.timer.countdown(timeout, self.timeout) self.trackChoicePosters = [] trackAccess = base.localAvatar.getTrackAccess() for trackId in xrange(ToontownBattleGlobals.NUM_GAG_TRACKS): if trackAccess[trackId] == 0: self.choices.append(trackId) tp = TrackPoster(trackId, self.chooseTrack) tp.reparentTo(self) self.trackChoicePosters.append(tp) for track in self.trackChoicePosters: track.setPos(0, 0, 0) track.setScale(1.5) track.hide() self.setPage(self.index) return
def setGameStart(self, timestamp, molesWhackTarget, totalTime): """ This method gets called from the AI when all avatars are ready Ready usually means they have read the rules Inheritors should call this plus the code to start the game """ self.GameDuration = totalTime self.MolesWhackedTarget = molesWhackTarget self.activeField = 1 self.isToonInRange = 0 self.scheduleMoles() self.notify.debug("%d setGameStart: Starting game" % self.doId) self.gameStartTime = \ globalClockDelta.networkToLocalTime(timestamp) self.gameStarted = True for hill in self.moleHills: hill.setGameStartTime(self.gameStartTime) curGameTime = self.getCurrentGameTime() timeLeft = self.GameDuration - curGameTime self.cleanupTimer() self.timer = ToontownTimer.ToontownTimer() self.timer.posBelowTopRightCorner() self.timer.setTime(timeLeft) self.timer.countdown(timeLeft, self.timerExpired) self.startScheduleTask() self.frame2D.show() if self.hasRestarted: self.level.countryClub.showInfoText(self.restartedText) self.sendUpdate("damageMe", []) else: self.hasRestarted = 1 self.updateGuiScore()
def load(self): minigameGui = loader.loadModel('phase_4/models/gui/minigame_rules_gui') buttonGui = loader.loadModel('phase_3.5/models/gui/inventory_gui') self.frame = DirectFrame(image=minigameGui.find('**/minigame-rules-panel'), relief=None, pos=(0.1375, 0, -0.6667)) self.gameTitleText = DirectLabel(parent=self.frame, text=self.gameTitle, scale=TTLocalizer.MRPgameTitleText, text_align=TextNode.ACenter, text_font=getSignFont(), text_fg=(1.0, 0.33, 0.33, 1.0), pos=TTLocalizer.MRgameTitleTextPos, relief=None) self.instructionsText = DirectLabel(parent=self.frame, text=self.instructions, scale=TTLocalizer.MRPinstructionsText, text_align=TextNode.ACenter, text_wordwrap=TTLocalizer.MRPinstructionsTextWordwrap, pos=TTLocalizer.MRPinstructionsTextPos, relief=None) self.playButton = DirectButton(parent=self.frame, relief=None, image=(buttonGui.find('**/InventoryButtonUp'), buttonGui.find('**/InventoryButtonDown'), buttonGui.find('**/InventoryButtonRollover')), image_color=Vec4(0, 0.9, 0.1, 1), text=TTLocalizer.MinigameRulesPanelPlay, text_fg=(1, 1, 1, 1), text_pos=(0, -0.02, 0), text_scale=TTLocalizer.MRPplayButton, pos=(1.0025, 0, -0.203), scale=1.05, command=self.playCallback) minigameGui.removeNode() buttonGui.removeNode() self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(self.frame) self.timer.setScale(0.4) self.timer.setPos(0.997, 0, 0.064) self.frame.hide() return
def setGameStart(self, timestamp, molesWhackTarget, totalTime): self.GameDuration = totalTime self.MolesWhackedTarget = molesWhackTarget self.activeField = 1 self.isToonInRange = 0 self.scheduleMoles() self.notify.debug('%d setGameStart: Starting game' % self.doId) self.gameStartTime = globalClockDelta.networkToLocalTime(timestamp) self.gameStarted = True for hill in self.moleHills: hill.setGameStartTime(self.gameStartTime) curGameTime = self.getCurrentGameTime() timeLeft = self.GameDuration - curGameTime self.cleanupTimer() self.timer = ToontownTimer.ToontownTimer() self.timer.posBelowTopRightCorner() self.timer.setTime(timeLeft) self.timer.countdown(timeLeft, self.timerExpired) self.startScheduleTask() self.frame2D.show() if self.hasRestarted: self.level.countryClub.showInfoText(self.restartedText) self.sendUpdate('damageMe', []) else: self.hasRestarted = 1 self.updateGuiScore()
def enterInputChoice(self): self.notify.debug("enterInputChoice") for button in self.diceButtonList: button.show() self.timer = ToontownTimer.ToontownTimer() self.timer.hide() if self.timerStartTime != None: self.startTimer()
def loadNextGameTimer(self): self.nextGame = DirectLabel(parent=self, relief=None, text='', text_font=ToontownGlobals.getSignFont(), text_scale=TTLocalizer.BCGnextGame * BG.CardImageScale[2], text_fg=(1.0, 1.0, 1.0, 1), pos=(BG.GridXOffset, 0, 4 * BG.CardImageScale[2])) self.nextGameTimer = ToontownTimer.ToontownTimer() self.nextGameTimer.reparentTo(self.nextGame) self.nextGameTimer.setPos(0, 0, -5 * BG.CardImageScale[2]) self.nextGameTimer.setProp('image', None) self.nextGameTimer.setProp('text_font', ToontownGlobals.getSignFont()) self.nextGameTimer.setProp('text_scale', 0.2 * BG.CardImageScale[2]) self.nextGameTimer.setFontColor(Vec4(1.0, 1.0, 1.0, 1))
def __makeGui(self): if base.config.GetBool('want-qa-regression', 0): self.notify.info('QA-REGRESSION: FISHING: ZoneId: %s' % self.pond.getArea()) if self.madeGui: return self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.hide() self.castGui = loader.loadModel('phase_4/models/gui/fishingGui') self.castGui.setScale(0.67) self.castGui.setPos(0, 1, 0) for nodeName in ('bucket', 'jar', 'display_bucket', 'display_jar'): self.castGui.find('**/' + nodeName).reparentTo(self.castGui) self.exitButton = DirectButton(parent=self.castGui, relief=None, text=('', TTLocalizer.FishingExit, TTLocalizer.FishingExit), text_align=TextNode.ACenter, text_scale=0.1, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0.0, -0.12), pos=(1.75, 0, -1.33), textMayChange=0, image=(self.castGui.find('**/exit_buttonUp'), self.castGui.find('**/exit_buttonDown'), self.castGui.find('**/exit_buttonRollover')), command=self.__userExit) self.castGui.find('**/exitButton').removeNode() self.castButton = DirectButton(parent=self.castGui, relief=None, text=TTLocalizer.FishingCast, text_align=TextNode.ACenter, text_scale=(3, 3 * 0.75, 3 * 0.75), text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -4), image=self.castGui.find('**/castButton'), image0_color=(1, 0, 0, 1), image1_color=(0, 1, 0, 1), image2_color=(1, 1, 0, 1), image3_color=(0.8, 0.5, 0.5, 1), pos=(0, -0.05, -0.666), scale=(0.036, 1, 0.048)) self.castGui.find('**/castButton').removeNode() self.arrow = self.castGui.find('**/arrow') self.arrowTip = self.arrow.find('**/arrowTip') self.arrowTail = self.arrow.find('**/arrowTail') self.arrow.reparentTo(self.castGui) self.arrow.setColorScale(0.9, 0.9, 0.1, 0.7) self.arrow.hide() self.jar = DirectLabel(parent=self.castGui, relief=None, text=str(self.av.getMoney()), text_scale=0.16, text_fg=(0.95, 0.95, 0, 1), text_font=ToontownGlobals.getSignFont(), pos=(-1.12, 0, -1.3)) self.bucket = DirectLabel(parent=self.castGui, relief=None, text='', text_scale=0.09, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), pos=(1.14, 0, -1.33)) self.__updateFishTankGui() self.itemGui = NodePath('itemGui') self.itemFrame = DirectFrame(parent=self.itemGui, relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=ToontownGlobals.GlobalDialogColor, geom_scale=(1, 1, 0.6), text=TTLocalizer.FishingItemFound, text_pos=(0, 0.2), text_scale=0.08, pos=(0, 0, 0.587)) self.itemLabel = DirectLabel(parent=self.itemFrame, text='', text_scale=0.06, pos=(0, 0, -0.25)) buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui') self.itemGuiCloseButton = DirectButton(parent=self.itemFrame, pos=(0.44, 0, -0.24), relief=None, image=(buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr')), image_scale=(0.7, 1, 0.7), command=self.__itemGuiClose) buttons.removeNode() jarGui = loader.loadModel('phase_3.5/models/gui/jar_gui') bootGui = loader.loadModel('phase_4/models/gui/fishing_boot') packageGui = loader.loadModel('phase_3.5/models/gui/stickerbook_gui').find('**/package') self.itemJellybean = DirectFrame(parent=self.itemFrame, relief=None, image=jarGui, scale=0.5) self.itemBoot = DirectFrame(parent=self.itemFrame, relief=None, image=bootGui, scale=0.2) self.itemPackage = DirectFrame(parent=self.itemFrame, relief=None, image=packageGui, scale=0.25) self.itemJellybean.hide() self.itemBoot.hide() self.itemPackage.hide() self.failureDialog = TTDialog.TTGlobalDialog(dialogName=self.uniqueName('failureDialog'), doneEvent=self.uniqueName('failureDialog'), command=self.__userExit, message=TTLocalizer.FishingFailure, style=TTDialog.CancelOnly, cancelButtonText=TTLocalizer.FishingExit) self.failureDialog.hide() self.sellFishDialog = TTDialog.TTGlobalDialog(dialogName=self.uniqueName('sellFishDialog'), doneEvent=self.uniqueName('sellFishDialog'), command=self.__sellFish, message=TTLocalizer.FishBingoOfferToSellFish, style=TTDialog.YesNo) self.sellFishDialog.hide() self.sellFishConfirmDialog = TTDialog.TTGlobalDialog(dialogName=self.uniqueName('sellFishConfirmDialog'), doneEvent=self.uniqueName('sellFishConfirmDialog'), command=self.__sellFishConfirm, message=TTLocalizer.STOREOWNER_TROPHY, style=TTDialog.Acknowledge) self.sellFishConfirmDialog.hide() self.brokeDialog = TTDialog.TTGlobalDialog(dialogName=self.uniqueName('brokeDialog'), doneEvent=self.uniqueName('brokeDialog'), command=self.__userExit, message=TTLocalizer.FishingBroke, style=TTDialog.CancelOnly, cancelButtonText=TTLocalizer.FishingExit) self.brokeDialog.hide() self.howToDialog = TTDialog.TTGlobalDialog(dialogName=self.uniqueName('howToDialog'), doneEvent=self.uniqueName('howToDialog'), fadeScreen=0, message=TTLocalizer.FishingHowToFailed, style=TTDialog.Acknowledge) self.howToDialog['command'] = self.__hideHowTo self.howToDialog.setPos(-0.3, 0, 0.5) self.howToDialog.hide() self.madeGui = 1 return
def enterPlay(self): self.notify.debug('enterPlay') self.gui.createScoresPanel(self.avIdList) self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.setTime(self.TIME) self.timer.countdown(self.TIME, self.__handleTimeout) self.player.start() self.cog.start() self.theme.stop() self.theme.setVolume(1) self.theme.play()
def __init__(self): self.index = 0 self.id = time.time() self.lastGlove = base.localAvatar.style.gloveColor self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(aspect2d) self.timer.posInTopRightCorner() self.timer.countdown(GloveNPCGlobals.TIMER_SECONDS, self.__exit, [GloveNPCGlobals.TIMER_END]) self.setupButtons() self.bindButtons() self.__updateIndex(0)
def enterInputChoice(self): self.notify.debug('enterInputChoice') NametagGlobals.setOnscreenChatForced(1) self.timer = ToontownTimer.ToontownTimer() self.timer.hide() if self.timerStartTime != None: self.startTimer() if base.localAvatar.laffMeter: base.localAvatar.laffMeter.stop() self.gui.show() self.showMinigamesAndBonuses() return
def setGameStart(self, timestamp): self.notify.debug('%d setGameStart: Starting game' % self.doId) self.gameStartTime = globalClockDelta.networkToLocalTime(timestamp) self.gameStarted = True curGameTime = self.getCurrentGameTime() timeLeft = self.GameDuration - curGameTime self.cleanupTimer() self.timer = ToontownTimer.ToontownTimer() self.timer.posBelowTopRightCorner() self.timer.setTime(timeLeft) self.timer.countdown(timeLeft, self.timerExpired) self.startScheduleTask() self.frame2D.show()
def enterPlay(self): self.notify.debug("enterPlay") # Initialize the scoreboard for i in range(self.numPlayers): avId = self.avIdList[i] avName = self.getAvatarName(avId) scorePanel = \ MinigameAvatarScorePanel.MinigameAvatarScorePanel(avId, avName) scorePanel.reparentTo(base.a2dTopRight) scorePanel.setPos(-0.213, 0.0, -0.5 - 0.28 * i) self.scorePanels.append(scorePanel) self.goalBar.show() self.goalBar['value'] = 0. # We need the right edge of the screen for display of the # scoreboard, so we can't have any offscreen popups there. base.setCellsAvailable(base.rightCells, 0) self.__spawnUpdateSuitsTask() orthoDrive = OrthoDrive( self.TOON_SPEED, maxFrameMove=self.MAX_FRAME_MOVE, customCollisionCallback=self.__doMazeCollisions, priority = 1 ) self.orthoWalk = OrthoWalk(orthoDrive, broadcast=not self.isSinglePlayer()) self.orthoWalk.start() # listen for collisions with the suits self.accept(MazeSuit.COLLISION_EVENT_NAME, self.__hitBySuit) # listen for treasure pickups self.accept(self.TREASURE_GRAB_EVENT_NAME, self.__treasureGrabbed) # Start counting down the game clock, # call timerExpired when it reaches 0 self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.setTime(MazeGameGlobals.GAME_DURATION) self.timer.countdown(MazeGameGlobals.GAME_DURATION, self.timerExpired) # listen for resetClock messages so we can keep our clock in sync self.accept("resetClock", self.__resetClock) base.playMusic(self.music, looping = 0, volume = .8)
def enterPlay(self): self.notify.debug('enterPlay') self.orthoWalk.start() for suit in self.suits: suitCollSphere = CollisionSphere(0, 0, 0, 1.0) suit.collSphereName = 'suitCollSphere%s' % self.suits.index(suit) suitCollSphere.setTangible(0) suitCollNode = CollisionNode(self.uniqueName(suit.collSphereName)) suitCollNode.setIntoCollideMask(ToontownGlobals.WallBitmask) suitCollNode.addSolid(suitCollSphere) suit.collNodePath = suit.attachNewNode(suitCollNode) suit.collNodePath.hide() if self.ShowSuitSpheres: suit.collNodePath.show() self.accept(self.uniqueName('enter' + suit.collSphereName), self.handleSuitCollision) self.scores = [0] * self.numPlayers spacing = 0.40000000000000002 for i in xrange(self.numPlayers): avId = self.avIdList[i] avName = self.getAvatarName(avId) scorePanel = MinigameAvatarScorePanel.MinigameAvatarScorePanel( avId, avName) scorePanel.setScale(0.90000000000000002) scorePanel.setPos(0.75 - spacing * (self.numPlayers - 1 - i), 0.0, 0.84999999999999998) scorePanel.makeTransparent(0.75) self.scorePanels.append(scorePanel) self.fruitsCaught = 0 self.droppedObjCaught = {} self.dropIntervals = {} self.droppedObjNames = [] self.dropSchedule = [] self.numItemsDropped = 0 self.scheduleDrops() self.startDropTask() if self.WantSuits: self.startSuitWalkTask() self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.setTime(CatchGameGlobals.GameDuration) self.timer.countdown(CatchGameGlobals.GameDuration, self.timerExpired) self.timer.setTransparency(1) self.timer.setColorScale(1, 1, 1, 0.75) base.playMusic(self.music, looping=0, volume=0.90000000000000002)
def load(self): # create the timer self.timer = ToontownTimer.ToontownTimer() self.timer.setPos(-0.305, 0.0, 0.800) self.timer.reparentTo(base.a2dBottomRight) self.timer.hide() # load the model self.geom = loader.loadModel("phase_5.5/models/estate/target") self.geom.reparentTo(base.cr.playGame.hood.loader.geom) self.geom.setPos(0, 0, 40) self.geom.setScale(3) self.geom.stash() self.hitSound = base.loader.loadSfx("phase_4/audio/sfx/MG_Tag_A.mp3") self.rewardSound = base.loader.loadSfx( "phase_4/audio/sfx/MG_pos_buzzer.wav") # create a text node to display the score self.scoreText = TextNode("scoreText") self.scoreText.setTextColor(1, 0, 0, 1) self.scoreText.setAlign(self.scoreText.ACenter) self.scoreText.setFont(getSignFont()) self.scoreText.setText("0") self.scoreNode = self.timer.attachNewNode(self.scoreText) self.scoreNode.setPos(0, 0, .35) self.scoreNode.setScale(.25) # create pinballInfo stuff self.curPinballScoreText = TextNode("pinballScoreText") self.curPinballScoreText.setTextColor(1, 0, 0, 1) self.curPinballScoreText.setAlign(self.scoreText.ACenter) self.curPinballScoreText.setFont(getSignFont()) self.curPinballScoreText.setText("") self.curPinballScoreNode = render.attachNewNode( self.curPinballScoreText) self.curPinballScoreNode.setPos(0.5, 0.5, .30) self.curPinballScoreNode.setScale(.25) # setup a collision sphere colSphere = CollisionSphere(0, 0, 0, 3.5) colSphere.setTangible(0) colNode = CollisionNode("targetSphere") colNode.addSolid(colSphere) colSphereNode = self.geom.attachNewNode(colNode) self.accept("hitTarget", self.handleHitTarget) self.accept("missedTarget", self.handleMissedTarget) #self.accept('f3-up', self.handleHitTarget) self.accept("entertargetSphere", self.handleEnterTarget)
def __init__(self, eventDict, petSeeds): self.eventDict = eventDict self.mainMenuDoneEvent = 'MainMenuGuiDone' self.adoptPetDoneEvent = 'AdoptPetGuiDone' self.returnPetDoneEvent = 'ReturnPetGuiDone' self.petChooserDoneEvent = 'PetChooserGuiDone' self.fishGuiDoneEvent = 'MyFishGuiDone' self.namePickerDoneEvent = 'NamePickerGuiDone' self.goHomeDlgDoneEvent = 'GoHomeDlgDone' self.dialog = None self.dialogStack = [] self.petSeeds = petSeeds self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(aspect2d) self.timer.posInTopRightCorner() self.timer.countdown(PetConstants.PETCLERK_TIMER, self.__timerExpired) self.doDialog(Dialog_MainMenu)
def __init__(self, tracks, timeout): DirectFrame.__init__( self, relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=Vec4(0.8, 0.6, 0.4, 1), geom_scale=(1.5, 1, .9), geom_hpr=(0, 0, -90), pos=(-0.85, 0, 0), ) self.initialiseoptions(TrackChoiceGui) guiButton = loader.loadModel("phase_3/models/gui/quit_button") self.cancelButton = DirectButton( parent=self, relief=None, image=( guiButton.find("**/QuitBtn_UP"), guiButton.find("**/QuitBtn_DN"), guiButton.find("**/QuitBtn_RLVR"), ), image_scale=(0.7, 1, 1), text=TTLocalizer.TrackChoiceGuiCancel, pos=(0.15, 0, -0.625), text_scale=0.06, text_pos=(0, -0.02), command=self.chooseTrack, extraArgs=[-1], ) guiButton.removeNode() self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(self) self.timer.setScale(0.35) self.timer.setPos(-0.2, 0, -0.6) self.timer.countdown(timeout, self.timeout) self.trackChoicePosters = [] for trackId in tracks: tp = TrackPoster(trackId, self.chooseTrack) tp.reparentTo(self) self.trackChoicePosters.append(tp) self.trackChoicePosters[0].setPos(0, 0, -0.2) self.trackChoicePosters[1].setPos(0, 0, 0.4)
def enterPlay(self): self.notify.debug('enterPlay') base.playMusic(self.music, looping = 1, volume = 0.90000000000000002) orthoDrive = OrthoDrive(self.TOON_SPEED, maxFrameMove = self.MAX_FRAME_MOVE, customCollisionCallback = self._DistributedPairingGame__doPairingGameCollisions) self.orthoWalk = OrthoWalk(orthoDrive, broadcast = not self.isSinglePlayer()) self.orthoWalk.start() self.accept('insert', self._DistributedPairingGame__flipKeyPressed) self.accept('delete', self._DistributedPairingGame__flipKeyPressed) self.accept('time-control', self._DistributedPairingGame__beginSignal) self.accept('time-control-up', self._DistributedPairingGame__endSignal) self.bonusGlowIndex = 0 self.bonusGlowCard = self.bonusTraversal[self.bonusGlowIndex] self.startBonusTask() self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.setTime(self.gameDuration) self.timer.countdown(self.gameDuration, self.timerExpired) if base.localAvatar.laffMeter: base.localAvatar.laffMeter.stop()