def __init__(self, description, needed, icon):
        NodePath.__init__(self, 'objective-%s' % id(self))

        self.needed = needed
        self.visible = False

        self.fadeInTrack = None
        self.fadeOutTrack = None

        gui = loader.loadModel(
            'phase_5/models/cogdominium/tt_m_gui_csa_flyThru')
        self.background = gui.find('**/*background').copyTo(self)
        self.background.setScale(2.5)
        gui.removeNode()

        self.icon = icon.copyTo(self.background)
        self.icon.setScale(0.08)
        self.icon.setPos(-0.167, 0, -0.002)

        text = TextNode('challenge')
        text.setText('Challenge')
        text.setFont(ToontownGlobals.getSignFont())
        text.setTextColor(0.95, 0.95, 0, 1)
        self.objText = self.background.attachNewNode(text)
        self.objText.setScale(0.03)
        self.objText.setPos(-0.04, 0.0, 0.02)

        text = TextNode('description')
        text.setText(description)
        text.setFont(ToontownGlobals.getSignFont())
        text.setTextColor(0.95, 0.95, 0, 1)
        text.setAlign(TextNode.ACenter)
        self.objText = self.background.attachNewNode(text)
        self.objText.setScale(0.015)
        self.objText.setPos(0.048, 0.0, -0.009)

        self.progressBar = DirectWaitBar(guiId='ChallengeProgressBar',
                                         parent=self.background,
                                         frameSize=(-0.11, 0.11, -0.007,
                                                    0.007),
                                         pos=(0.048, 0, -0.0338),
                                         text='')
        self.progressBar['range'] = needed

        self.progressText = DirectLabel(
            guiId='ChallengeProgressText',
            parent=self.progressBar,
            relief=None,
            pos=(0, 0, -0.0048),
            text='',
            textMayChange=1,
            text_scale=0.014,
            text_fg=(0.03, 0.83, 0, 1),
            text_align=TextNode.ACenter,
            text_font=ToontownGlobals.getSignFont())

        self.updateProgress(0)

        self.reparentTo(base.a2dBottomLeft)
        self.stash()
 def enterFrozen(self):
     self.loadIceCube()
     base.playSfx(self.iceFormSfx)
     base.cr.playGame.getPlace().fsm.request('stop', [0])
     base.localAvatar.stop()
     base.playSfx(choice(self.frozenSfxArray))
     self.iccsIval = LerpColorScaleInterval(
         self.iceCube,
         duration=0.5,
         colorScale=VBase4(0.76, 0.76, 1.0, 1.0),
         startColorScale=self.iceCube.getColorScale(),
         blendType='easeInOut')
     self.iccsIval.start()
     props = WindowProperties()
     props.setCursorHidden(True)
     base.win.requestProperties(props)
     self.frame = DirectFrame(pos=(0, 0, 0.7))
     self.powerBar = DirectWaitBar(frameColor=(1, 1, 1, 1),
                                   range=100,
                                   value=0,
                                   scale=(0.4, 0.5, 0.25),
                                   parent=self.frame,
                                   barColor=(0.55, 0.7, 1.0, 1.0))
     self.label = OnscreenText(text="SHAKE MOUSE",
                               shadow=(0, 0, 0, 1),
                               fg=(0.55, 0.7, 1.0, 1.0),
                               pos=(0, -0.1, 0),
                               parent=self.frame)
     taskMgr.add(self.__watchMouseMovement, 'BRWater-watchMouseMovement')
     taskMgr.add(self.__lowerPowerBar, 'BRWater-lowerPowerBar')
     mw = base.mouseWatcherNode
     if mw.hasMouse():
         self.lastMouseX = mw.getMouseX()
Пример #3
0
 def makeGui(self):
     self.destroyGui()
     self.guiFrame = DirectFrame(parent = base.a2dBottomRight, pos=(-0.55, 0, 0.15))
     self.guiBg = OnscreenImage(image = "phase_4/maps/turret_gui_bg.png", scale = (0.15, 0, 0.075), parent = self.guiFrame)
     self.guiBg.setTransparency(True)
     self.guiLabel = DirectLabel(text = "Turret", text_fg = (1, 0, 0, 1), relief = None, text_scale = 0.05, text_font = loader.loadFont("phase_3/models/fonts/ImpressBT.ttf"), pos = (0, 0, 0.025), parent = self.guiFrame)
     self.guiBar = DirectWaitBar(range = self.myTurret.getMaxHealth(), value = self.myTurret.getHealth(), scale = 0.125, parent = self.guiFrame, pos = (0, 0, -0.01))
Пример #4
0
 def __init__(self):
     NodePath.__init__(self, 'wave-gui')
     self.reparentTo(base.a2dBottomCenter)
     self.setBin('fixed', 60)
     self.setTransparency(True, 1)
     self.setAlphaScale(0.75, 1)
     self.setZ(0.1)
     self.frame = DirectFrame(image='materials/ui/wave_ui_base.png',
                              parent=self,
                              relief=None,
                              image_scale=(.373, 1, .094))
     self.waveText = OnscreenText(text="Wave 4",
                                  pos=(0, 0.0175, 0),
                                  scale=0.06,
                                  parent=self.frame)
     self.progress = DirectWaitBar(scale=(.324, 1, .3),
                                   relief=None,
                                   barColor=(1, 0.75, 0, 1),
                                   parent=self.frame,
                                   pos=(0, 0, -0.0293))
     self.progress.setBin('fixed', 61)
     self.progress['range'] = 50
     self.progress['value'] = 35
     self.progressText = OnscreenText(text=str(self.progress['value']) +
                                      " / " + str(self.progress['range']),
                                      scale=0.04,
                                      parent=self.frame,
                                      pos=(0, -0.04, 0))
     self.progressText.setBin('fixed', 62)
     self.hide()
Пример #5
0
    def __init__(self):
        # a fill panel so the player doesn't see how everything
        # gets loaded in the background
        self.frameMain = DirectFrame(
            # size of the frame
            frameSize = (base.a2dLeft, base.a2dRight,
                         base.a2dTop, base.a2dBottom),
			image = "Logo.png",
			image_scale = (0.612/2.0, 1, 0.495/2.0),
			image_pos = (0, 0, 0.7),
            # tramsparent bg color
            frameColor = (0, 0, 0, 1))
        self.frameMain.setTransparency(1)

        # the text Loading... on top
        self.lblLoading = DirectLabel(
            scale = 0.25,
            pos = (0, 0, 0),
            frameColor = (0, 0, 0, 0),
            text = _("Loading..."),
            text_align = TextNode.ACenter,
            text_fg = (1,1,1,1))
        self.lblLoading.reparentTo(self.frameMain)

        # the waitbar on the bottom
        self.wbLoading = DirectWaitBar(
            text = "0%",
            text_fg = (1,1,1,1),
            value = 0,
            pos = (0, 0, -0.5),
            barColor = (0.5, 0.4, 0.1, 1),
            frameColor = (0.1, 0.1, 0.1, 1))
        self.wbLoading.reparentTo(self.frameMain)
Пример #6
0
class WaitBar(DirectObject):
    """
    Wrapper for DirectWaitBar that scales/moves accordingly to the window size (for Pixel2d root).
    """
    def __init__(self, parent):
        super().__init__()
        self.node = parent.attach_new_node("cooldown bar")
        self.wait_bar = DirectWaitBar(
            value=0,
            scale=1,
            parent=self.node,
            frameColor=(0, 0, 0, 0.3),
            barColor=(1, 1, 0, 0.6),
        )
        self.width = 0.026
        self.height = 0.005
        self.accept("aspectRatioChanged", self.aspect_ratio_change_update)

    def aspect_ratio_change_update(self):
        """
        Rescale/move wait-bar when the window size has changed.
        """

        reference_width = core.instance.win.get_x_size()
        reference_height = core.instance.win.get_y_size()
        width_px = reference_width * self.width
        height_px = reference_height * self.height
        self.wait_bar["frameSize"] = (
            0,
            width_px,
            height_px,
            0,
        )
        self.wait_bar.set_pos(reference_width * -0.026, 0, 0)
Пример #7
0
 def _initPiePowerMeter(self):
     h = PartyGlobals.CogActivityPowerMeterHeight / 2.0
     w = PartyGlobals.CogActivityPowerMeterWidth / 2.0
 
     self._piePowerMeter = DirectWaitBar(
         frameSize = (-h, h, -w, w),
         relief = DGG.GROOVE,
         frameColor = (0.9, 0.9, 0.9, 1.0),
         borderWidth = (0.01, 0.01),
         barColor = PartyGlobals.CogActivityColors[0],
         pos = PartyGlobals.CogActivityPowerMeterPos,
         hpr = (0.0, 0.0, -90.0),
         )
     
     self._piePowerMeter.setBin("fixed", 0)
     
     self._piePowerTitle = OnscreenText(
         text=TTLocalizer.PartyCogGuiPowerLabel,
         pos=PartyGlobals.CogActivityPowerMeterTextPos,
         scale=0.05,
         fg=(1.0, 1.0, 1.0, 1.0),
         align=TextNode.ACenter,
         )
         
     self._piePowerTitle.setBin("fixed", 0)
     
     self._piePowerMeter.hide()
     self._piePowerTitle.hide()  
Пример #8
0
Файл: hud.py Проект: iPazu/Slimy
    def __init__(self):
        self.lifeBar = DirectWaitBar(value=100,
                                     barColor=(0, 1, 0.20, 1),
                                     barRelief=DGG.RAISED,
                                     relief=DGG.RIDGE,
                                     frameColor=(0.8, 0.05, 0.10, 1),
                                     frameSize=(-1.2, 0, 0, -0.1),
                                     pos=(-0.2, 0, base.a2dTop))
        self.lifeBar.setTransparency(1)

        self.font = loader.loadFont(
            str(MAINDIR) + '/assets/fonts/allerdisplay.ttf')

        self.score_text = OnscreenText(text="Score:",
                                       pos=(-1.6, 0.93),
                                       scale=0.05,
                                       fg=(1, 1, 1, 1),
                                       align=TextNode.ACenter,
                                       font=self.font,
                                       mayChange=False)
        self.score = OnscreenText(text="0",
                                  pos=(-1.6, 0.83),
                                  scale=0.07,
                                  fg=(1, 1, 1, 1),
                                  align=TextNode.ACenter,
                                  font=self.font,
                                  mayChange=True)

        self.accept("hud_setLifeBarValue", self.setLifeBarValue)
        self.hide()
Пример #9
0
    def start(self):
        self.fullyChargedSound = base.loadSfx('phase_4/audio/sfx/ring_get.ogg')
        self.rechargeSound = base.loadSfx(
            'phase_4/audio/sfx/MG_sfx_travel_game_blue_arrow.ogg')
        self.batteryFrame = DirectFrame(parent=base.a2dBottomRight,
                                        pos=(-0.2, 0, 0.1),
                                        scale=(0.8, 0, 1))
        self.batteryBg = OnscreenImage(
            image='phase_4/maps/battery_charge_frame.png',
            parent=self.batteryFrame)
        self.batteryBg.setTransparency(1)
        self.batteryBg.setX(0.03)
        self.batteryBg.setScale(0.17, 0, 0.05)
        self.batteryBg.setColorScale(0, 0, 0, 1)
        self.batteryBar = DirectWaitBar(value=0,
                                        range=5,
                                        barColor=(1, 1, 1, 1),
                                        relief=None,
                                        scale=(0.12, 0.0, 0.3),
                                        parent=self.batteryFrame)

        self.viewfinder = Viewfinder(1.0)

        base.localAvatar.walkControls.setWalkSpeed(CIGlobals.ToonForwardSpeed,
                                                   0.0,
                                                   CIGlobals.ToonReverseSpeed,
                                                   CIGlobals.ToonRotateSpeed)
        FirstPerson.start(self)
Пример #10
0
    def __init__(self):
        self.lifeBar1 = DirectWaitBar(
            text = "Player1",
            text_fg = (1,1,1,1),
            text_pos = (-1.2, -0.18, 0),
            text_align = TextNode.ALeft,
            value = 100,
            barColor = (0, 1, 0.25, 1),
            barRelief = DGG.RAISED,
            barBorderWidth = (0.03, 0.03),
            borderWidth = (0.01, 0.01),
            relief = DGG.RIDGE,
            frameColor = (0.8,0.05,0.10,1),
            frameSize = (-1.2, 0, -0.1, 0),
            pos = (-0.2,0,base.a2dTop-0.15))
        self.lifeBar1.setTransparency(1)

        self.lifeBar2 = DirectWaitBar(
            text = "Player2",
            text_fg = (1,1,1,1),
            text_pos = (1.2, -0.18, 0),
            text_align = TextNode.ARight,
            value = 100,
            barColor = (0, 1, 0.25, 1),
            barRelief = DGG.RAISED,
            barBorderWidth = (0.03, 0.03),
            borderWidth = (0.01, 0.01),
            relief = DGG.RIDGE,
            frameColor = (0.8,0.05,0.10,1),
            frameSize = (0, 1.2, -0.1, 0),
            pos = (0.2,0,base.a2dTop-0.15))
        self.lifeBar2.setTransparency(1)

        self.accept("hud_setLifeBarValue", self.setLifeBarValue)
        self.hide()
Пример #11
0
    def __init__(self):
        self.lifeBar1 = DirectWaitBar(text="Player1",
                                      text_fg=(1, 1, 1, 1),
                                      text_pos=(-1.2, -0.18, 0),
                                      text_align=TextNode.ALeft,
                                      value=100,
                                      barColor=(0, 1, 0.25, 1),
                                      barRelief=DGG.RAISED,
                                      barBorderWidth=(0.03, 0.03),
                                      borderWidth=(0.01, 0.01),
                                      relief=DGG.RIDGE,
                                      frameColor=(0.8, 0.05, 0.10, 1),
                                      frameSize=(-1.2, 0, 0, -0.1),
                                      pos=(-0.2, 0, base.a2dTop - 0.15))
        self.lifeBar1.setTransparency(1)

        self.lifeBar2 = DirectWaitBar(text="Player2",
                                      text_fg=(1, 1, 1, 1),
                                      text_pos=(1.2, -0.18, 0),
                                      text_align=TextNode.ARight,
                                      value=100,
                                      barColor=(0, 1, 0.25, 1),
                                      barRelief=DGG.RAISED,
                                      barBorderWidth=(0.03, 0.03),
                                      borderWidth=(0.01, 0.01),
                                      relief=DGG.RIDGE,
                                      frameColor=(0.8, 0.05, 0.10, 1),
                                      frameSize=(0, 1.2, 0, -0.1),
                                      pos=(0.2, 0, base.a2dTop - 0.15))
        self.lifeBar2.setTransparency(1)

        self.accept("hud_setLifeBarValue", self.setLifeBarValue)
        self.hide()
Пример #12
0
 def setupHealthBar(self):
     self.hpBar = DirectWaitBar(text="",
                                value=100.0,
                                pos=(0, 0, 1.5),
                                scale=0.3,
                                barColor=Vec4(1, 0, 0, 1))
     self.hpBar.setBillboardPointEye()
     self.hpBar.reparentTo(self.eNode)
 def setupPowerBar(self):
     self.powerBar = DirectWaitBar(pos=(0.0, 0, -0.94), relief=DGG.SUNKEN, frameSize=(-2.0,
      2.0,
      -0.2,
      0.2), borderWidth=(0.02, 0.02), scale=0.25, range=1, sortOrder=50, frameColor=(0.5, 0.5, 0.5, 0.5), barColor=(0.75, 0.75, 1.0, 0.8), text='', text_scale=0.26, text_fg=(1, 1, 1, 1), text_align=TextNode.ACenter, text_pos=(0, -0.05))
     self.power = 0
     self.powerBar['value'] = self.power
     self.powerBar.hide()
Пример #14
0
 def __init__(self, barColor=(255, 0, 0, 1), pos=(1.0, 0, 0.9)):
     self.bar = DirectWaitBar(pos=pos,
                              barColor=barColor,
                              text="",
                              value=0,
                              range=30,
                              frameSize=(-0.3, 0.3, 0, 0.03),
                              frameColor=(0, 0, 255, 1))
class PowerBar(NodePath):

    def __init__(self):
        NodePath.__init__(self, 'pbar')
        self.bar = DirectWaitBar(range = 150, frameColor = (1, 1, 1, 1), barColor = (0.286, 0.901, 1, 1), relief = DGG.RAISED,
                               borderWidth = (0.04, 0.04), pos = (0, 0, 0.85), scale = 0.2, hpr = (0, 0, 0),
                               parent = self, frameSize = (-0.85, 0.85, -0.12, 0.12))
        self.hide()
        self.reparentTo(aspect2d)
        self.speed = 0.2
        self.exponent = 0.75
        self.startTime = 0.0
        self.task = None
        
    def __getPower(self, time):
        elapsed = max(time - self.startTime, 0.0)
        t = elapsed / self.speed
        t = math.pow(t, self.exponent)
        power = int(t * 150) % 300
        if power > 150:
            power = 300 - power
        return power
        
    def getPower(self):
        return self.bar['value']
        
    def start(self):
        taskMgr.remove("hideBarTask-" + str(id(self)))
        
        self.startTime = globalClock.getFrameTime()
        self.task = taskMgr.add(self.__powerBarUpdate, "powerBarUpdate-" + str(id(self)))
        self.show()
        
    def __powerBarUpdate(self, task):
        self.bar['value'] = self.__getPower(globalClock.getFrameTime())
        return task.cont
        
    def stop(self, hideAfter = -1):
        if self.task:
            self.task.remove()
        self.task = None
        if hideAfter != -1:
            taskMgr.doMethodLater(hideAfter, self.__hideBarTask, "hideBarTask-" + str(id(self)))
            
    def __hideBarTask(self, task):
        self.hide()
        return task.done
        
    def destroy(self):
        taskMgr.remove("hideBarTask-" + str(id(self)))
        taskMgr.remove("powerBarUpdate-" + str(id(self)))
        self.stop()
        self.speed = None
        self.exponent = None
        self.startTime = None
        self.bar.destroy()
        self.bar = None
        self.removeNode()
Пример #16
0
    def onstage(self):
        self.notify.debug('onstage')
        DistributedMinigame.onstage(self)
        self.maze.onstage()
        self.randomNumGen.shuffle(self.startPosHTable)
        lt = base.localAvatar
        lt.reparentTo(render)
        lt.hideName()
        self.__placeToon(self.localAvId)
        lt.setAnimState('Happy', 1.0)
        lt.setSpeed(0, 0)
        self.camParent = render.attachNewNode('mazeGameCamParent')
        self.camParent.reparentTo(base.localAvatar)
        self.camParent.setPos(0, 0, 0)
        self.camParent.setHpr(render, 0, 0, 0)
        camera.reparentTo(self.camParent)
        camera.setPos(self.camOffset)
        self.__spawnCameraTask()
        self.toonRNGs = []
        for i in xrange(self.numPlayers):
            self.toonRNGs.append(RandomNumGen.RandomNumGen(self.randomNumGen))

        self.treasures = []
        for i in xrange(self.maze.numTreasures):
            self.treasures.append(MazeTreasure.MazeTreasure(self.treasureModel, self.maze.treasurePosList[i], i, self.doId))

        self.__loadSuits()
        for suit in self.suits:
            suit.onstage()

        self.sndTable = {'hitBySuit': [None] * self.numPlayers, 'falling': [
                     None] * self.numPlayers}
        for i in xrange(self.numPlayers):
            self.sndTable['hitBySuit'][i] = base.loader.loadSfx('phase_4/audio/sfx/MG_Tag_C.ogg')
            self.sndTable['falling'][i] = base.loader.loadSfx('phase_4/audio/sfx/MG_cannon_whizz.ogg')

        self.grabSounds = []
        for i in xrange(5):
            self.grabSounds.append(base.loader.loadSfx('phase_4/audio/sfx/MG_maze_pickup.ogg'))

        self.grabSoundIndex = 0
        for avId in self.avIdList:
            self.toonHitTracks[avId] = Wait(0.1)

        self.scores = [0] * self.numPlayers
        self.goalBar = DirectWaitBar(parent=render2d, relief=DGG.SUNKEN, frameSize=(-0.35,
                                                                                    0.35,
                                                                                    -0.15,
                                                                                    0.15), borderWidth=(0.02,
                                                                                                        0.02), scale=0.42, pos=(0.84, 0, 0.5 - 0.28 * self.numPlayers + 0.05), barColor=(0,
                                                                                                                                                                                         0.7,
                                                                                                                                                                                         0,
                                                                                                                                                                                         1))
        self.goalBar.setBin('unsorted', 0)
        self.goalBar.hide()
        self.introTrack = self.getIntroTrack()
        self.introTrack.start()
        return
    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
Пример #18
0
class WaveGUI(NodePath):
    def __init__(self):
        NodePath.__init__(self, 'wave-gui')
        self.reparentTo(base.a2dBottomCenter)
        self.setBin('fixed', 60)
        self.setTransparency(True, 1)
        self.setAlphaScale(0.75, 1)
        self.setZ(0.1)
        self.frame = DirectFrame(image='materials/ui/wave_ui_base.png',
                                 parent=self,
                                 relief=None,
                                 image_scale=(.373, 1, .094))
        self.waveText = OnscreenText(text="Wave 4",
                                     pos=(0, 0.0175, 0),
                                     scale=0.06,
                                     parent=self.frame)
        self.progress = DirectWaitBar(scale=(.324, 1, .3),
                                      relief=None,
                                      barColor=(1, 0.75, 0, 1),
                                      parent=self.frame,
                                      pos=(0, 0, -0.0293))
        self.progress.setBin('fixed', 61)
        self.progress['range'] = 50
        self.progress['value'] = 35
        self.progressText = OnscreenText(text=str(self.progress['value']) +
                                         " / " + str(self.progress['range']),
                                         scale=0.04,
                                         parent=self.frame,
                                         pos=(0, -0.04, 0))
        self.progressText.setBin('fixed', 62)
        self.hide()

    def doHide(self):
        Sequence(
            LerpColorScaleInterval(self,
                                   1.0, (1, 1, 1, 0), (1, 1, 1, 0.75),
                                   override=1), Func(self.hide)).start()

    def doShow(self):
        Sequence(
            Func(self.show),
            LerpColorScaleInterval(self,
                                   1.0, (1, 1, 1, 0.75), (1, 1, 1, 0),
                                   override=1)).start()

    def incProgress(self):
        self.adjustProgress(self.progress['value'] + 1)

    def adjustForWave(self, waveNum, suits):
        self.waveText['text'] = "Wave {0}".format(waveNum)
        self.progress['range'] = suits
        self.adjustProgress(0)

    def adjustProgress(self, progress):
        self.progress['value'] = progress
        self.progressText['text'] = str(self.progress['value']) + " / " + str(
            self.progress['range'])
 def __init__(self, mg, cr, avId):
     RemoteAvatar.__init__(self, mg, cr, avId)
     self.health = 100
     self.retrieveAvatar()
     if game.process == 'client':
         self.healthBar = DirectWaitBar(value=100)
         self.healthBar.setBillboardAxis()
         self.healthBar.reparentTo(self.avatar)
         self.healthBar.setZ(self.avatar.nametag3d.getZ(self.avatar) + 1)
         print "generated health bar"
 def initHealthBar(self):
     self.healthBar = DirectWaitBar(frameSize=(-0.35, 0.35, -0.04, 0.04),
                                    relief=DGG.FLAT,
                                    frameColor=(0.0, 0.0, 0.0, 0.0),
                                    borderWidth=(0.0, 0.0),
                                    barColor=(0.0, 1.0, 0.0, 1.0),
                                    scale=100)
     self.healthBar.setBillboardPointEye()
     self.healthBar['value'] = 100
     self.healthBar.hide(OTPRender.ReflectionCameraBitmask)
     self.healthBar.setLightOff()
Пример #21
0
class LoadingScreen():
    def __init__(self):
        # a fill panel so the player doesn't see how everything
        # gets loaded in the background
        self.frameMain = DirectFrame(
            # size of the frame
            frameSize = (base.a2dLeft, base.a2dRight,
                         base.a2dTop, base.a2dBottom),
			image = "Logo.png",
			image_scale = (0.612/2.0, 1, 0.495/2.0),
			image_pos = (0, 0, 0.7),
            # tramsparent bg color
            frameColor = (0, 0, 0, 1))
        self.frameMain.setTransparency(1)

        # the text Loading... on top
        self.lblLoading = DirectLabel(
            scale = 0.25,
            pos = (0, 0, 0),
            frameColor = (0, 0, 0, 0),
            text = _("Loading..."),
            text_align = TextNode.ACenter,
            text_fg = (1,1,1,1))
        self.lblLoading.reparentTo(self.frameMain)

        # the waitbar on the bottom
        self.wbLoading = DirectWaitBar(
            text = "0%",
            text_fg = (1,1,1,1),
            value = 0,
            pos = (0, 0, -0.5),
            barColor = (0.5, 0.4, 0.1, 1),
            frameColor = (0.1, 0.1, 0.1, 1))
        self.wbLoading.reparentTo(self.frameMain)

    def show(self):
        self.frameMain.show()
        # and render two frames so the loading screen
        # is realy shown on screen
        base.graphicsEngine.renderFrame()
        base.graphicsEngine.renderFrame()

    def hide(self):
        self.frameMain.hide()

    def setLoadingValue(self, value):
        """Set the waitbar value to the given value, where
        value has to be a integer from 0 to 100"""
        if value > 100: value = 100
        if value < 0: value = 0
        self.wbLoading["value"] = value
        self.wbLoading["text"] = "{0}%".format(value)
        base.graphicsEngine.renderFrame()
        base.graphicsEngine.renderFrame()
 def createInterface(self):
     self.cogProgressBar = DirectWaitBar(pos=(0, 0, -0.9),
                                         relief=DGG.RAISED,
                                         scale=0.6,
                                         frameColor=(1, 0.5, 0.3, 0.75),
                                         barColor=(1, 0.25, 0.25, 0.5),
                                         value=0,
                                         range=self.getTotalCogs(),
                                         text="",
                                         text_scale=0.08)
     self.__updateProgressBar()
 def load(self):
     if self.isToon:
         self.barGeom = loader.loadModel('phase_3.5/models/gui/exp_bar')
         self.color = self.style.getHeadColor()
         self.bgBar = DirectFrame(parent=base.a2dBottomLeft,
                                  relief=None,
                                  geom=self.barGeom,
                                  pos=(.6, 0, .3),
                                  geom_scale=(0.3, 0.25, 0.1),
                                  geom_color=self.color)
         self.expBar = DirectWaitBar(parent=self.bgBar,
                                     guiId='expBar',
                                     pos=(0.0, 0, 0),
                                     relief=DGG.SUNKEN,
                                     frameSize=(-2.0, 2.0, -0.1, 0.1),
                                     borderWidth=(0.01, 0.01),
                                     scale=0.25,
                                     range=self.maxExp,
                                     sortOrder=50,
                                     frameColor=(0.5, 0.5, 0.5, 0.5),
                                     barColor=(0.0, 1.0, 0.0, 0.5),
                                     text=str(self.exp) + '/' +
                                     str(self.maxExp),
                                     text_scale=0.2,
                                     text_fg=(1, 1, 1, 1),
                                     text_align=TextNode.ACenter,
                                     text_pos=(0, -0.05))
         self.expBar['value'] = self.exp
         if self.level == ToontownGlobals.MaxToonLevel:
             self.expBar['range'] = 1
             self.expBar['value'] = 1
             self.expBar['text'] = 'MAX'
         self.levelLabel = OnscreenText(
             parent=self.bgBar,
             text=TTLocalizer.ExpBarLevel + str(self.level + 1),
             pos=(0.0, 0.05),
             scale=0.05,
             font=ToontownGlobals.getBuildingNametagFont(),
             fg=(1, 1, 1, 1))
         self.levelLabel.hide()
         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'),
                       gui.find('**/tt_t_gui_mat_shuffleArrowUp'),
                       gui.find('**/tt_t_gui_mat_shuffleArrowDisabled'))
         self.visToggle = DirectButton(parent=self.bgBar,
                                       relief=None,
                                       geom=arrowImage,
                                       hpr=(0, 0, 0),
                                       pos=(.53, 0, 0),
                                       scale=(0.4, 0.4, 0.4),
                                       command=self.toggleVis)
         if not settings.get('experienceBarMode'):
             self.hide()
 def __init__(self):
     NodePath.__init__(self, 'pbar')
     self.bar = DirectWaitBar(range = 150, frameColor = (1, 1, 1, 1), barColor = (0.286, 0.901, 1, 1), relief = DGG.RAISED,
                            borderWidth = (0.04, 0.04), pos = (0, 0, 0.85), scale = 0.2, hpr = (0, 0, 0),
                            parent = self, frameSize = (-0.85, 0.85, -0.12, 0.12))
     self.hide()
     self.reparentTo(aspect2d)
     self.speed = 0.2
     self.exponent = 0.75
     self.startTime = 0.0
     self.task = None
Пример #25
0
 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.bg = self.bgm.find('**/bg')
     self.logo = loader.loadTexture("phase_3/maps/CogInvasion_Logo.png")
     self.logoNode = hidden.attachNewNode('logoNode')
     self.logoNode.setScale(self.defaultLogoScale)
     self.logoNode.setPos(0, self.defaultLogoZ, 0)
     self.logoImg = OnscreenImage(image=self.logo,
                                  scale=(0.685, 0, 0.325),
                                  parent=self.logoNode)
     self.logoImg.setTransparency(True)
     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=14.5,
                                    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=(89.0 / 255, 95.0 / 255,
                                             98.0 / 255, 1.0),
                                    text_font=CIGlobals.getMinnieFont(),
                                    parent=hidden,
                                    text_shadow=(0, 0, 0, 1))
Пример #26
0
class ControlPointBar(DirectWaitBar):
    def __init__(self, barColor=(255,0,0,1), pos=(1.0,0,0.9)): 
        self.bar = DirectWaitBar(pos = pos, barColor = barColor, text="",
        value=0, range=30, frameSize=(-0.3,0.3,0,0.03), frameColor=(0,0,255,1))

    def setValue(self, value):
        self.bar['value'] = float(value)

    def hide(self):
        self.bar.hide()
    
    def show(self):
        self.bar.show()
Пример #27
0
 def __init__(self, parent):
     super().__init__()
     self.node = parent.attach_new_node("cooldown bar")
     self.wait_bar = DirectWaitBar(
         value=0,
         scale=1,
         parent=self.node,
         frameColor=(0, 0, 0, 0.3),
         barColor=(1, 1, 0, 0.6),
     )
     self.width = 0.026
     self.height = 0.005
     self.accept("aspectRatioChanged", self.aspect_ratio_change_update)
Пример #28
0
    def mostrarInfo(self):

        self.marcador = TextNode("Marcador")
        self.marcador.setText("Puntos: " + str(self.ship.puntos))
        self.marcador.setCardColor(0, 0, 0, 1)
        self.marcador.setCardDecal(True)
        self.marcador.setCardAsMargin(0.4, 0.4, 0.4, 0.4)
        self.marcadorNP = aspect2d.attachNewNode(self.marcador)
        self.marcadorNP.reparentTo(base.a2dTopLeft)
        self.marcadorNP.setPos(0.02, 0, -0.05)
        self.marcadorNP.setScale(0.07)

        self.barraEnergia = DirectWaitBar(text = "Energia", value = 5, 
            range = 5, scale = 0.3, pos = (0, 0, 0.95))
Пример #29
0
 def setAvatar(self, avatar):
     Gag.setAvatar(self, avatar)
     if self.isLocal():
         self.powerBar = DirectWaitBar(range=150,
                                       frameColor=(1, 1, 1, 1),
                                       barColor=(0.286, 0.901, 1, 1),
                                       relief=DGG.RAISED,
                                       borderWidth=(0.04, 0.04),
                                       pos=(0, 0, 0.85),
                                       scale=0.2,
                                       hpr=(0, 0, 0),
                                       parent=aspect2d,
                                       frameSize=(-0.85, 0.85, -0.12, 0.12))
         self.powerBar.hide()
Пример #30
0
class ResourceBar(DirectWaitBar):
    def __init__(self, barColor=(200,180,0,1), pos=(0,0,0.9)): 
        self.bar = DirectWaitBar(pos = pos, barColor = barColor, text="",
        value=70, range=100, frameSize=(-0.3,0.3,0,0.03), frameColor=(0,0,0,1))

    def setValue(self, value):
        self.bar['value'] = float(value)

    def hide(self):
        self.bar.hide()
    
    def show(self):
        self.bar.show()
        
Пример #31
0
 def __init__(self, path, scale=0.5, extraText='', decimal=0, showOverValues=1):
     rootsim.RootSim.__init__(self, path, scale=scale)
     self.extraText = extraText
     self.currentValue = 0.0
     self.maxValue = 0.0
     self.barValue = 0.0
     self.scale = scale
     self.decimal = decimal
     self.showOverValues = showOverValues
     self.myText = ''
     self.textOverValue = None
     self.myBar = DirectWaitBar(text = '0 / 0', scale = scale, 
                                frameColor = globals.colors['guiblue2'],
                                borderWidth = (0.01, 0.01))
     self.barColor = globals.colors['guiblue1']
Пример #32
0
 def load(self):
     if self.isToon:
         self.barGeom = loader.loadModel('phase_3.5/models/gui/exp_bar')
         self.color = self.style.getHeadColor()
         self.bgBar = DirectFrame(relief=None, geom=self.barGeom, pos=(0.0, 0, -.95), geom_scale=(0.3, 0.25, 0.1), geom_color=self.color)
         self.expBar = DirectWaitBar(parent=self.bgBar, guiId='expBar', pos=(0.0, 0, 0), relief=DGG.SUNKEN, frameSize=(-2.0, 2.0, -0.1, 0.1), borderWidth=(0.01, 0.01), scale=0.25, range=self.maxExp, sortOrder=50, frameColor=(0.5, 0.5, 0.5, 0.5), barColor=(0.0, 1.0, 0.0, 0.5), text=str(self.exp)+'/'+str(self.maxExp), text_scale=0.2, text_fg=(1, 1, 1, 1), text_align=TextNode.ACenter, text_pos=(0, -0.05))
         self.expBar['value'] = self.exp
         if self.level == ToontownGlobals.MaxToonLevel:
             self.expBar['range'] = 1
             self.expBar['value'] = 1
             self.expBar['text'] = 'MAX'
         self.levelLabel = OnscreenText(parent = self.bgBar, text = TTLocalizer.ExpBarLevel + str(self.level+1), pos = (0.0, 0.05), scale = 0.05, font=ToontownGlobals.getBuildingNametagFont(), fg = (1, 1, 1, 1))
         self.levelLabel.hide()
         gui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_mainGui')
         if not settings.get('experienceBarMode'):
             self.hide()
Пример #33
0
    def __init__(self, _main):
        self.main = _main
        self.strenght = self.main.enemyStrength
        self.id = id(self)
        self.model = loader.loadModel("Enemy")
        self.model.setP(-90)
        self.model.setH(180)
        self.model.hide()
        cs = CollisionSphere(0, 0, 0, 0.5)
        cnode = CollisionNode('colEnemy' + str(self.id))
        cnode.addSolid(cs)
        self.colNP = self.model.attachNewNode(cnode)
        #self.colNP.show()

        # Game state
        self.health = 100 + (100 * self.strenght)
        self.damageDone = 0.1 + (0.1 * self.strenght)
        self.lastShot = 0.0
        self.attackRate = 10.0


        self.statusHealth = DirectWaitBar(
            text = "",
            value = self.health,
            range = self.health,
            frameSize = (0.12, 0.8, -0.12, 0.0),
            pos = (-0.5, 0, -0.5),
            barColor = (1, 0, 0, 1))
        self.statusHealth.reparentTo(self.model)
        self.statusHealth.setDepthWrite(False)
        self.statusHealth.setBin('fixed', 0)
        self.statusHealth.setBillboardAxis()
Пример #34
0
    def __init__(self):
        ShowBase.__init__(self)

        self.graphics = Graphics()
        self.environment = Environment()
        self.physics = Physics()

        #self.level = testlevels.SimpleBridge()
        #self.level = testlevels.ObstacleWall()
        self.level = testlevels.Staircase()
        self.level.enable_physics(self.physics)

        self.player = Player(self.level)
        self.player.model.setPos(-10, 0, 1)
        self.player.enable_physics(self.physics)

        self.graphics.camera_target = self.player
        self.environment.spotlight_target = self.player.model

        self.health_bar = DirectWaitBar(pos = (0, 0, -0.9), scale = 0.5,
                                        frameColor = Vec4(0.3, 0.3, 0.3, 0.8),
                                        relief = 5, borderWidth = (0.05,0.05))
        self.health_bar.reparentTo(aspect2d)
        self.max_health = self.player.health
        taskMgr.add(self.update_health, "UpdateHealthTask")

        self.accept("escape", self.reset)
Пример #35
0
 def start(self):
     self.fullyChargedSound = base.loadSfx('phase_4/audio/sfx/MG_pairing_match.mp3')
     self.rechargeSound = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_blue_arrow.mp3')
     self.batteryFrame = DirectFrame(parent=base.a2dBottomRight, pos=(-0.2, 0, 0.1), scale=(0.8, 0, 1))
     self.batteryBg = OnscreenImage(image='phase_4/maps/battery_charge_frame.png', parent=self.batteryFrame)
     self.batteryBg.setTransparency(1)
     self.batteryBg.setX(0.03)
     self.batteryBg.setScale(0.17, 0, 0.05)
     self.batteryBar = DirectWaitBar(value=0, range=5, barColor=(1, 1, 1, 1), relief=None, scale=(0.12, 0.0, 0.3), parent=self.batteryFrame)
     self.cameraFocus = loader.loadModel('phase_4/models/minigames/photo_game_viewfinder.bam')
     self.cameraFocus.reparentTo(base.aspect2d)
     self.focusCollHandler = CollisionHandlerEvent()
     self.focusCollHandler.setInPattern('%fn-into')
     self.focusCollHandler.setOutPattern('%fn-out')
     self.focusCollNode = CollisionNode('mouseRay')
     self.focusCollNP = base.camera.attachNewNode(self.focusCollNode)
     self.focusCollNode.setCollideMask(BitMask32(0))
     self.focusCollNode.setFromCollideMask(CIGlobals.WallBitmask)
     self.focusRay = CollisionRay()
     self.focusRay.setFromLens(base.camNode, 0.0, 0.0)
     self.focusCollNode.addSolid(self.focusRay)
     base.cTrav.addCollider(self.focusCollNP, self.focusCollHandler)
     base.localAvatar.walkControls.setWalkSpeed(CIGlobals.ToonForwardSpeed, 0.0, CIGlobals.ToonReverseSpeed, CIGlobals.ToonRotateSpeed)
     FirstPerson.start(self)
     return
 def initFishStaminaBar(self):
     self.legendaryGui = loader.loadModel('models/minigames/pir_m_gam_fsh_legendaryGui')
     self.iconBaseFrame = DirectFrame(relief=None, state=DGG.DISABLED, pos=(0, 0,
                                                                            0), sortOrder=30, image=self.legendaryGui.find('**/pir_t_gui_fsh_fishPortraitFrame'), image_scale=0.18, image_pos=(0,
                                                                                                                                                                                               0,
                                                                                                                                                                                               0))
     self.iconBaseFrame.setTransparency(TransparencyAttrib.MAlpha)
     self.fishUINodePath = NodePath(self.iconBaseFrame)
     self.fishUINodePath.setPos(-0.3, 0.0, 0.83)
     self.fishUINodePath.reparentTo(hidden)
     self.iconCard = loader.loadModel('models/gui/treasure_gui')
     self.iconBaseFrame.iconImage = OnscreenImage(parent=self.iconBaseFrame, image=self.iconCard.find('**/%s*' % CollectionMap.Assets[self.myData['id']]), scale=0.35, hpr=(0,
                                                                                                                                                                            0,
                                                                                                                                                                            0), pos=(0.0,
                                                                                                                                                                                     0,
                                                                                                                                                                                     0.0))
     self.fishNameLabel = TextNode('fishNameLabel')
     name = self.getName().split('_')
     self.fishNameLabel.setText(name[0])
     self.fishNameLabel.setTextColor(1.0, 1.0, 1.0, 1.0)
     self.fishNameLabelNodePath = NodePath(self.fishNameLabel)
     self.fishNameLabelNodePath.setPos(0.3, 0, 0.04)
     self.fishNameLabelNodePath.setScale(0.045)
     self.fishNameLabelNodePath.reparentTo(self.iconBaseFrame)
     self.fishStaminaBar = DirectWaitBar(parent=self.iconBaseFrame, relief=DGG.FLAT, state=DGG.DISABLED, range=100, value=0, sortOrder=20, frameColor=(0,
                                                                                                                                                       0,
                                                                                                                                                       0,
                                                                                                                                                       1.0), pos=(0.07, 0.0, -0.015), hpr=(0,
                                                                                                                                                                                           0,
                                                                                                                                                                                           0), frameSize=(0,
                                                                                                                                                                                                          0.72,
                                                                                                                                                                                                          0,
                                                                                                                                                                                                          0.028))
     self.fishStaminaBar['value'] = self.staminaValue
     self.fishStaminaBar['barColor'] = FishingGlobals.fishingStaminaBarColor[int(self.staminaValue / 100.0 * (len(FishingGlobals.fishingStaminaBarColor) - 1))]
     self.fishStaminaValueLabel = TextNode('fishStaminaValueLabel')
     self.fishStaminaValueLabel.setText(str(self.staminaValue) + '//' + str(self.staminaValue))
     self.fishStaminaValueLabel.setTextColor(1.0, 1.0, 1.0, 1.0)
     self.fishStaminaValueLabelNodePath = NodePath(self.fishStaminaValueLabel)
     self.fishStaminaValueLabelNodePath.setPos(0.66, 0, -0.06)
     self.fishStaminaValueLabelNodePath.setScale(0.045)
     self.fishStaminaValueLabelNodePath.reparentTo(self.iconBaseFrame)
     self.fishStaminaBarFrame = DirectLabel(parent=self.iconBaseFrame, relief=None, state=DGG.DISABLED, frameColor=(1,
                                                                                                                    1,
                                                                                                                    1,
                                                                                                                    0.1), pos=(0.44,
                                                                                                                               0.0,
                                                                                                                               0.0), hpr=(0,
                                                                                                                                          0,
                                                                                                                                          0), sortOrder=25, image=self.legendaryGui.find('**/pir_t_gui_fsh_staminaBarForeground'), image_scale=(1.0,
                                                                                                                                                                                                                                                0.0,
                                                                                                                                                                                                                                                0.05), image_pos=(0.0,
                                                                                                                                                                                                                                                                  0.0,
                                                                                                                                                                                                                                                                  0.0), image_hpr=(0.0,
                                                                                                                                                                                                                                                                                   0.0,
                                                                                                                                                                                                                                                                                   0.0))
     self.fishStaminaBarFrame.setTransparency(TransparencyAttrib.MAlpha)
     self.fishStaminaBarFrame.setDepthTest(True)
     self.fishStaminaBarFrame.setDepthWrite(True)
     return
 def setupPowerBar(self):
     self.powerBar = DirectWaitBar(pos=(0.0, 0, -0.94), relief=DGG.SUNKEN, frameSize=(-2.0,
      2.0,
      -0.2,
      0.2), borderWidth=(0.02, 0.02), scale=0.25, range=100, sortOrder=50, frameColor=(0.5, 0.5, 0.5, 0.5), barColor=(1.0, 0.0, 0.0, 1.0), text='', text_scale=0.26, text_fg=(1, 1, 1, 1), text_align=TextNode.ACenter, text_pos=(0, -0.05))
     self.power = 0
     self.powerBar['value'] = self.power
     self.powerBar.hide()
Пример #38
0
 def __init__(self):
     '''        
     '''
     self.__wait_bar = DirectWaitBar( text = "Carregando...",
                                      value = 0,
                                      pos = (0, 0, -.95),
                                      text_scale = 0.05,
                                      text_pos = (0, 0.025),
                                      frameSize = (-1.3, 1.3, 0, 0.08) )
     
     self.hide()
    def onstage(self):
        self.notify.debug('onstage')
        DistributedMinigame.onstage(self)
        self.maze.onstage()
        self.randomNumGen.shuffle(self.startPosHTable)
        lt = base.localAvatar
        lt.reparentTo(render)
        lt.hideName()
        self.__placeToon(self.localAvId)
        lt.setAnimState('Happy', 1.0)
        lt.setSpeed(0, 0)
        self.camParent = render.attachNewNode('mazeGameCamParent')
        self.camParent.reparentTo(base.localAvatar)
        self.camParent.setPos(0, 0, 0)
        self.camParent.setHpr(render, 0, 0, 0)
        camera.reparentTo(self.camParent)
        camera.setPos(self.camOffset)
        self.__spawnCameraTask()
        self.toonRNGs = []
        for i in xrange(self.numPlayers):
            self.toonRNGs.append(RandomNumGen.RandomNumGen(self.randomNumGen))

        self.treasures = []
        for i in xrange(self.maze.numTreasures):
            self.treasures.append(MazeTreasure.MazeTreasure(self.treasureModel, self.maze.treasurePosList[i], i, self.doId))

        self.__loadSuits()
        for suit in self.suits:
            suit.onstage()

        self.sndTable = {'hitBySuit': [None] * self.numPlayers,
         'falling': [None] * self.numPlayers}
        for i in xrange(self.numPlayers):
            self.sndTable['hitBySuit'][i] = base.loadSfx('phase_4/audio/sfx/MG_Tag_C.ogg')
            self.sndTable['falling'][i] = base.loadSfx('phase_4/audio/sfx/MG_cannon_whizz.ogg')

        self.grabSounds = []
        for i in xrange(5):
            self.grabSounds.append(base.loadSfx('phase_4/audio/sfx/MG_maze_pickup.ogg'))

        self.grabSoundIndex = 0
        for avId in self.avIdList:
            self.toonHitTracks[avId] = Wait(0.1)

        self.scores = [0] * self.numPlayers
        self.goalBar = DirectWaitBar(parent=render2d, relief=DGG.SUNKEN, frameSize=(-0.35,
         0.35,
         -0.15,
         0.15), borderWidth=(0.02, 0.02), scale=0.42, pos=(0.84, 0, 0.5 - 0.28 * self.numPlayers + 0.05), barColor=(0, 0.7, 0, 1))
        self.goalBar.setBin('unsorted', 0)
        self.goalBar.hide()
        self.introTrack = self.getIntroTrack()
        self.introTrack.start()
        return
 def _initPiePowerMeter(self):
     h = PartyGlobals.CogActivityPowerMeterHeight / 2.0
     w = PartyGlobals.CogActivityPowerMeterWidth / 2.0
     self._piePowerMeter = DirectWaitBar(frameSize=(-h,
      h,
      -w,
      w), relief=DGG.GROOVE, frameColor=(0.9, 0.9, 0.9, 1.0), borderWidth=(0.01, 0.01), barColor=PartyGlobals.CogActivityColors[0], pos=PartyGlobals.CogActivityPowerMeterPos, hpr=(0.0, 0.0, -90.0))
     self._piePowerMeter.setBin('fixed', 0)
     self._piePowerTitle = OnscreenText(text=TTLocalizer.PartyCogGuiPowerLabel, pos=PartyGlobals.CogActivityPowerMeterTextPos, scale=0.05, fg=(1.0, 1.0, 1.0, 1.0), align=TextNode.ACenter)
     self._piePowerTitle.setBin('fixed', 0)
     self._piePowerMeter.hide()
     self._piePowerTitle.hide()
Пример #41
0
 def __init__(self):
     self.bgm = loader.loadModel('phase_3/models/gui/progress-background.bam')
     self.bgm.find('**/logo').stash()
     self.bg = self.bgm.find('**/bg')
     self.logo = loader.loadTexture('phase_3/maps/CogInvasion_Logo.png')
     self.logoImg = OnscreenImage(image=self.logo, scale=(0.5, 0, 0.3), pos=(0, 0, 0), parent=hidden)
     self.logoImg.setTransparency(True)
     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)
     self.loading_lbl = DirectLabel(text='', relief=None, scale=0.08, pos=(-1.0725, 0, -0.79), text_align=TextNode.ALeft, sortOrder=100, text_fg=(0.343, 0.343, 0.343, 1.0), text_font=CIGlobals.getMinnieFont(), parent=hidden, text_shadow=(0, 0, 0, 1))
     return
    def load(self):
        self.head = loader.loadModel(self.filePrefix + '-head-zero')

        for anim in AnimList:
            self.animDict[anim] = '%s-%s-%s' % (GenericModel, 'head', anim)

        self.headActor = Actor(self.head, self.animDict)
        self.headActor.hide()
        self.headActor.setBin("fixed", 40)
        self.headActor.setDepthTest(True)
        self.headActor.setDepthWrite(True)

        self.headActor.reparentTo(self)
        self.headActor.setHpr(-90, 0, 270)
        self.headActor.setScale(0.021)
        self.headActor.setPos(-0.25, 0.0, 0.75)
        self.headActor.setPlayRate(2.0, 'turn2Fb')
        self.headActor.loop('Ff_neutral')

        self.eyes = loader.loadModel('phase_10/models/cogHQ/CashBotBossEyes.bam')
        self.eyes.setPosHprScale(4.5, 0, -2.5, 90, 90, 0, 0.4, 0.4, 0.4)
        self.eyes.reparentTo(self.headActor)
        self.eyes.hide()

        self.stars = globalPropPool.getProp('stun')
        self.stars.setPosHprScale(7, 0, 0, 0, 0, -90, 3, 3, 3)
        self.stars.loop('stun')

        self.safe = loader.loadModel('phase_10/models/cogHQ/CBSafe.bam')
        self.safe.reparentTo(self.headActor)
        self.safe.setPosHpr(-1, 0, 0.2, 0, -90, 90)
        self.safe.setBin("fixed", 40)
        self.safe.setDepthTest(True)
        self.safe.setDepthWrite(True)
        self.safe.hide()

        self.headActor.show()

        self.healthBar = DirectWaitBar(parent=self, pos=(0, 0, 0.85), relief=DGG.SUNKEN,
                                       frameSize=(-1.75, 1.75, -0.3, 0.3),
                                       borderWidth=(0.02, 0.02), scale=0.1, range=1, sortOrder=50,
                                       frameColor=(0.5, 0.5, 0.5, 0.5), barColor=(0.75, 0.75, 1.0, 0.8), text='',
                                       text_scale=0.35, text_fg=(1, 1, 1, 1), text_align=TextNode.ACenter,
                                       text_pos=(0, -0.05), text_font=getSuitFont())

        self.updateHealthBar(self.maxHp)
Пример #43
0
 def enterFrozen(self):
     self.loadIceCube()
     base.cr.playGame.getPlace().fsm.request('stop', [0])
     base.localAvatar.stop()
     base.playSfx(choice(self.frozenSfxArray))
     self.iccsIval = LerpColorScaleInterval(self.iceCube, duration=0.5, colorScale=VBase4(0.76, 0.76, 1.0, 1.0), startColorScale=self.iceCube.getColorScale(), blendType='easeInOut')
     self.iccsIval.start()
     props = WindowProperties()
     props.setCursorHidden(True)
     base.win.requestProperties(props)
     self.frame = DirectFrame(pos=(0, 0, 0.7))
     self.powerBar = DirectWaitBar(frameColor=(1, 1, 1, 1), range=100, value=0, scale=(0.4, 0.5, 0.25), parent=self.frame, barColor=(0.55, 0.7, 1.0, 1.0))
     self.label = OnscreenText(text='SHAKE MOUSE', shadow=(0, 0, 0, 1), fg=(0.55, 0.7, 1.0, 1.0), pos=(0, -0.1, 0), parent=self.frame)
     taskMgr.add(self.__watchMouseMovement, 'BRWater-watchMouseMovement')
     taskMgr.add(self.__lowerPowerBar, 'BRWater-lowerPowerBar')
     mw = base.mouseWatcherNode
     if mw.hasMouse():
         self.lastMouseX = mw.getMouseX()
    def __init__(self, description, needed, icon):
        NodePath.__init__(self, 'objective-%s' % id(self))

        self.needed = needed
        self.visible = False

        self.fadeInTrack = None
        self.fadeOutTrack = None

        gui = loader.loadModel('phase_5/models/cogdominium/tt_m_gui_csa_flyThru')
        self.background = gui.find('**/*background').copyTo(self)
        self.background.setScale(2.5)
        gui.removeNode()

        self.icon = icon.copyTo(self.background)
        self.icon.setScale(0.08)
        self.icon.setPos(-0.167, 0, -0.002)

        text = TextNode('challenge')
        text.setText('Challenge')
        text.setFont(ToontownGlobals.getSignFont())
        text.setTextColor(0.95, 0.95, 0, 1)
        self.objText = self.background.attachNewNode(text)
        self.objText.setScale(0.03)
        self.objText.setPos(-0.04, 0.0, 0.02)

        text = TextNode('description')
        text.setText(description)
        text.setFont(ToontownGlobals.getSignFont())
        text.setTextColor(0.95, 0.95, 0, 1)
        text.setAlign(TextNode.ACenter)
        self.objText = self.background.attachNewNode(text)
        self.objText.setScale(0.015)
        self.objText.setPos(0.048, 0.0, -0.009)

        self.progressBar = DirectWaitBar(guiId='ChallengeProgressBar', parent=self.background, frameSize=(-0.11, 0.11, -0.007, 0.007), pos=(0.048, 0, -0.0338), text='')
        self.progressBar['range'] = needed

        self.progressText = DirectLabel(guiId='ChallengeProgressText', parent=self.progressBar, relief=None, pos=(0, 0, -0.0048), text='', textMayChange=1, text_scale=0.014, text_fg=(0.03, 0.83, 0, 1), text_align=TextNode.ACenter, text_font=ToontownGlobals.getSignFont())

        self.updateProgress(0)

        self.reparentTo(base.a2dBottomLeft)
        self.stash()
 def setupPowerBar(self):
     self.powerBar = DirectWaitBar(
         pos=(0.0, 0, -0.93999999999999995),
         relief=DGG.SUNKEN,
         frameSize=(-2.0, 2.0, -0.20000000000000001, 0.20000000000000001),
         borderWidth=(0.02, 0.02),
         scale=0.25,
         range=1,
         sortOrder=50,
         frameColor=(0.5, 0.5, 0.5, 0.5),
         barColor=(0.75, 0.75, 1.0, 0.80000000000000004),
         text="",
         text_scale=0.26000000000000001,
         text_fg=(1, 1, 1, 1),
         text_align=TextNode.ACenter,
         text_pos=(0, -0.050000000000000003),
     )
     self.power = 0
     self.powerBar["value"] = self.power
     self.powerBar.hide()
Пример #46
0
class Bar(DirectObject.DirectObject):
	def __init__( self):
		self.bar = DirectWaitBar(text = "Loading...", value = 0, pos = (0,.4,.4))
		self.bar.hide()

	def incBar(self, arg):
		self.bar['value'] +=	arg
		#text = str(bar['value'])
		#textObject.setText(text)

	def show(self):
		self.bar.show()

	def hide(self):
		self.bar.hide()
Пример #47
0
 def makeGui(self):
     self.destroyGui()
     self.guiFrame = DirectFrame(parent=base.a2dBottomRight, pos=(-0.55, 0, 0.15))
     self.guiBg = OnscreenImage(image="phase_4/maps/turret_gui_bg.png", scale=(0.15, 0, 0.075), parent=self.guiFrame)
     self.guiBg.setTransparency(True)
     self.guiLabel = DirectLabel(
         text="Turret",
         text_fg=(1, 0, 0, 1),
         relief=None,
         text_scale=0.05,
         text_font=loader.loadFont("phase_3/models/fonts/ImpressBT.ttf"),
         pos=(0, 0, 0.025),
         parent=self.guiFrame,
     )
     self.guiBar = DirectWaitBar(
         range=self.myTurret.getMaxHealth(),
         value=self.myTurret.getHealth(),
         scale=0.125,
         parent=self.guiFrame,
         pos=(0, 0, -0.01),
     )
     return
Пример #48
0
    def __init__(self):
        self.defaultFont = loader.loadFont("gui/fonts/UbuntuBold.bam")

        # a fill panel so the player doesn't see how everything
        # gets loaded in the background
        self.frameMain = DirectFrame(
            # size of the frame
            frameSize = (base.a2dLeft, base.a2dRight,
                         base.a2dTop, base.a2dBottom),
            # position of the frame
            #pos = (0, 0, 0),
            # tramsparent bg color
            frameColor = (0.05, 0.1, 0.25, 1))

        # the text Loading... on top
        self.lblLoading = DirectLabel(
            scale = 0.25,
            pos = (0, 0, 0.5),
            frameColor = (0, 0, 0, 0),
            text = "Loading...",
            text_align = TextNode.ACenter,
            text_fg = (1,1,1,1),
            text_font = self.defaultFont)
        self.lblLoading.reparentTo(self.frameMain)

        # the waitbar on the bottom
        self.wbLoading = DirectWaitBar(
            text = "0%",
            text_fg = (1,1,1,1),
            text_font = self.defaultFont,
            value = 100,
            pos = (0, 0, -0.5),
            barColor = (0, 0, 1, 1))
        self.wbLoading.reparentTo(self.frameMain)

        self.setText()
        self.hide()
Пример #49
0
class ControlPointBar(DirectWaitBar):
    def __init__(self, barColor=(255,0,0,1), pos=(1.0,0,0.9)): 
        self.bar = DirectWaitBar(pos = pos, barColor = barColor, text="",
        value=70, range=100, frameSize=(-0.3,0.3,0,0.03), frameColor=(0,0,255,1))
        

    def setValue(self, value):
        self.bar['value'] = float(value)
        self.setPos((0,0,0))

    def hide(self):
        self.bar.hide()
    
    # to make inherited setPos available for this object
    def show(self):
        self.bar.show()
    
    # to make inherited setPos available for this object
    def setPos(self, pos):
        self.bar.setPos(pos)
class DistributedBanquetTable(DistributedObject.DistributedObject, FSM.FSM, BanquetTableBase.BanquetTableBase):
    notify = DirectNotifyGlobal.directNotify.newCategory("DistributedBanquetTable")
    rotationsPerSeatIndex = [90, 90, 0, 0, -90, -90, 180, 180]
    pitcherMinH = -360
    pitcherMaxH = 360
    rotateSpeed = 30
    waterPowerSpeed = base.config.GetDouble("water-power-speed", 15)
    waterPowerExponent = base.config.GetDouble("water-power-exponent", 0.75)
    useNewAnimations = True
    TugOfWarControls = False
    OnlyUpArrow = True
    if OnlyUpArrow:
        BASELINE_KEY_RATE = 3
    else:
        BASELINE_KEY_RATE = 6
    UPDATE_KEY_PRESS_RATE_TASK = "BanquetTableUpdateKeyPressRateTask"
    YELLOW_POWER_THRESHOLD = 0.75
    RED_POWER_THRESHOLD = 0.96999999999999997

    def __init__(self, cr):
        DistributedObject.DistributedObject.__init__(self, cr)
        FSM.FSM.__init__(self, "DistributedBanquetTable")
        self.boss = None
        self.index = -1
        self.diners = {}
        self.dinerStatus = {}
        self.serviceLocs = {}
        self.chairLocators = {}
        self.sitLocators = {}
        self.activeIntervals = {}
        self.dinerStatusIndicators = {}
        self.preparedForPhaseFour = False
        self.avId = 0
        self.toon = None
        self.pitcherSmoother = SmoothMover()
        self.pitcherSmoother.setSmoothMode(SmoothMover.SMOn)
        self.smoothStarted = 0
        self._DistributedBanquetTable__broadcastPeriod = 0.20000000000000001
        self.changeSeq = 0
        self.lastChangeSeq = 0
        self.pitcherAdviceLabel = None
        self.fireLength = 250
        self.fireTrack = None
        self.hitObject = None
        self.setupPowerBar()
        self.aimStart = None
        self.toonPitcherPosition = Point3(0, -2, 0)
        self.allowLocalRequestControl = True
        self.fadeTrack = None
        self.grabTrack = None
        self.gotHitByBoss = False
        self.keyTTL = []
        self.keyRate = 0
        self.buttons = [0, 1]
        self.lastPowerFired = 0
        self.moveSound = None
        self.releaseTrack = None

    def disable(self):
        DistributedObject.DistributedObject.disable(self)
        taskMgr.remove(self.triggerName)
        taskMgr.remove(self.smoothName)
        taskMgr.remove(self.watchControlsName)
        taskMgr.remove(self.pitcherAdviceName)
        taskMgr.remove(self.posHprBroadcastName)
        taskMgr.remove(self.waterPowerTaskName)
        if self.releaseTrack:
            self.releaseTrack.finish()
            self.releaseTrack = None

        if self.fireTrack:
            self.fireTrack.finish()
            self.fireTrack = None

        self.cleanupIntervals()

    def delete(self):
        DistributedObject.DistributedObject.delete(self)
        self.boss = None
        self.ignoreAll()
        for indicator in self.dinerStatusIndicators.values():
            indicator.delete()

        self.dinerStatusIndicators = {}
        for diner in self.diners.values():
            diner.delete()

        self.diners = {}
        self.powerBar.destroy()
        self.powerBar = None
        self.pitcherMoveSfx.stop()

    def announceGenerate(self):
        DistributedObject.DistributedObject.announceGenerate(self)
        self.loadAssets()
        self.smoothName = self.uniqueName("pitcherSmooth")
        self.pitcherAdviceName = self.uniqueName("pitcherAdvice")
        self.posHprBroadcastName = self.uniqueName("pitcherBroadcast")
        self.waterPowerTaskName = self.uniqueName("updateWaterPower")
        self.triggerName = self.uniqueName("trigger")
        self.watchControlsName = self.uniqueName("watchControls")

    def setBossCogId(self, bossCogId):
        self.bossCogId = bossCogId
        self.boss = base.cr.doId2do[bossCogId]
        self.boss.setTable(self, self.index)

    def setIndex(self, index):
        self.index = index

    def setState(self, state, avId, extraInfo):
        self.gotHitByBoss = extraInfo
        if state == "F":
            self.demand("Off")
        elif state == "N":
            self.demand("On")
        elif state == "I":
            self.demand("Inactive")
        elif state == "R":
            self.demand("Free")
        elif state == "C":
            self.demand("Controlled", avId)
        elif state == "L":
            self.demand("Flat", avId)
        else:
            self.notify.error("Invalid state from AI: %s" % state)

    def setNumDiners(self, numDiners):
        self.numDiners = numDiners

    def setDinerInfo(self, hungryDurations, eatingDurations, dinerLevels):
        self.dinerInfo = {}
        for i in xrange(len(hungryDurations)):
            hungryDur = hungryDurations[i]
            eatingDur = eatingDurations[i]
            dinerLevel = dinerLevels[i]
            self.dinerInfo[i] = (hungryDur, eatingDur, dinerLevel)

    def loadAssets(self):
        self.tableGroup = loader.loadModel("phase_12/models/bossbotHQ/BanquetTableChairs")
        tableLocator = self.boss.geom.find("**/TableLocator_%d" % (self.index + 1))
        if tableLocator.isEmpty():
            self.tableGroup.reparentTo(render)
            self.tableGroup.setPos(0, 75, 0)
        else:
            self.tableGroup.reparentTo(tableLocator)
        self.tableGeom = self.tableGroup.find("**/Geometry")
        self.setupDiners()
        self.setupChairCols()
        self.squirtSfx = loader.loadSfx("phase_4/audio/sfx/AA_squirt_seltzer_miss.mp3")
        self.hitBossSfx = loader.loadSfx("phase_5/audio/sfx/SA_watercooler_spray_only.mp3")
        self.hitBossSoundInterval = SoundInterval(self.hitBossSfx, node=self.boss, volume=1.0)
        self.serveFoodSfx = loader.loadSfx("phase_4/audio/sfx/MG_sfx_travel_game_bell_for_trolley.mp3")
        self.pitcherMoveSfx = base.loadSfx("phase_4/audio/sfx/MG_cannon_adjust.mp3")

    def setupDiners(self):
        for i in xrange(self.numDiners):
            newDiner = self.createDiner(i)
            self.diners[i] = newDiner
            self.dinerStatus[i] = self.HUNGRY

    def createDiner(self, i):
        diner = Suit.Suit()
        diner.dna = SuitDNA.SuitDNA()
        level = self.dinerInfo[i][2]
        level -= 4
        diner.dna.newSuitRandom(level=level, dept="c")
        diner.setDNA(diner.dna)
        if self.useNewAnimations:
            diner.loop("sit", fromFrame=i)
        else:
            diner.pose("landing", 0)
        locator = self.tableGroup.find("**/chair_%d" % (i + 1))
        locatorScale = locator.getNetTransform().getScale()[0]
        correctHeadingNp = locator.attachNewNode("correctHeading")
        self.chairLocators[i] = correctHeadingNp
        heading = self.rotationsPerSeatIndex[i]
        correctHeadingNp.setH(heading)
        sitLocator = correctHeadingNp.attachNewNode("sitLocator")
        base.sitLocator = sitLocator
        pos = correctHeadingNp.getPos(render)
        if SuitDNA.getSuitBodyType(diner.dna.name) == "c":
            sitLocator.setPos(0.5, 3.6499999999999999, -3.75)
        else:
            sitLocator.setZ(-2.3999999999999999)
            sitLocator.setY(2.5)
            sitLocator.setX(0.5)
        self.sitLocators[i] = sitLocator
        diner.setScale(1.0 / locatorScale)
        diner.reparentTo(sitLocator)
        newLoc = NodePath("serviceLoc-%d-%d" % (self.index, i))
        newLoc.reparentTo(correctHeadingNp)
        newLoc.setPos(0, 3.0, 1)
        self.serviceLocs[i] = newLoc
        base.serviceLoc = newLoc
        head = diner.find("**/joint_head")
        newIndicator = DinerStatusIndicator.DinerStatusIndicator(parent=head, pos=Point3(0, 0, 3.5), scale=5.0)
        newIndicator.wrtReparentTo(diner)
        self.dinerStatusIndicators[i] = newIndicator
        return diner

    def setupChairCols(self):
        for i in xrange(self.numDiners):
            chairCol = self.tableGroup.find("**/collision_chair_%d" % (i + 1))
            colName = "ChairCol-%d-%d" % (self.index, i)
            chairCol.setTag("chairIndex", str(i))
            chairCol.setName(colName)
            chairCol.setCollideMask(ToontownGlobals.WallBitmask)
            self.accept("enter" + colName, self.touchedChair)

    def touchedChair(self, colEntry):
        chairIndex = int(colEntry.getIntoNodePath().getTag("chairIndex"))
        if chairIndex in self.dinerStatus:
            status = self.dinerStatus[chairIndex]
            if status in (self.HUNGRY, self.ANGRY):
                self.boss.localToonTouchedChair(self.index, chairIndex)

    def serveFood(self, food, chairIndex):
        self.removeFoodModel(chairIndex)
        serviceLoc = self.serviceLocs.get(chairIndex)
        if not food or food.isEmpty():
            foodModel = loader.loadModel("phase_12/models/bossbotHQ/canoffood")
            foodModel.setScale(ToontownGlobals.BossbotFoodModelScale)
            foodModel.reparentTo(serviceLoc)
        else:
            food.wrtReparentTo(serviceLoc)
            tray = food.find("**/tray")
            if not tray.isEmpty():
                tray.hide()

            ivalDuration = 1.5
            foodMoveIval = Parallel(
                SoundInterval(self.serveFoodSfx, node=food),
                ProjectileInterval(
                    food, duration=ivalDuration, startPos=food.getPos(serviceLoc), endPos=serviceLoc.getPos(serviceLoc)
                ),
                LerpHprInterval(food, ivalDuration, Point3(0, -360, 0)),
            )
            intervalName = "serveFood-%d-%d" % (self.index, chairIndex)
            foodMoveIval.start()
            self.activeIntervals[intervalName] = foodMoveIval

    def setDinerStatus(self, chairIndex, status):
        if chairIndex in self.dinerStatus:
            oldStatus = self.dinerStatus[chairIndex]
            self.dinerStatus[chairIndex] = status
            if oldStatus != status:
                if status == self.EATING:
                    self.changeDinerToEating(chairIndex)
                elif status == self.HUNGRY:
                    self.changeDinerToHungry(chairIndex)
                elif status == self.ANGRY:
                    self.changeDinerToAngry(chairIndex)
                elif status == self.DEAD:
                    self.changeDinerToDead(chairIndex)
                elif status == self.HIDDEN:
                    self.changeDinerToHidden(chairIndex)

    def removeFoodModel(self, chairIndex):
        serviceLoc = self.serviceLocs.get(chairIndex)
        if serviceLoc:
            for i in xrange(serviceLoc.getNumChildren()):
                serviceLoc.getChild(0).removeNode()

    def changeDinerToEating(self, chairIndex):
        indicator = self.dinerStatusIndicators.get(chairIndex)
        eatingDuration = self.dinerInfo[chairIndex][1]
        if indicator:
            indicator.request("Eating", eatingDuration)

        diner = self.diners[chairIndex]
        intervalName = "eating-%d-%d" % (self.index, chairIndex)
        eatInTime = 32.0 / 24.0
        eatOutTime = 21.0 / 24.0
        eatLoopTime = 19 / 24.0
        rightHand = diner.getRightHand()
        waitTime = 5
        loopDuration = eatingDuration - eatInTime - eatOutTime - waitTime
        serviceLoc = self.serviceLocs[chairIndex]

        def foodAttach(self=self, diner=diner):
            foodModel = self.serviceLocs[chairIndex].getChild(0)
            (foodModel.reparentTo(diner.getRightHand()),)
            (foodModel.setHpr(Point3(0, -94, 0)),)
            (foodModel.setPos(Point3(-0.14999999999999999, -0.69999999999999996, -0.40000000000000002)),)
            scaleAdj = 1
            if SuitDNA.getSuitBodyType(diner.dna.name) == "c":
                scaleAdj = 0.59999999999999998
                (foodModel.setPos(Point3(0.10000000000000001, -0.25, -0.31)),)
            else:
                scaleAdj = 0.80000000000000004
                (foodModel.setPos(Point3(-0.25, -0.84999999999999998, -0.34000000000000002)),)
            oldScale = foodModel.getScale()
            newScale = oldScale * scaleAdj
            foodModel.setScale(newScale)

        def foodDetach(self=self, diner=diner):
            foodModel = diner.getRightHand().getChild(0)
            (foodModel.reparentTo(serviceLoc),)
            (foodModel.setPosHpr(0, 0, 0, 0, 0, 0),)
            scaleAdj = 1
            if SuitDNA.getSuitBodyType(diner.dna.name) == "c":
                scaleAdj = 0.59999999999999998
            else:
                scakeAdj = 0.80000000000000004
            oldScale = foodModel.getScale()
            newScale = oldScale / scaleAdj
            foodModel.setScale(newScale)

        eatIval = Sequence(
            ActorInterval(diner, "sit", duration=waitTime),
            ActorInterval(diner, "sit-eat-in", startFrame=0, endFrame=6),
            Func(foodAttach),
            ActorInterval(diner, "sit-eat-in", startFrame=6, endFrame=32),
            ActorInterval(diner, "sit-eat-loop", duration=loopDuration, loop=1),
            ActorInterval(diner, "sit-eat-out", startFrame=0, endFrame=12),
            Func(foodDetach),
            ActorInterval(diner, "sit-eat-out", startFrame=12, endFrame=21),
        )
        eatIval.start()
        self.activeIntervals[intervalName] = eatIval

    def changeDinerToHungry(self, chairIndex):
        intervalName = "eating-%d-%d" % (self.index, chairIndex)
        if intervalName in self.activeIntervals:
            self.activeIntervals[intervalName].finish()

        self.removeFoodModel(chairIndex)
        indicator = self.dinerStatusIndicators.get(chairIndex)
        if indicator:
            indicator.request("Hungry", self.dinerInfo[chairIndex][0])

        diner = self.diners[chairIndex]
        if random.choice([0, 1]):
            diner.loop("sit-hungry-left")
        else:
            diner.loop("sit-hungry-right")

    def changeDinerToAngry(self, chairIndex):
        self.removeFoodModel(chairIndex)
        indicator = self.dinerStatusIndicators.get(chairIndex)
        if indicator:
            indicator.request("Angry")

        diner = self.diners[chairIndex]
        diner.loop("sit-angry")

    def changeDinerToDead(self, chairIndex):
        def removeDeathSuit(suit, deathSuit):
            if not deathSuit.isEmpty():
                deathSuit.detachNode()
                suit.cleanupLoseActor()

        self.removeFoodModel(chairIndex)
        indicator = self.dinerStatusIndicators.get(chairIndex)
        if indicator:
            indicator.request("Dead")

        diner = self.diners[chairIndex]
        deathSuit = diner
        locator = self.tableGroup.find("**/chair_%d" % (chairIndex + 1))
        deathSuit = diner.getLoseActor()
        ival = Sequence(
            Func(self.notify.debug, "before actorinterval sit-lose"),
            ActorInterval(diner, "sit-lose"),
            Func(self.notify.debug, "before deathSuit.setHpr"),
            Func(deathSuit.setHpr, diner.getHpr()),
            Func(self.notify.debug, "before diner.hide"),
            Func(diner.hide),
            Func(self.notify.debug, "before deathSuit.reparentTo"),
            Func(deathSuit.reparentTo, self.chairLocators[chairIndex]),
            Func(self.notify.debug, "befor ActorInterval lose"),
            ActorInterval(deathSuit, "lose", duration=MovieUtil.SUIT_LOSE_DURATION),
            Func(self.notify.debug, "before remove deathsuit"),
            Func(removeDeathSuit, diner, deathSuit, name="remove-death-suit-%d-%d" % (chairIndex, self.index)),
            Func(self.notify.debug, "diner.stash"),
            Func(diner.stash),
        )
        spinningSound = base.loadSfx("phase_3.5/audio/sfx/Cog_Death.mp3")
        deathSound = base.loadSfx("phase_3.5/audio/sfx/ENC_cogfall_apart.mp3")
        deathSoundTrack = Sequence(
            Wait(0.80000000000000004),
            SoundInterval(spinningSound, duration=1.2, startTime=1.5, volume=0.20000000000000001, node=deathSuit),
            SoundInterval(
                spinningSound, duration=3.0, startTime=0.59999999999999998, volume=0.80000000000000004, node=deathSuit
            ),
            SoundInterval(deathSound, volume=0.32000000000000001, node=deathSuit),
        )
        intervalName = "dinerDie-%d-%d" % (self.index, chairIndex)
        deathIval = Parallel(ival, deathSoundTrack)
        deathIval.start()
        self.activeIntervals[intervalName] = deathIval

    def changeDinerToHidden(self, chairIndex):
        self.removeFoodModel(chairIndex)
        indicator = self.dinerStatusIndicators.get(chairIndex)
        if indicator:
            indicator.request("Inactive")

        diner = self.diners[chairIndex]
        diner.hide()

    def setAllDinersToSitNeutral(self):
        startFrame = 0
        for diner in self.diners.values():
            if not diner.isHidden():
                diner.loop("sit", fromFrame=startFrame)
                startFrame += 1
                continue

    def cleanupIntervals(self):
        for interval in self.activeIntervals.values():
            interval.finish()

        self.activeIntervals = {}

    def clearInterval(self, name, finish=1):
        if self.activeIntervals.has_key(name):
            ival = self.activeIntervals[name]
            if finish:
                ival.finish()
            else:
                ival.pause()
            if self.activeIntervals.has_key(name):
                del self.activeIntervals[name]

        else:
            self.notify.debug("interval: %s already cleared" % name)

    def finishInterval(self, name):
        if self.activeIntervals.has_key(name):
            interval = self.activeIntervals[name]
            interval.finish()

    def getNotDeadInfo(self):
        notDeadList = []
        for i in xrange(self.numDiners):
            if self.dinerStatus[i] != self.DEAD:
                notDeadList.append((self.index, i, 12))
                continue

        return notDeadList

    def enterOn(self):
        pass

    def exitOn(self):
        pass

    def enterInactive(self):
        for chairIndex in xrange(self.numDiners):
            indicator = self.dinerStatusIndicators.get(chairIndex)
            if indicator:
                indicator.request("Inactive")

            self.removeFoodModel(chairIndex)

    def exitInactive(self):
        pass

    def enterFree(self):
        self.resetPowerBar()
        if self.fadeTrack:
            self.fadeTrack.finish()
            self.fadeTrack = None

        self.prepareForPhaseFour()
        if self.avId == localAvatar.doId:
            self.tableGroup.setAlphaScale(0.29999999999999999)
            self.tableGroup.setTransparency(1)
            taskMgr.doMethodLater(5, self._DistributedBanquetTable__allowDetect, self.triggerName)
            self.fadeTrack = Sequence(
                Func(self.tableGroup.setTransparency, 1),
                self.tableGroup.colorScaleInterval(0.20000000000000001, VBase4(1, 1, 1, 0.29999999999999999)),
            )
            self.fadeTrack.start()
            self.allowLocalRequestControl = False
        else:
            self.allowLocalRequestControl = True
        self.avId = 0

    def exitFree(self):
        pass

    def touchedTable(self, colEntry):
        tableIndex = int(colEntry.getIntoNodePath().getTag("tableIndex"))
        if self.state == "Free" and self.avId == 0 and self.allowLocalRequestControl:
            self.d_requestControl()

    def prepareForPhaseFour(self):
        if not self.preparedForPhaseFour:
            for i in xrange(8):
                chair = self.tableGroup.find("**/chair_%d" % (i + 1))
                if not chair.isEmpty():
                    chair.hide()

                colChairs = self.tableGroup.findAllMatches("**/ChairCol*")
                for i in xrange(colChairs.getNumPaths()):
                    col = colChairs.getPath(i)
                    col.stash()

                colChairs = self.tableGroup.findAllMatches("**/collision_chair*")
                for i in xrange(colChairs.getNumPaths()):
                    col = colChairs.getPath(i)
                    col.stash()

            tableCol = self.tableGroup.find("**/collision_table")
            colName = "TableCol-%d" % self.index
            tableCol.setTag("tableIndex", str(self.index))
            tableCol.setName(colName)
            tableCol.setCollideMask(ToontownGlobals.WallBitmask | ToontownGlobals.BanquetTableBitmask)
            self.accept("enter" + colName, self.touchedTable)
            self.preparedForPhaseFour = True
            self.waterPitcherModel = loader.loadModel("phase_12/models/bossbotHQ/tt_m_ara_bhq_seltzerBottle")
            lampNode = self.tableGroup.find("**/lamp_med_5")
            pos = lampNode.getPos(self.tableGroup)
            lampNode.hide()
            bottleLocator = self.tableGroup.find("**/bottle_locator")
            pos = bottleLocator.getPos(self.tableGroup)
            self.waterPitcherNode = self.tableGroup.attachNewNode("pitcherNode")
            self.waterPitcherNode.setPos(pos)
            self.waterPitcherModel.reparentTo(self.waterPitcherNode)
            self.waterPitcherModel.ls()
            self.nozzle = self.waterPitcherModel.find("**/nozzle_tip")
            self.handLocator = self.waterPitcherModel.find("**/hand_locator")
            self.handPos = self.handLocator.getPos()

    def d_requestControl(self):
        self.sendUpdate("requestControl")

    def d_requestFree(self, gotHitByBoss):
        self.sendUpdate("requestFree", [gotHitByBoss])

    def enterControlled(self, avId):
        self.prepareForPhaseFour()
        self.avId = avId
        toon = base.cr.doId2do.get(avId)
        if not toon:
            return None

        self.toon = toon
        self.grabTrack = self.makeToonGrabInterval(toon)
        self.notify.debug("grabTrack=%s" % self.grabTrack)
        self.pitcherCamPos = Point3(0, -50, 40)
        self.pitcherCamHpr = Point3(0, -21, 0)
        if avId == localAvatar.doId:
            self.boss.toMovieMode()
            self._DistributedBanquetTable__enableControlInterface()
            self.startPosHprBroadcast()
            self.grabTrack = Sequence(
                self.grabTrack,
                Func(camera.wrtReparentTo, localAvatar),
                LerpPosHprInterval(camera, 1, self.pitcherCamPos, self.pitcherCamHpr),
                Func(self.boss.toCraneMode),
            )
            if self.TugOfWarControls:
                self._DistributedBanquetTable__spawnUpdateKeyPressRateTask()

            self.accept("exitCrane", self.gotBossZapped)
        else:
            self.startSmooth()
            toon.stopSmooth()
        self.grabTrack.start()

    def exitControlled(self):
        self.ignore("exitCrane")
        if self.grabTrack:
            self.grabTrack.finish()
            self.grabTrack = None

        nextState = self.getCurrentOrNextState()
        self.notify.debug("nextState=%s" % nextState)
        if nextState == "Flat":
            place = base.cr.playGame.getPlace()
            self.notify.debug("%s" % place.fsm)
            if self.avId == localAvatar.doId:
                self._DistributedBanquetTable__disableControlInterface()

        elif self.toon and not self.toon.isDisabled():
            self.toon.loop("neutral")
            self.toon.startSmooth()

        self.releaseTrack = self.makeToonReleaseInterval(self.toon)
        self.stopPosHprBroadcast()
        self.stopSmooth()
        if self.avId == localAvatar.doId:
            localAvatar.wrtReparentTo(render)
            self._DistributedBanquetTable__disableControlInterface()
            camera.reparentTo(base.localAvatar)
            camera.setPos(base.localAvatar.cameraPositions[0][0])
            camera.setHpr(0, 0, 0)
            self.goToFinalBattle()
            self.safeBossToFinalBattleMode()
        else:
            toon = base.cr.doId2do.get(self.avId)
            if toon:
                toon.wrtReparentTo(render)

        self.releaseTrack.start()

    def safeBossToFinalBattleMode(self):
        if self.boss:
            self.boss.toFinalBattleMode()

    def goToFinalBattle(self):
        if self.cr:
            place = self.cr.playGame.getPlace()
            if place and hasattr(place, "fsm"):
                if place.fsm.getCurrentState().getName() == "crane":
                    place.setState("finalBattle")

    def makeToonGrabInterval(self, toon):
        toon.pose("leverNeutral", 0)
        toon.update()
        rightHandPos = toon.rightHand.getPos(toon)
        self.toonPitcherPosition = Point3(self.handPos[0] - rightHandPos[0], self.handPos[1] - rightHandPos[1], 0)
        destZScale = rightHandPos[2] / self.handPos[2]
        grabIval = Sequence(
            Func(toon.wrtReparentTo, self.waterPitcherNode),
            Func(toon.loop, "neutral"),
            Parallel(
                ActorInterval(toon, "jump"),
                Sequence(
                    Wait(0.42999999999999999),
                    Parallel(
                        ProjectileInterval(
                            toon,
                            duration=0.90000000000000002,
                            startPos=toon.getPos(self.waterPitcherNode),
                            endPos=self.toonPitcherPosition,
                        ),
                        LerpHprInterval(toon, 0.90000000000000002, Point3(0, 0, 0)),
                        LerpScaleInterval(self.waterPitcherModel, 0.90000000000000002, Point3(1, 1, destZScale)),
                    ),
                ),
            ),
            Func(toon.setPos, self.toonPitcherPosition),
            Func(toon.loop, "leverNeutral"),
        )
        return grabIval

    def makeToonReleaseInterval(self, toon):
        temp1 = self.waterPitcherNode.attachNewNode("temp1")
        temp1.setPos(self.toonPitcherPosition)
        temp2 = self.waterPitcherNode.attachNewNode("temp2")
        temp2.setPos(0, -10, -self.waterPitcherNode.getZ())
        startPos = temp1.getPos(render)
        endPos = temp2.getPos(render)
        temp1.removeNode()
        temp2.removeNode()

        def getSlideToPos(toon=toon):
            return render.getRelativePoint(toon, Point3(0, -10, 0))

        if self.gotHitByBoss:
            self.notify.debug("creating zap interval instead")
            grabIval = Sequence(
                Func(toon.loop, "neutral"),
                Func(toon.wrtReparentTo, render),
                Parallel(ActorInterval(toon, "slip-backward"), toon.posInterval(0.5, getSlideToPos, fluid=1)),
            )
        else:
            grabIval = Sequence(
                Func(toon.loop, "neutral"),
                Func(toon.wrtReparentTo, render),
                Parallel(
                    ActorInterval(toon, "jump"),
                    Sequence(
                        Wait(0.42999999999999999),
                        ProjectileInterval(toon, duration=0.90000000000000002, startPos=startPos, endPos=endPos),
                    ),
                ),
            )
        return grabIval

    def b_clearSmoothing(self):
        self.d_clearSmoothing()
        self.clearSmoothing()

    def d_clearSmoothing(self):
        self.sendUpdate("clearSmoothing", [0])

    def clearSmoothing(self, bogus=None):
        self.pitcherSmoother.clearPositions(1)

    def doSmoothTask(self, task):
        self.pitcherSmoother.computeAndApplySmoothHpr(self.waterPitcherNode)
        return Task.cont

    def startSmooth(self):
        if not self.smoothStarted:
            taskName = self.smoothName
            taskMgr.remove(taskName)
            self.reloadPosition()
            taskMgr.add(self.doSmoothTask, taskName)
            self.smoothStarted = 1

    def stopSmooth(self):
        if self.smoothStarted:
            taskName = self.smoothName
            taskMgr.remove(taskName)
            self.forceToTruePosition()
            self.smoothStarted = 0

    def _DistributedBanquetTable__enableControlInterface(self):
        gui = loader.loadModel("phase_3.5/models/gui/avatar_panel_gui")
        self.closeButton = DirectButton(
            image=(
                gui.find("**/CloseBtn_UP"),
                gui.find("**/CloseBtn_DN"),
                gui.find("**/CloseBtn_Rllvr"),
                gui.find("**/CloseBtn_UP"),
            ),
            relief=None,
            scale=2,
            text=TTLocalizer.BossbotPitcherLeave,
            text_scale=0.040000000000000001,
            text_pos=(0, -0.070000000000000007),
            text_fg=VBase4(1, 1, 1, 1),
            pos=(1.05, 0, -0.81999999999999995),
            command=self._DistributedBanquetTable__exitPitcher,
        )
        self.accept("escape", self._DistributedBanquetTable__exitPitcher)
        self.accept("control", self._DistributedBanquetTable__controlPressed)
        self.accept("control-up", self._DistributedBanquetTable__controlReleased)
        self.accept("InputState-forward", self._DistributedBanquetTable__upArrow)
        self.accept("InputState-reverse", self._DistributedBanquetTable__downArrow)
        self.accept("InputState-turnLeft", self._DistributedBanquetTable__leftArrow)
        self.accept("InputState-turnRight", self._DistributedBanquetTable__rightArrow)
        self.accept("arrow_up", self._DistributedBanquetTable__upArrowKeyPressed)
        self.accept("arrow_down", self._DistributedBanquetTable__downArrowKeyPressed)
        taskMgr.add(self._DistributedBanquetTable__watchControls, self.watchControlsName)
        taskMgr.doMethodLater(5, self._DistributedBanquetTable__displayPitcherAdvice, self.pitcherAdviceName)
        self.arrowVert = 0
        self.arrowHorz = 0
        self.powerBar.show()

    def _DistributedBanquetTable__disableControlInterface(self):
        if self.closeButton:
            self.closeButton.destroy()
            self.closeButton = None

        self._DistributedBanquetTable__cleanupPitcherAdvice()
        self.ignore("escape")
        self.ignore("control")
        self.ignore("control-up")
        self.ignore("InputState-forward")
        self.ignore("InputState-reverse")
        self.ignore("InputState-turnLeft")
        self.ignore("InputState-turnRight")
        self.ignore("arrow_up")
        self.ignore("arrow_down")
        self.arrowVert = 0
        self.arrowHorz = 0
        taskMgr.remove(self.watchControlsName)
        taskMgr.remove(self.waterPowerTaskName)
        self.resetPowerBar()
        self.aimStart = None
        self.powerBar.hide()
        if self.TugOfWarControls:
            self._DistributedBanquetTable__killUpdateKeyPressRateTask()
            self.keyTTL = []

        self._DistributedBanquetTable__setMoveSound(None)

    def _DistributedBanquetTable__displayPitcherAdvice(self, task):
        if self.pitcherAdviceLabel == None:
            self.pitcherAdviceLabel = DirectLabel(
                text=TTLocalizer.BossbotPitcherAdvice,
                text_fg=VBase4(1, 1, 1, 1),
                text_align=TextNode.ACenter,
                relief=None,
                pos=(0, 0, 0.68999999999999995),
                scale=0.10000000000000001,
            )

    def _DistributedBanquetTable__cleanupPitcherAdvice(self):
        if self.pitcherAdviceLabel:
            self.pitcherAdviceLabel.destroy()
            self.pitcherAdviceLabel = None

        taskMgr.remove(self.pitcherAdviceName)

    def showExiting(self):
        if self.closeButton:
            self.closeButton.destroy()
            self.closeButton = DirectLabel(
                relief=None,
                text=TTLocalizer.BossbotPitcherLeaving,
                pos=(1.05, 0, -0.88),
                text_pos=(0, 0),
                text_scale=0.059999999999999998,
                text_fg=VBase4(1, 1, 1, 1),
            )

        self._DistributedBanquetTable__cleanupPitcherAdvice()

    def _DistributedBanquetTable__exitPitcher(self):
        self.showExiting()
        self.d_requestFree(False)

    def _DistributedBanquetTable__controlPressed(self):
        self._DistributedBanquetTable__cleanupPitcherAdvice()
        if self.TugOfWarControls:
            if self.power:
                self.aimStart = 1
                self._DistributedBanquetTable__endFireWater()

        elif self.state == "Controlled":
            self._DistributedBanquetTable__beginFireWater()

    def _DistributedBanquetTable__controlReleased(self):
        if self.TugOfWarControls:
            pass
        1
        if self.state == "Controlled":
            self._DistributedBanquetTable__endFireWater()

    def _DistributedBanquetTable__upArrow(self, pressed):
        self._DistributedBanquetTable__incrementChangeSeq()
        self._DistributedBanquetTable__cleanupPitcherAdvice()
        if pressed:
            self.arrowVert = 1
        elif self.arrowVert > 0:
            self.arrowVert = 0

    def _DistributedBanquetTable__downArrow(self, pressed):
        self._DistributedBanquetTable__incrementChangeSeq()
        self._DistributedBanquetTable__cleanupPitcherAdvice()
        if pressed:
            self.arrowVert = -1
        elif self.arrowVert < 0:
            self.arrowVert = 0

    def _DistributedBanquetTable__rightArrow(self, pressed):
        self._DistributedBanquetTable__incrementChangeSeq()
        self._DistributedBanquetTable__cleanupPitcherAdvice()
        if pressed:
            self.arrowHorz = 1
        elif self.arrowHorz > 0:
            self.arrowHorz = 0

    def _DistributedBanquetTable__leftArrow(self, pressed):
        self._DistributedBanquetTable__incrementChangeSeq()
        self._DistributedBanquetTable__cleanupPitcherAdvice()
        if pressed:
            self.arrowHorz = -1
        elif self.arrowHorz < 0:
            self.arrowHorz = 0

    def _DistributedBanquetTable__incrementChangeSeq(self):
        self.changeSeq = self.changeSeq + 1 & 255

    def stopPosHprBroadcast(self):
        taskName = self.posHprBroadcastName
        taskMgr.remove(taskName)

    def startPosHprBroadcast(self):
        taskName = self.posHprBroadcastName
        self.b_clearSmoothing()
        self.d_sendPitcherPos()
        taskMgr.remove(taskName)
        taskMgr.doMethodLater(
            self._DistributedBanquetTable__broadcastPeriod, self._DistributedBanquetTable__posHprBroadcast, taskName
        )

    def _DistributedBanquetTable__posHprBroadcast(self, task):
        self.d_sendPitcherPos()
        taskName = self.posHprBroadcastName
        taskMgr.doMethodLater(
            self._DistributedBanquetTable__broadcastPeriod, self._DistributedBanquetTable__posHprBroadcast, taskName
        )
        return Task.done

    def d_sendPitcherPos(self):
        timestamp = globalClockDelta.getFrameNetworkTime()
        self.sendUpdate("setPitcherPos", [self.changeSeq, self.waterPitcherNode.getH(), timestamp])

    def setPitcherPos(self, changeSeq, h, timestamp):
        self.changeSeq = changeSeq
        if self.smoothStarted:
            now = globalClock.getFrameTime()
            local = globalClockDelta.networkToLocalTime(timestamp, now)
            self.pitcherSmoother.setH(h)
            self.pitcherSmoother.setTimestamp(local)
            self.pitcherSmoother.markPosition()
        else:
            self.waterPitcherNode.setH(h)

    def _DistributedBanquetTable__watchControls(self, task):
        if self.arrowHorz:
            self._DistributedBanquetTable__movePitcher(self.arrowHorz)
        else:
            self._DistributedBanquetTable__setMoveSound(None)
        return Task.cont

    def _DistributedBanquetTable__movePitcher(self, xd):
        dt = globalClock.getDt()
        h = self.waterPitcherNode.getH() - xd * self.rotateSpeed * dt
        h %= 360
        self.notify.debug(
            "rotSpeed=%.2f curH=%.2f  xd =%.2f, dt = %.2f, h=%.2f"
            % (self.rotateSpeed, self.waterPitcherNode.getH(), xd, dt, h)
        )
        limitH = h
        self.waterPitcherNode.setH(limitH)
        if xd:
            self._DistributedBanquetTable__setMoveSound(self.pitcherMoveSfx)

    def reloadPosition(self):
        self.pitcherSmoother.clearPositions(0)
        self.pitcherSmoother.setHpr(self.waterPitcherNode.getHpr())
        self.pitcherSmoother.setPhonyTimestamp()

    def forceToTruePosition(self):
        if self.pitcherSmoother.getLatestPosition():
            self.pitcherSmoother.applySmoothHpr(self.waterPitcherNode)

        self.pitcherSmoother.clearPositions(1)

    def getSprayTrack(
        self, color, origin, target, dScaleUp, dHold, dScaleDown, horizScale=1.0, vertScale=1.0, parent=render
    ):
        track = Sequence()
        SPRAY_LEN = 1.5
        sprayProp = MovieUtil.globalPropPool.getProp("spray")
        sprayScale = hidden.attachNewNode("spray-parent")
        sprayRot = hidden.attachNewNode("spray-rotate")
        spray = sprayRot
        spray.setColor(color)
        if color[3] < 1.0:
            spray.setTransparency(1)

        def showSpray(sprayScale, sprayRot, sprayProp, origin, target, parent):
            if callable(origin):
                origin = origin()

            if callable(target):
                target = target()

            sprayRot.reparentTo(parent)
            sprayRot.clearMat()
            sprayScale.reparentTo(sprayRot)
            sprayScale.clearMat()
            sprayProp.reparentTo(sprayScale)
            sprayProp.clearMat()
            sprayRot.setPos(origin)
            sprayRot.lookAt(Point3(target))

        track.append(Func(showSpray, sprayScale, sprayRot, sprayProp, origin, target, parent))

        def calcTargetScale(target=target, origin=origin, horizScale=horizScale, vertScale=vertScale):
            if callable(target):
                target = target()

            if callable(origin):
                origin = origin()

            distance = Vec3(target - origin).length()
            yScale = distance / SPRAY_LEN
            targetScale = Point3(yScale * horizScale, yScale, yScale * vertScale)
            return targetScale

        track.append(LerpScaleInterval(sprayScale, dScaleUp, calcTargetScale, startScale=Point3(0.01, 0.01, 0.01)))
        track.append(Func(self.checkHitObject))
        track.append(Wait(dHold))

        def prepareToShrinkSpray(spray, sprayProp, origin, target):
            if callable(target):
                target = target()

            if callable(origin):
                origin = origin()

            sprayProp.setPos(Point3(0.0, -SPRAY_LEN, 0.0))
            spray.setPos(target)

        track.append(Func(prepareToShrinkSpray, spray, sprayProp, origin, target))
        track.append(LerpScaleInterval(sprayScale, dScaleDown, Point3(0.01, 0.01, 0.01)))

        def hideSpray(spray, sprayScale, sprayRot, sprayProp, propPool):
            sprayProp.detachNode()
            MovieUtil.removeProp(sprayProp)
            sprayRot.removeNode()
            sprayScale.removeNode()

        track.append(Func(hideSpray, spray, sprayScale, sprayRot, sprayProp, MovieUtil.globalPropPool))
        return track

    def checkHitObject(self):
        if not self.hitObject:
            return None

        if self.avId != base.localAvatar.doId:
            return None

        tag = self.hitObject.getNetTag("pieCode")
        pieCode = int(tag)
        if pieCode == ToontownGlobals.PieCodeBossCog:
            self.hitBossSoundInterval.start()
            self.sendUpdate("waterHitBoss", [self.index])
            if self.TugOfWarControls:
                damage = 1
                if self.lastPowerFired < self.YELLOW_POWER_THRESHOLD:
                    damage = 1
                elif self.lastPowerFired < self.RED_POWER_THRESHOLD:
                    damage = 2
                else:
                    damage = 3
                self.boss.d_hitBoss(damage)
            else:
                damage = 1
                if self.lastPowerFired < self.YELLOW_POWER_THRESHOLD:
                    damage = 1
                elif self.lastPowerFired < self.RED_POWER_THRESHOLD:
                    damage = 2
                else:
                    damage = 3
                self.boss.d_hitBoss(damage)

    def waterHitBoss(self, tableIndex):
        if self.index == tableIndex:
            self.hitBossSoundInterval.start()

    def setupPowerBar(self):
        self.powerBar = DirectWaitBar(
            pos=(0.0, 0, -0.93999999999999995),
            relief=DGG.SUNKEN,
            frameSize=(-2.0, 2.0, -0.20000000000000001, 0.20000000000000001),
            borderWidth=(0.02, 0.02),
            scale=0.25,
            range=1,
            sortOrder=50,
            frameColor=(0.5, 0.5, 0.5, 0.5),
            barColor=(0.75, 0.75, 1.0, 0.80000000000000004),
            text="",
            text_scale=0.26000000000000001,
            text_fg=(1, 1, 1, 1),
            text_align=TextNode.ACenter,
            text_pos=(0, -0.050000000000000003),
        )
        self.power = 0
        self.powerBar["value"] = self.power
        self.powerBar.hide()

    def resetPowerBar(self):
        self.power = 0
        self.powerBar["value"] = self.power
        self.powerBar["text"] = ""
        self.keyTTL = []

    def _DistributedBanquetTable__beginFireWater(self):
        if self.fireTrack and self.fireTrack.isPlaying():
            return None

        if self.aimStart != None:
            return None

        if not self.state == "Controlled":
            return None

        if not self.avId == localAvatar.doId:
            return None

        time = globalClock.getFrameTime()
        self.aimStart = time
        messenger.send("wakeup")
        taskMgr.add(self._DistributedBanquetTable__updateWaterPower, self.waterPowerTaskName)

    def _DistributedBanquetTable__endFireWater(self):
        if self.aimStart == None:
            return None

        if not self.state == "Controlled":
            return None

        if not self.avId == localAvatar.doId:
            return None

        taskMgr.remove(self.waterPowerTaskName)
        messenger.send("wakeup")
        self.aimStart = None
        origin = self.nozzle.getPos(render)
        target = self.boss.getPos(render)
        angle = deg2Rad(self.waterPitcherNode.getH() + 90)
        x = math.cos(angle)
        y = math.sin(angle)
        fireVector = Point3(x, y, 0)
        if self.power < 0.001:
            self.power = 0.001

        self.lastPowerFired = self.power
        fireVector *= self.fireLength * self.power
        target = origin + fireVector
        segment = CollisionSegment(origin[0], origin[1], origin[2], target[0], target[1], target[2])
        fromObject = render.attachNewNode(CollisionNode("pitcherColNode"))
        fromObject.node().addSolid(segment)
        fromObject.node().setFromCollideMask(
            ToontownGlobals.PieBitmask | ToontownGlobals.CameraBitmask | ToontownGlobals.FloorBitmask
        )
        fromObject.node().setIntoCollideMask(BitMask32.allOff())
        queue = CollisionHandlerQueue()
        base.cTrav.addCollider(fromObject, queue)
        base.cTrav.traverse(render)
        queue.sortEntries()
        self.hitObject = None
        if queue.getNumEntries():
            entry = queue.getEntry(0)
            target = entry.getSurfacePoint(render)
            self.hitObject = entry.getIntoNodePath()

        base.cTrav.removeCollider(fromObject)
        fromObject.removeNode()
        self.d_firingWater(origin, target)
        self.fireWater(origin, target)
        self.resetPowerBar()

    def _DistributedBanquetTable__updateWaterPower(self, task):
        if not self.powerBar:
            print "### no power bar!!!"
            return task.done

        newPower = self._DistributedBanquetTable__getWaterPower(globalClock.getFrameTime())
        self.power = newPower
        self.powerBar["value"] = newPower
        if self.power < self.YELLOW_POWER_THRESHOLD:
            self.powerBar["barColor"] = VBase4(0.75, 0.75, 1.0, 0.80000000000000004)
        elif self.power < self.RED_POWER_THRESHOLD:
            self.powerBar["barColor"] = VBase4(1.0, 1.0, 0.0, 0.80000000000000004)
        else:
            self.powerBar["barColor"] = VBase4(1.0, 0.0, 0.0, 0.80000000000000004)
        return task.cont

    def _DistributedBanquetTable__getWaterPower(self, time):
        elapsed = max(time - self.aimStart, 0.0)
        t = elapsed / self.waterPowerSpeed
        exponent = self.waterPowerExponent
        if t > 1:
            t = t % 1

        power = 1 - math.pow(1 - t, exponent)
        if power > 1.0:
            power = 1.0

        return power

    def d_firingWater(self, origin, target):
        self.sendUpdate("firingWater", [origin[0], origin[1], origin[2], target[0], target[1], target[2]])

    def firingWater(self, startX, startY, startZ, endX, endY, endZ):
        origin = Point3(startX, startY, startZ)
        target = Point3(endX, endY, endZ)
        self.fireWater(origin, target)

    def fireWater(self, origin, target):
        color = VBase4(0.75, 0.75, 1, 0.80000000000000004)
        dScaleUp = 0.10000000000000001
        dHold = 0.29999999999999999
        dScaleDown = 0.10000000000000001
        horizScale = 0.10000000000000001
        vertScale = 0.10000000000000001
        sprayTrack = self.getSprayTrack(color, origin, target, dScaleUp, dHold, dScaleDown, horizScale, vertScale)
        duration = self.squirtSfx.length()
        if sprayTrack.getDuration() < duration:
            duration = sprayTrack.getDuration()

        soundTrack = SoundInterval(self.squirtSfx, node=self.waterPitcherModel, duration=duration)
        self.fireTrack = Parallel(sprayTrack, soundTrack)
        self.fireTrack.start()

    def getPos(self, wrt=render):
        return self.tableGroup.getPos(wrt)

    def getLocator(self):
        return self.tableGroup

    def enterFlat(self, avId):
        self.prepareForPhaseFour()
        self.resetPowerBar()
        self.notify.debug("enterFlat %d" % self.index)
        if self.avId:
            toon = base.cr.doId2do.get(self.avId)
            if toon:
                toon.wrtReparentTo(render)
                toon.setZ(0)

        self.tableGroup.setScale(1, 1, 0.01)
        if self.avId and self.avId == localAvatar.doId:
            localAvatar.b_squish(ToontownGlobals.BossCogDamageLevels[ToontownGlobals.BossCogMoveAttack])

    def exitFlat(self):
        self.tableGroup.setScale(1.0)
        if self.avId:
            toon = base.cr.doId2do.get(self.avId)
            if toon:
                if toon == localAvatar:
                    self.boss.toCraneMode()
                    toon.b_setAnimState("neutral")

                toon.setAnimState("neutral")
                toon.loop("leverNeutral")

    def _DistributedBanquetTable__allowDetect(self, task):
        if self.fadeTrack:
            self.fadeTrack.finish()

        self.fadeTrack = Sequence(
            self.tableGroup.colorScaleInterval(0.20000000000000001, VBase4(1, 1, 1, 1)),
            Func(self.tableGroup.clearColorScale),
            Func(self.tableGroup.clearTransparency),
        )
        self.fadeTrack.start()
        self.allowLocalRequestControl = True

    def gotBossZapped(self):
        self.showExiting()
        self.d_requestFree(True)

    def _DistributedBanquetTable__upArrowKeyPressed(self):
        if self.TugOfWarControls:
            self._DistributedBanquetTable__pressHandler(0)

    def _DistributedBanquetTable__downArrowKeyPressed(self):
        if self.TugOfWarControls:
            self._DistributedBanquetTable__pressHandler(1)

    def _DistributedBanquetTable__pressHandler(self, index):
        if index == self.buttons[0]:
            self.keyTTL.insert(0, 1.0)
            if not self.OnlyUpArrow:
                self.buttons.reverse()

    def _DistributedBanquetTable__spawnUpdateKeyPressRateTask(self):
        taskMgr.remove(self.taskName(self.UPDATE_KEY_PRESS_RATE_TASK))
        taskMgr.doMethodLater(
            0.10000000000000001,
            self._DistributedBanquetTable__updateKeyPressRateTask,
            self.taskName(self.UPDATE_KEY_PRESS_RATE_TASK),
        )

    def _DistributedBanquetTable__killUpdateKeyPressRateTask(self):
        taskMgr.remove(self.taskName(self.UPDATE_KEY_PRESS_RATE_TASK))

    def _DistributedBanquetTable__updateKeyPressRateTask(self, task):
        if self.state not in "Controlled":
            return Task.done

        for i in range(len(self.keyTTL)):
            self.keyTTL[i] -= 0.10000000000000001

        for i in range(len(self.keyTTL)):
            if self.keyTTL[i] <= 0:
                a = self.keyTTL[0:i]
                del self.keyTTL
                self.keyTTL = a
                break
                continue

        self.keyRate = len(self.keyTTL)
        keyRateDiff = self.keyRate - self.BASELINE_KEY_RATE
        diffPower = keyRateDiff / 300.0
        if self.power < 1 and diffPower > 0:
            diffPower = diffPower * math.pow(1 - self.power, 1.25)

        newPower = self.power + diffPower
        if newPower > 1:
            newPower = 1
        elif newPower < 0:
            newPower = 0

        self.notify.debug("diffPower=%.2f keyRate = %d, newPower=%.2f" % (diffPower, self.keyRate, newPower))
        self.power = newPower
        self.powerBar["value"] = newPower
        if self.power < self.YELLOW_POWER_THRESHOLD:
            self.powerBar["barColor"] = VBase4(0.75, 0.75, 1.0, 0.80000000000000004)
        elif self.power < self.RED_POWER_THRESHOLD:
            self.powerBar["barColor"] = VBase4(1.0, 1.0, 0.0, 0.80000000000000004)
        else:
            self.powerBar["barColor"] = VBase4(1.0, 0.0, 0.0, 0.80000000000000004)
        self._DistributedBanquetTable__spawnUpdateKeyPressRateTask()
        return Task.done

    def _DistributedBanquetTable__setMoveSound(self, sfx):
        if sfx != self.moveSound:
            if self.moveSound:
                self.moveSound.stop()

            self.moveSound = sfx
            if self.moveSound:
                base.playSfx(self.moveSound, looping=1, volume=0.5)
Пример #51
0
class Fighter(DirectObject):
    def __init__(self):
        
        base.disableMouse()

        # Carga el fondo del juego
        self.bg = loader.loadModel("models/plane")
        self.bg.reparentTo(camera)
        self.bg.setPos(0, 200, 0)
        self.bg.setScale(300, 0, 146)
        self.bg.setTexture(loader.loadTexture("models/Backgrounds/farback.png"), 1)
        
        # Inicializa el gestor de teclado y los objetos del juego
        self.inputManager = InputManager()

        # Inicializa el menu del juego
        self.inicializarMenu()

        self.marcador = None
        self.barraEnergia = None
        self.marcadorFinalNP = None
        self.entrada = None
        self.rankingNP = None

        self.mostrarMenuJuego()
        self.accept("m", self.cambiarMenuJuego)
        self.accept("q", self.salir)

    # Inicializa el menu
    def inicializarMenu(self):
        self.menuGraphics = loader.loadModel("models/MenuGraphics")
        self.fonts = {"silver" : loader.loadFont("fonts/LuconSilver"),
                      "blue" : loader.loadFont("fonts/LuconBlue"),
                      "orange" : loader.loadFont("fonts/LuconOrange")}
        self.menu = Menu(self.menuGraphics, self.fonts, self.inputManager)
        self.menu.initMenu([0, None, 
            ["Nueva Partida", "Salir"],
            [[self.nuevaPartida], [self.salir]],
            [[None], [None]]])

    # Comienza una partida
    def nuevaPartida(self):
        
        if (not self.marcadorFinalNP is None):
            self.marcadorFinalNP.detachNode()
            self.marcadorFinalNP.remove()

        if (not self.rankingNP is None):
            self.rankingNP.detachNode()
            self.rankingNP.remove()

        self.ship = Ship(self.inputManager)
        self.mostrarInfo()

        taskMgr.add(self.actualizarInfo, "Actualizar Puntuacion")

    # Inicializa y muestra el marcador del jugador
    def mostrarInfo(self):

        self.marcador = TextNode("Marcador")
        self.marcador.setText("Puntos: " + str(self.ship.puntos))
        self.marcador.setCardColor(0, 0, 0, 1)
        self.marcador.setCardDecal(True)
        self.marcador.setCardAsMargin(0.4, 0.4, 0.4, 0.4)
        self.marcadorNP = aspect2d.attachNewNode(self.marcador)
        self.marcadorNP.reparentTo(base.a2dTopLeft)
        self.marcadorNP.setPos(0.02, 0, -0.05)
        self.marcadorNP.setScale(0.07)

        self.barraEnergia = DirectWaitBar(text = "Energia", value = 5, 
            range = 5, scale = 0.3, pos = (0, 0, 0.95))

    # Actualiza la puntuacion del jugador en pantalla
    def actualizarInfo(self, tarea):
        self.marcador.setText("Puntos: " + str(self.ship.puntos))
        self.barraEnergia["value"] = self.ship.vida
        self.barraEnergia.setValue()

        # Termina la partida
        if (self.ship.terminarPartida):
            self.terminarPartida()
            return tarea.done

        return tarea.cont

    # Termina partida liberando recursos para poder empezar una nueva
    # sin reiniciar el juego
    def terminarPartida(self):
        # Solicita al usuario un nombre para la tabla de puntuaciones
        self.entrada = DirectEntry(width = 15, numLines = 1, scale = 0.07,
            cursorKeys = 1, frameSize = (0, 15, 0, 1), command = self.almacenarPuntuacion,
            pos = (-0.3, 0, 0.1), focus = True, text_pos = (0.2, 0.2))
        self.puntos = self.ship.puntos

        self.ship.ship.detachNode()
        self.ship.ship.remove()
        taskMgr.remove("Mover Nave")
        taskMgr.remove("Generar Enemigos")
        taskMgr.remove("Comprobar Impactos")
        taskMgr.remove("Actualizar Puntuacion")
        taskMgr.remove("Explosionar*")

        self.mostrarFinPartida()

        # Libera los recursos de la partida que ha terminado
        self.ship.eliminarObjetos()
        del self.ship
        del self.menuGraphics
        del self.menu
        self.marcadorNP.detachNode()
        self.marcadorNP.remove()
        self.barraEnergia.destroy()
        del self.marcador
        del self.barraEnergia

        #self.inicializarMenu()

    # Almacena la puntuacion del jugador
    def almacenarPuntuacion(self, valor):

        self.crearBDD()

        db = sqlite3.connect("datos.db")
        cursor = db.cursor()
        parametros = (valor, self.puntos)
        cursor.execute("insert into puntuaciones values (?, ?)", parametros)
        db.commit()
        cursor.close()

        self.entrada.destroy()

        self.mostrarTopPuntuacion()

        self.inicializarMenu()

    # Crea la Base de Datos si no existe ya
    def crearBDD(self):
        db = sqlite3.connect("datos.db")
        cursor = db.cursor()
        args = ("puntuaciones",)
        cursor.execute("select name from sqlite_master where name = ?", args)
        if len(cursor.fetchall()) == 0:
            cursor.execute("create table puntuaciones (nombre text, puntuacion numeric)")
            db.commit()
        cursor.close()

    # Muestra las 10 mejores puntuaciones
    def mostrarTopPuntuacion(self):
        # Extrae las 10 mejores puntuaciones de la base de datos
        db = sqlite3.connect("datos.db")
        cursor = db.cursor()
        cursor.execute("select nombre, puntuacion from puntuaciones order by puntuacion desc limit 10")
        puntuaciones = cursor.fetchall()
        cursor.close()
        resultado = "-- MEJORES PUNTUACIONES --\n-Jugador-  -Puntuacion-\n\n"
        for nombre, puntuacion in puntuaciones:
            resultado += nombre + " " + str(puntuacion) + "\n"

        # Muestra las 10 mejores puntuaciones
        self.ranking = TextNode("Ranking")
        self.ranking.setText(resultado)
        self.ranking.setCardColor(0, 0, 0, 1)
        self.ranking.setCardDecal(True)
        self.ranking.setCardAsMargin(0.4, 0.4, 0.4, 0.4)
        self.rankingNP = aspect2d.attachNewNode(self.ranking)
        self.rankingNP.reparentTo(base.a2dTopLeft)
        self.rankingNP.setPos(1, 0, -1)
        self.rankingNP.setScale(0.07)

    # Muestra el mensaje de fin de partida
    def mostrarFinPartida(self):
        self.marcadorFinal = TextNode("Marcador Final")
        self.marcadorFinal.setText("Game Over!\nPuntuacion: " + str(self.ship.puntos) +"\n\n" +
            "Escribe tu nombre:")
        self.marcadorFinal.setCardColor(0, 0, 0, 1)
        self.marcadorFinal.setCardDecal(True)
        self.marcadorFinal.setCardAsMargin(0.4, 0.4, 0.4, 0.4)
        self.marcadorFinalNP = aspect2d.attachNewNode(self.marcadorFinal)
        self.marcadorFinalNP.setPos(-0.3, 0, 0.5)
        self.marcadorFinalNP.setScale(0.07)

    # Muestra un menu con las opciones durante el juego
    def mostrarMenuJuego(self):
        self.textoMenu = {}
        self.textoMenu["titulo"] = OnscreenText(text = "", pos = (0, 0.92), scale = 0.08, 
            fg = (1, 1, 1, 1), bg = (0, 0, 1, 0.7))
        self.textoMenu["descripcion"] = OnscreenText(text = "", pos = (0, 0.84), scale = 0.05,
            fg = (1, 1, 0, 1), bg = (0, 0, 0, 0.5))
        self.textoMenu["opciones"] = OnscreenText(text = "", pos = (-1.3, 0), scale = 0.05,
            fg = (1, 1, 1, 1), bg = (1, 0.3, 0, 0.6), align=TextNode.ALeft, wordwrap = 15)

        self.textoMenu["opciones"].setText("** OPCIONES **\n" + 
            "m = ocultar menu\n" +
            "q = salir")

        # Inicialmente el menu se deja oculto
        for linea in self.textoMenu.values():
            linea.hide()

    # Muestra / Oculta el menu de juego
    def cambiarMenuJuego(self):
        for linea in self.textoMenu.values():
            if linea.isHidden():
                linea.show()
            else:
                linea.hide()

    # Sale del juego
    def salir(self):
        print("Saliendo . . .")
        sys.exit()
Пример #52
0
class DistributedCogBattle(DistributedObject):
    notify = directNotify.newCategory('DistributedCogBattle')
    DNCData = {0: [[(-50, 98.73, 0.4), (351.31, 0.0, 0.0), 1.25],
         [(-41.07, 97.2, 0.4), (350.34, 0.0, 0.0), 1.25],
         [(-152.73, -0.58, 0.4), (90.0, 0, 0), 1.25],
         [(-152.73, 8.81, 0.4), (85.3, 0, 0), 1.25],
         [(34.34, -157.19, 2.95), (150.75, 0, 0), 1.25],
         [(26.21, -152.66, 2.95), (147.09, 0, 0), 1.25]],
     1: [],
     2: [],
     5: []}

    def __init__(self, cr):
        try:
            self.DistributedCogBattle_initialized
            return
        except:
            self.DistributedCogBattle_initialized = 1

        DistributedObject.__init__(self, cr)
        self.hoodIndex = None
        self.totalCogs = None
        self.cogsRemaining = None
        self.cogProgressBar = None
        self.DNCSigns = []
        self.introMessageSeq = None
        self.victorySeq = None
        self.turretManager = None
        return

    def setTurretManager(self, tmgr):
        self.turretManager = tmgr

    def getTurretManager(self):
        return self.turretManager

    def victory(self):
        self.cr.playGame.getPlace().fsm.request('stop')
        base.localAvatar.b_setAnimState('win')
        self.victorySeq = Sequence(Wait(7.0), Func(self.finishVictory))
        self.victorySeq.start()

    def finishVictory(self):
        hoodId = self.cr.playGame.hood.hoodId
        if hoodId == CIGlobals.BattleTTC:
            hoodId = CIGlobals.ToontownCentral
            zoneId = CIGlobals.ToontownCentralId
        else:
            zoneId = CogBattleGlobals.HoodIndex2HoodId[self.getHoodIndex()]
        requestStatus = {'zoneId': zoneId,
         'hoodId': hoodId,
         'where': 'playground',
         'avId': base.localAvatar.doId,
         'loader': 'safeZoneLoader',
         'shardId': None,
         'how': 'teleportIn'}
        self.cr.playGame.getPlace().fsm.request('teleportOut', [requestStatus])
        return

    def setTotalCogs(self, num):
        self.totalCogs = num

    def getTotalCogs(self):
        return self.totalCogs

    def setCogsRemaining(self, num):
        self.cogsRemaining = num
        if self.cogProgressBar:
            self.__updateProgressBar()

    def getCogsRemaining(self):
        return self.cogsRemaining

    def setHoodIndex(self, index):
        self.hoodIndex = index

    def getHoodIndex(self):
        return self.hoodIndex

    def startPlacePoll(self):
        taskMgr.add(self.__placePoll, 'DistributedCogBattle-placePoll')

    def __placePoll(self, task):
        if self.cr.playGame.getPlace() != None:
            self.sendUpdate('arrived', [])
            self.constructArea()
            self.createInterface()
            self.__doIntroMessages()
            return task.done
        else:
            return task.cont
            return

    def stopPlacePoll(self):
        taskMgr.remove('DistributedCogBattle-placePoll')

    def createInterface(self):
        self.cogProgressBar = DirectWaitBar(pos=(0, 0, -0.9), relief=DGG.RAISED, scale=0.6, frameColor=(1, 0.5, 0.3, 0.75), barColor=(1, 0.25, 0.25, 0.5), value=0, range=self.getTotalCogs(), text='', text_scale=0.08)
        self.__updateProgressBar()

    def __updateProgressBar(self):
        self.cogProgressBar.update(self.getCogsRemaining())
        self.cogProgressBar['text'] = '{0}/{1} {2} Remaining'.format(self.getCogsRemaining(), self.getTotalCogs(), CIGlobals.Suits)

    def destroyInterface(self):
        if self.cogProgressBar:
            self.cogProgressBar.destroy()
            self.cogProgressBar = None
        return

    def createBossGui(self):
        self.destroyInterface()
        backgroundGui = loader.loadModel('phase_5/models/cogdominium/tt_m_gui_csa_flyThru.bam')
        backgroundGui.find('**/chatBubble').removeNode()
        bg = backgroundGui.find('**/background')
        bg.setScale(5.2)
        bg.setPos(0.14, 0, -0.6667)
        bg.reparentTo(aspect2d)
        self.frame = DirectFrame(geom=bg, relief=None, pos=(0.2, 0, -0.6667))
        return

    def constructArea(self):
        for data in self.DNCData[self.hoodIndex]:
            dnc = loader.loadModel('phase_3.5/models/props/do_not_cross.egg')
            dnc.setPos(*data[0])
            dnc.setHpr(*data[1])
            dnc.setScale(data[2])
            dnc.reparentTo(render)
            self.DNCSigns.append(dnc)

    def deconstructArea(self):
        for dnc in self.DNCSigns:
            dnc.removeNode()

    def createWhisper(self, msg):
        whisper = Whisper()
        whisper.createSystemMessage(msg)

    def __doIntroMessages(self):
        self.introMessageSeq = Sequence(name='DistributedCogBattle-introMessageSeq')
        self.introMessageSeq.append(Func(self.createWhisper, 'Welcome, Toons! The Cogs will be here soon, so get prepared!'))
        self.introMessageSeq.append(Wait(7.5))
        self.introMessageSeq.append(Func(self.createWhisper, 'The pink bar at the bottom of the screen shows the amount of Cogs remaining to defeat.'))
        self.introMessageSeq.append(Wait(8.5))
        self.introMessageSeq.append(Func(self.createWhisper, 'Purchase gags from Goofy at the Gag Shop to restock your used gags.'))
        self.introMessageSeq.append(Wait(7.5))
        self.introMessageSeq.append(Func(self.createWhisper, "Purchase battle tools from Coach at Coach's Battle Shop in between invasions."))
        self.introMessageSeq.setDoneEvent(self.introMessageSeq.getName())
        self.acceptOnce(self.introMessageSeq.getDoneEvent(), self.__introMessagesDone)
        self.introMessageSeq.start()

    def __introMessagesDone(self):
        if self.introMessageSeq:
            self.introMessageSeq.finish()
            self.introMessageSeq = None
        return

    def announceGenerate(self):
        DistributedObject.announceGenerate(self)
        base.localAvatar.setMyBattle(self)
        self.startPlacePoll()

    def disable(self):
        self.turretManager = None
        base.localAvatar.setMyBattle(None)
        self.stopPlacePoll()
        self.deconstructArea()
        self.destroyInterface()
        if self.victorySeq:
            self.victorySeq.pause()
            self.victorySeq = None
        self.hoodIndex = None
        self.DNCSigns = None
        self.totalCogs = None
        self.cogsRemaining = None
        if self.introMessageSeq:
            self.introMessageSeq.pause()
            self.introMessageSeq = None
        DistributedObject.disable(self)
        return
class DistributedGolfSpot(DistributedObject.DistributedObject, FSM.FSM):
    notify = DirectNotifyGlobal.directNotify.newCategory('DistributedGolfSpot')
    positions = ((-45, 100, GolfGlobals.GOLF_BALL_RADIUS),
     (-15, 100, GolfGlobals.GOLF_BALL_RADIUS),
     (15, 100, GolfGlobals.GOLF_BALL_RADIUS),
     (45, 100, GolfGlobals.GOLF_BALL_RADIUS))
    toonGolfOffsetPos = Point3(-2, 0, -GolfGlobals.GOLF_BALL_RADIUS)
    toonGolfOffsetHpr = Point3(-90, 0, 0)
    rotateSpeed = 20
    golfPowerSpeed = base.config.GetDouble('golf-power-speed', 3)
    golfPowerExponent = base.config.GetDouble('golf-power-exponent', 0.75)

    def __init__(self, cr):
        DistributedObject.DistributedObject.__init__(self, cr)
        FSM.FSM.__init__(self, 'DistributedGolfSpot')
        self.boss = None
        self.index = None
        self.avId = 0
        self.toon = None
        self.golfSpotSmoother = SmoothMover()
        self.golfSpotSmoother.setSmoothMode(SmoothMover.SMOn)
        self.smoothStarted = 0
        self.__broadcastPeriod = 0.2
        if self.index > len(self.positions):
            self.notify.error('Invalid index %d' % index)
        self.fadeTrack = None
        self.setupPowerBar()
        self.aimStart = None
        self.golfSpotAdviceLabel = None
        self.changeSeq = 0
        self.lastChangeSeq = 0
        self.controlKeyAllowed = False
        self.flyBallTracks = {}
        self.splatTracks = {}
        self.__flyBallBubble = None
        self.flyBallHandler = None
        self.__flyBallSequenceNum = 0
        self.swingInterval = None
        self.lastHitSequenceNum = -1
        self.goingToReward = False
        self.gotHitByBoss = False
        self.releaseTrack = None
        self.grabTrack = None
        self.restoreScaleTrack = None
        return

    def setBossCogId(self, bossCogId):
        self.bossCogId = bossCogId
        self.boss = base.cr.doId2do[bossCogId]
        self.boss.setGolfSpot(self, self.index)

    def setIndex(self, index):
        self.index = index

    def disable(self):
        DistributedObject.DistributedObject.disable(self)
        self.ignoreAll()

    def delete(self):
        DistributedObject.DistributedObject.delete(self)
        self.ignoreAll()
        self.boss = None
        return

    def announceGenerate(self):
        DistributedObject.DistributedObject.announceGenerate(self)
        self.triggerName = self.uniqueName('trigger')
        self.triggerEvent = 'enter%s' % self.triggerName
        self.smoothName = self.uniqueName('golfSpotSmooth')
        self.golfSpotAdviceName = self.uniqueName('golfSpotAdvice')
        self.posHprBroadcastName = self.uniqueName('golfSpotBroadcast')
        self.ballPowerTaskName = self.uniqueName('updateGolfPower')
        self.adjustClubTaskName = self.uniqueName('adjustClub')
        self.loadAssets()
        self.accept('flyBallHit-%d' % self.index, self.__flyBallHit)

    def loadAssets(self):
        self.root = render.attachNewNode('golfSpot-%d' % self.index)
        self.root.setPos(*self.positions[self.index])
        self.ballModel = loader.loadModel('phase_6/models/golf/golf_ball')
        self.ballColor = VBase4(1, 1, 1, 1)
        if self.index < len(GolfGlobals.PlayerColors):
            self.ballColor = VBase4(*GolfGlobals.PlayerColors[self.index])
            self.ballModel.setColorScale(self.ballColor)
        self.ballModel.reparentTo(self.root)
        self.club = loader.loadModel('phase_6/models/golf/putter')
        self.clubLookatSpot = self.root.attachNewNode('clubLookat')
        self.clubLookatSpot.setY(-(GolfGlobals.GOLF_BALL_RADIUS + 0.1))
        cs = CollisionSphere(0, 0, 0, 1)
        cs.setTangible(0)
        cn = CollisionNode(self.triggerName)
        cn.addSolid(cs)
        cn.setIntoCollideMask(ToontownGlobals.WallBitmask)
        self.trigger = self.root.attachNewNode(cn)
        self.trigger.stash()
        self.hitBallSfx = loader.loadSfx('phase_6/audio/sfx/Golf_Hit_Ball.ogg')

    def cleanup(self):
        if self.swingInterval:
            self.swingInterval.finish()
            self.swingInterval = None
        if self.releaseTrack:
            self.releaseTrack.finish()
            self.releaseTrack = None
        flyTracks = self.flyBallTracks.values()
        for track in flyTracks:
            track.finish()

        if self.fadeTrack:
            self.fadeTrack.finish()
            self.fadeTrack = None
        if self.restoreScaleTrack:
            self.restoreScaleTrack.finish()
            self.restoreScaleTrack = None
        self.root.removeNode()
        self.ballModel.removeNode()
        self.club.removeNode()
        if self.powerBar:
            self.powerBar.destroy()
            self.powerBar = None
        taskMgr.remove(self.triggerName)
        self.boss = None
        return

    def setState(self, state, avId, extraInfo):
        if not self.isDisabled():
            self.gotHitByBoss = extraInfo
            if state == 'C':
                self.demand('Controlled', avId)
            elif state == 'F':
                self.demand('Free')
            elif state == 'O':
                self.demand('Off')
            else:
                self.notify.error('Invalid state from AI: %s' % state)

    def enterOff(self):
        pass

    def exitOff(self):
        pass

    def enterFree(self):
        if self.fadeTrack:
            self.fadeTrack.finish()
            self.fadeTrack = None
        self.restoreScaleTrack = Sequence(Wait(6), self.getRestoreScaleInterval(), name='restoreScaleTrack')
        self.restoreScaleTrack.start()
        if self.avId == localAvatar.doId:
            if not self.isDisabled():
                self.ballModel.setAlphaScale(0.3)
                self.ballModel.setTransparency(1)
                taskMgr.doMethodLater(5, self.__allowDetect, self.triggerName)
                self.fadeTrack = Sequence(Func(self.ballModel.setTransparency, 1), self.ballModel.colorScaleInterval(0.2, VBase4(1, 1, 1, 0.3)), name='fadeTrack-enterFree')
                self.fadeTrack.start()
        else:
            self.trigger.unstash()
            self.accept(self.triggerEvent, self.__hitTrigger)
        self.avId = 0
        return

    def exitFree(self):
        if self.fadeTrack:
            self.fadeTrack.finish()
            self.fadeTrack = None
        self.restoreScaleTrack.finish()
        self.restoreScaleTrack = None
        taskMgr.remove(self.triggerName)
        self.ballModel.clearTransparency()
        self.trigger.stash()
        self.ignore(self.triggerEvent)
        return

    def enterControlled(self, avId):
        self.avId = avId
        toon = base.cr.doId2do.get(avId)
        if not toon:
            return
        self.enableControlKey()
        self.toon = toon
        self.grabTrack = self.makeToonGrabInterval(toon)
        if avId == localAvatar.doId:
            self.boss.toCraneMode()
            camera.reparentTo(self.root)
            camera.setPosHpr(0, -10, 3, 0, 0, 0)
            localAvatar.setPos(self.root, self.toonGolfOffsetPos)
            localAvatar.setHpr(self.root, self.toonGolfOffsetHpr)
            localAvatar.sendCurrentPosition()
            self.__enableControlInterface()
            self.startPosHprBroadcast()
            self.accept('exitCrane', self.gotBossZapped)
        self.grabTrack.start()

    def exitControlled(self):
        self.grabTrack.finish()
        del self.grabTrack
        if self.swingInterval:
            self.swingInterval.finish()
            self.swingInterval = None
        if not self.ballModel.isEmpty():
            if self.ballModel.isHidden():
                self.notify.debug('ball is hidden scale =%s' % self.ballModel.getScale())
            else:
                self.notify.debug('ball is showing scale=%s' % self.ballModel.getScale())
        if self.toon and not self.toon.isDisabled():
            self.toon.startSmooth()
        self.releaseTrack = self.makeToonReleaseInterval(self.toon)
        self.stopPosHprBroadcast()
        self.stopSmooth()
        if self.avId == localAvatar.doId:
            self.__disableControlInterface()
            if not self.goingToReward:
                camera.reparentTo(base.localAvatar)
                camera.setPos(base.localAvatar.cameraPositions[0][0])
                camera.setHpr(0, 0, 0)
        self.stopAdjustClubTask()
        self.releaseTrack.start()
        self.enableControlKey()
        return

    def __allowDetect(self, task):
        if self.fadeTrack:
            self.fadeTrack.finish()
        self.fadeTrack = Sequence(self.ballModel.colorScaleInterval(0.2, self.ballColor), Func(self.ballModel.clearTransparency), name='fadeTrack-allowDetect')
        self.fadeTrack.start()
        self.trigger.unstash()
        self.accept(self.triggerEvent, self.__hitTrigger)

    def __hitTrigger(self, event):
        self.d_requestControl()

    def getRestoreScaleInterval(self):
        return Sequence()

    def d_requestControl(self):
        self.sendUpdate('requestControl')

    def d_requestFree(self, gotHitByBoss):
        self.sendUpdate('requestFree', [gotHitByBoss])

    def makeToonGrabInterval(self, toon):
        origPos = toon.getPos(self.root)
        origHpr = toon.getHpr(self.root)
        a = self.accomodateToon(toon)
        newPos = toon.getPos()
        newHpr = toon.getHpr()
        origHpr.setX(PythonUtil.fitSrcAngle2Dest(origHpr[0], newHpr[0]))
        self.notify.debug('toon.setPosHpr %s %s' % (origPos, origHpr))
        toon.setPosHpr(origPos, origHpr)
        walkTime = 0.2
        reach = Sequence()
        if reach.getDuration() < walkTime:
            reach = Sequence(ActorInterval(toon, 'walk', loop=1, duration=walkTime - reach.getDuration()), reach)
        i = Sequence(Parallel(toon.posInterval(walkTime, newPos, origPos), toon.hprInterval(walkTime, newHpr, origHpr), reach), Func(toon.stopLookAround))
        if toon == base.localAvatar:
            i.append(Func(self.switchToAnimState, 'GolfPuttLoop'))
        i.append(Func(self.startAdjustClubTask))
        i = Parallel(i, a)
        return i

    def accomodateToon(self, toon):
        toon.wrtReparentTo(self.root)
        toon.setPos(self.toonGolfOffsetPos)
        toon.setHpr(self.toonGolfOffsetHpr)
        return Sequence()

    def switchToAnimState(self, animStateName, forced = False):
        curAnimState = base.localAvatar.animFSM.getCurrentState()
        curAnimStateName = ''
        if curAnimState:
            curAnimStateName = curAnimState.getName()
        if curAnimStateName != animStateName or forced:
            base.localAvatar.b_setAnimState(animStateName)

    def __enableControlInterface(self):
        gui = loader.loadModel('phase_3.5/models/gui/avatar_panel_gui')
        self.closeButton = DirectButton(image=(gui.find('**/CloseBtn_UP'),
         gui.find('**/CloseBtn_DN'),
         gui.find('**/CloseBtn_Rllvr'),
         gui.find('**/CloseBtn_UP')), relief=None, scale=2, text=TTLocalizer.BossbotGolfSpotLeave, text_scale=0.04, text_pos=(0, -0.07), text_fg=VBase4(1, 1, 1, 1), pos=(1.05, 0, -0.82), command=self.__exitGolfSpot)
        self.accept('escape', self.__exitGolfSpot)
        self.accept('control', self.__controlPressed)
        self.accept('control-up', self.__controlReleased)
        self.accept('InputState-forward', self.__upArrow)
        self.accept('InputState-reverse', self.__downArrow)
        self.accept('InputState-turnLeft', self.__leftArrow)
        self.accept('InputState-turnRight', self.__rightArrow)
        taskMgr.add(self.__watchControls, 'watchGolfSpotControls')
        taskMgr.doMethodLater(5, self.__displayGolfSpotAdvice, self.golfSpotAdviceName)
        self.arrowVert = 0
        self.arrowHorz = 0
        if self.powerBar:
            self.powerBar.show()
        return

    def __disableControlInterface(self):
        if self.closeButton:
            self.closeButton.destroy()
            self.closeButton = None
        self.__cleanupGolfSpotAdvice()
        self.ignore('escape')
        self.ignore('control')
        self.ignore('control-up')
        self.ignore('InputState-forward')
        self.ignore('InputState-reverse')
        self.ignore('InputState-turnLeft')
        self.ignore('InputState-turnRight')
        self.arrowVert = 0
        self.arrowHorz = 0
        taskMgr.remove('watchGolfSpotControls')
        if self.powerBar:
            self.powerBar.hide()
        else:
            self.notify.debug('self.powerBar is none')
        return

    def setupPowerBar(self):
        self.powerBar = DirectWaitBar(pos=(0.0, 0, -0.94), relief=DGG.SUNKEN, frameSize=(-2.0,
         2.0,
         -0.2,
         0.2), borderWidth=(0.02, 0.02), scale=0.25, range=100, sortOrder=50, frameColor=(0.5, 0.5, 0.5, 0.5), barColor=(1.0, 0.0, 0.0, 1.0), text='', text_scale=0.26, text_fg=(1, 1, 1, 1), text_align=TextNode.ACenter, text_pos=(0, -0.05))
        self.power = 0
        self.powerBar['value'] = self.power
        self.powerBar.hide()

    def resetPowerBar(self):
        self.power = 0
        self.powerBar['value'] = self.power
        self.powerBar['text'] = ''

    def __displayGolfSpotAdvice(self, task):
        if self.golfSpotAdviceLabel == None:
            self.golfSpotAdviceLabel = DirectLabel(text=TTLocalizer.BossbotGolfSpotAdvice, text_fg=VBase4(1, 1, 1, 1), text_align=TextNode.ACenter, relief=None, pos=(0, 0, 0.69), scale=0.1)
        return

    def __cleanupGolfSpotAdvice(self):
        if self.golfSpotAdviceLabel:
            self.golfSpotAdviceLabel.destroy()
            self.golfSpotAdviceLabel = None
        taskMgr.remove(self.golfSpotAdviceName)
        return

    def showExiting(self):
        if self.closeButton:
            self.closeButton.destroy()
            self.closeButton = DirectLabel(relief=None, text=TTLocalizer.BossbotGolfSpotLeaving, pos=(1.05, 0, -0.88), text_pos=(0, 0), text_scale=0.06, text_fg=VBase4(1, 1, 1, 1))
        self.__cleanupGolfSpotAdvice()
        return

    def __exitGolfSpot(self):
        self.d_requestFree(False)

    def __controlPressed(self):
        if self.controlKeyAllowed:
            self.__beginFireBall()

    def __controlReleased(self):
        if self.controlKeyAllowed:
            self.__endFireBall()

    def __upArrow(self, pressed):
        self.__incrementChangeSeq()
        self.__cleanupGolfSpotAdvice()
        if pressed:
            self.arrowVert = 1
        elif self.arrowVert > 0:
            self.arrowVert = 0

    def __downArrow(self, pressed):
        self.__incrementChangeSeq()
        self.__cleanupGolfSpotAdvice()
        if pressed:
            self.arrowVert = -1
        elif self.arrowVert < 0:
            self.arrowVert = 0

    def __rightArrow(self, pressed):
        self.__incrementChangeSeq()
        self.__cleanupGolfSpotAdvice()
        if pressed:
            self.arrowHorz = 1
            self.switchToAnimState('GolfRotateLeft')
        elif self.arrowHorz > 0:
            self.arrowHorz = 0
            self.switchToAnimState('GolfPuttLoop')

    def __leftArrow(self, pressed):
        self.__incrementChangeSeq()
        self.__cleanupGolfSpotAdvice()
        if pressed:
            self.arrowHorz = -1
            self.switchToAnimState('GolfRotateRight')
        elif self.arrowHorz < 0:
            self.arrowHorz = 0
            self.switchToAnimState('GolfPuttLoop')

    def __watchControls(self, task):
        if self.arrowHorz:
            self.__moveGolfSpot(self.arrowHorz)
        return Task.cont

    def __moveGolfSpot(self, xd):
        dt = globalClock.getDt()
        h = self.root.getH() - xd * self.rotateSpeed * dt
        h %= 360
        limitH = h
        self.root.setH(limitH)

    def __incrementChangeSeq(self):
        self.changeSeq = self.changeSeq + 1 & 255

    def __beginFireBall(self):
        if self.aimStart != None:
            return
        if not self.state == 'Controlled':
            return
        if not self.avId == localAvatar.doId:
            return
        time = globalClock.getFrameTime()
        self.aimStart = time
        messenger.send('wakeup')
        taskMgr.add(self.__updateBallPower, self.ballPowerTaskName)
        return

    def __endFireBall(self):
        if self.aimStart == None:
            return
        if not self.state == 'Controlled':
            return
        if not self.avId == localAvatar.doId:
            return
        taskMgr.remove(self.ballPowerTaskName)
        self.disableControlKey()
        messenger.send('wakeup')
        self.aimStart = None
        power = self.power
        angle = self.root.getH()
        self.notify.debug('incrementing self.__flyBallSequenceNum')
        self.__flyBallSequenceNum = (self.__flyBallSequenceNum + 1) % 255
        self.sendSwingInfo(power, angle, self.__flyBallSequenceNum)
        self.setSwingInfo(power, angle, self.__flyBallSequenceNum)
        self.resetPowerBar()
        return

    def __updateBallPower(self, task):
        if not self.powerBar:
            print '### no power bar!!!'
            return task.done
        newPower = self.__getBallPower(globalClock.getFrameTime())
        self.power = newPower
        self.powerBar['value'] = newPower
        return task.cont

    def __getBallPower(self, time):
        elapsed = max(time - self.aimStart, 0.0)
        t = elapsed / self.golfPowerSpeed
        t = math.pow(t, self.golfPowerExponent)
        power = int(t * 100) % 200
        if power > 100:
            power = 200 - power
        return power

    def stopPosHprBroadcast(self):
        taskName = self.posHprBroadcastName
        taskMgr.remove(taskName)

    def startPosHprBroadcast(self):
        taskName = self.posHprBroadcastName
        self.b_clearSmoothing()
        self.d_sendGolfSpotPos()
        taskMgr.remove(taskName)
        taskMgr.doMethodLater(self.__broadcastPeriod, self.__posHprBroadcast, taskName)

    def __posHprBroadcast(self, task):
        self.d_sendGolfSpotPos()
        taskName = self.posHprBroadcastName
        taskMgr.doMethodLater(self.__broadcastPeriod, self.__posHprBroadcast, taskName)
        return Task.done

    def d_sendGolfSpotPos(self):
        timestamp = globalClockDelta.getFrameNetworkTime()
        self.sendUpdate('setGolfSpotPos', [self.changeSeq, self.root.getH(), timestamp])

    def setGolfSpotPos(self, changeSeq, h, timestamp):
        self.changeSeq = changeSeq
        if self.smoothStarted:
            now = globalClock.getFrameTime()
            local = globalClockDelta.networkToLocalTime(timestamp, now)
            self.golfSpotSmoother.setH(h)
            self.golfSpotSmoother.setTimestamp(local)
            self.golfSpotSmoother.markPosition()
        else:
            self.root.setH(h)

    def b_clearSmoothing(self):
        self.d_clearSmoothing()
        self.clearSmoothing()

    def d_clearSmoothing(self):
        self.sendUpdate('clearSmoothing', [0])

    def clearSmoothing(self, bogus = None):
        self.golfSpotSmoother.clearPositions(1)

    def doSmoothTask(self, task):
        self.golfSpotSmoother.computeAndApplySmoothHpr(self.root)
        return Task.cont

    def startSmooth(self):
        if not self.smoothStarted:
            taskName = self.smoothName
            taskMgr.remove(taskName)
            self.reloadPosition()
            taskMgr.add(self.doSmoothTask, taskName)
            self.smoothStarted = 1

    def stopSmooth(self):
        if self.smoothStarted:
            taskName = self.smoothName
            taskMgr.remove(taskName)
            self.forceToTruePosition()
            self.smoothStarted = 0

    def makeToonReleaseInterval(self, toon):

        def getSlideToPos(toon = toon):
            return render.getRelativePoint(toon, Point3(0, -5, 0))

        if self.gotHitByBoss:
            grabIval = Sequence(Func(self.detachClub), name='makeToonReleaseInterval-gotHitByBoss')
            if not toon.isEmpty():
                toonIval = Sequence(Func(toon.wrtReparentTo, render), Parallel(ActorInterval(toon, 'slip-backward'), toon.posInterval(0.5, getSlideToPos, fluid=1)), name='makeToonReleaseInterval-toonIval')
                grabIval.append(toonIval)
        else:
            grabIval = Sequence(Func(self.detachClub))
            if not toon.isEmpty():
                toonIval = Sequence(Parallel(ActorInterval(toon, 'walk', duration=1.0, playRate=-1.0), LerpPosInterval(toon, duration=1.0, pos=Point3(-10, 0, 0))), Func(toon.wrtReparentTo, render))
                grabIval.append(toonIval)
        if localAvatar.doId == toon.doId:
            if not self.goingToReward and toon.hp > 0:
                grabIval.append(Func(self.goToFinalBattle))
                grabIval.append(Func(self.notify.debug, 'goingToFinalBattlemode'))
                grabIval.append(Func(self.safeBossToFinalBattleMode))
        return grabIval

    def safeBossToFinalBattleMode(self):
        if self.boss:
            self.boss.toFinalBattleMode()

    def goToFinalBattle(self):
        if self.cr:
            place = self.cr.playGame.getPlace()
            if place and hasattr(place, 'fsm'):
                curState = place.fsm.getCurrentState().getName()
                if place.fsm.getCurrentState().getName() == 'crane':
                    place.setState('finalBattle')
                else:
                    self.notify.debug('NOT going to final battle, state=%s' % curState)

    def attachClub(self, avId, pointToBall = False):
        club = self.club
        if club:
            av = base.cr.doId2do.get(avId)
            if av:
                av.useLOD(1000)
                lHand = av.getLeftHands()[0]
                club.setPos(0, 0, 0)
                club.reparentTo(lHand)
                netScale = club.getNetTransform().getScale()[1]
                counterActToonScale = lHand.find('**/counteractToonScale')
                if counterActToonScale.isEmpty():
                    counterActToonScale = lHand.attachNewNode('counteractToonScale')
                    counterActToonScale.setScale(1 / netScale)
                    self.notify.debug('creating counterActToonScale for %s' % av.getName())
                club.reparentTo(counterActToonScale)
                club.setX(-0.25 * netScale)
                if pointToBall:
                    club.lookAt(self.clubLookatSpot)

    def detachClub(self):
        if not self.club.isEmpty():
            self.club.reparentTo(self.root)
            self.club.setZ(-20)
            self.club.setScale(1)

    def adjustClub(self):
        club = self.club
        if club:
            distance = club.getDistance(self.clubLookatSpot)
            scaleFactor = distance / 2.058
            club.setScale(1, scaleFactor, 1)

    def startAdjustClubTask(self):
        taskMgr.add(self.adjustClubTask, self.adjustClubTaskName)

    def stopAdjustClubTask(self):
        taskMgr.remove(self.adjustClubTaskName)

    def adjustClubTask(self, task):
        self.attachClub(self.avId, True)
        self.adjustClub()
        return task.cont

    def enableControlKey(self):
        self.controlKeyAllowed = True

    def disableControlKey(self):
        self.controlKeyAllowed = False

    def sendSwingInfo(self, power, angle, sequenceNum):
        self.sendUpdate('setSwingInfo', [power, angle, sequenceNum])

    def startBallPlayback(self, power, angle, sequenceNum):
        flyBall = self.ballModel.copyTo(NodePath())
        flyBall.setScale(1.0)
        flyBallBubble = self.getFlyBallBubble().instanceTo(NodePath())
        flyBallBubble.reparentTo(flyBall)
        flyBall.setTag('pieSequence', str(sequenceNum))
        flyBall.setTag('throwerId', str(self.avId))
        t = power / 100.0
        t = 1.0 - t
        dist = 300 - 200 * t
        time = 1.5 + 0.5 * t
        proj = ProjectileInterval(None, startPos=Point3(0, 0, 0), endPos=Point3(0, dist, 0), duration=time)
        relVel = proj.startVel

        def getVelocity(root = self.root, relVel = relVel):
            return render.getRelativeVector(root, relVel)

        fly = Sequence(Func(flyBall.reparentTo, render), Func(flyBall.setPosHpr, self.root, 0, 0, 0, 0, 0, 0), Func(base.cTrav.addCollider, flyBallBubble, self.flyBallHandler), ProjectileInterval(flyBall, startVel=getVelocity, duration=3), Func(flyBall.detachNode), Func(base.cTrav.removeCollider, flyBallBubble), Func(self.notify.debug, 'removed collider'), Func(self.flyBallFinishedFlying, sequenceNum))
        flyWithSound = Parallel(fly, SoundInterval(self.hitBallSfx, node=self.root), name='flyWithSound')
        self.notify.debug('starting flyball track')
        flyWithSound.start()
        self.flyBallTracks[sequenceNum] = flyWithSound
        return

    def setSwingInfo(self, power, angle, sequenceNum):
        av = base.cr.doId2do.get(self.avId)
        self.swingInterval = Sequence()
        if av:
            self.stopAdjustClubTask()
            self.swingInterval = Sequence(ActorInterval(av, 'swing-putt', startFrame=0, endFrame=GolfGlobals.BALL_CONTACT_FRAME), Func(self.startBallPlayback, power, angle, sequenceNum), Func(self.ballModel.hide), ActorInterval(av, 'swing-putt', startFrame=GolfGlobals.BALL_CONTACT_FRAME, endFrame=24), Func(self.ballModel.setScale, 0.1), Func(self.ballModel.show), LerpScaleInterval(self.ballModel, 1.0, Point3(1, 1, 1)), Func(self.enableControlKey))
            if av == localAvatar:
                self.swingInterval.append(Func(self.switchToAnimState, 'GolfPuttLoop', True))
        self.swingInterval.start()

    def getFlyBallBubble(self):
        if self.__flyBallBubble == None:
            bubble = CollisionSphere(0, 0, 0, GolfGlobals.GOLF_BALL_RADIUS)
            node = CollisionNode('flyBallBubble')
            node.addSolid(bubble)
            node.setFromCollideMask(ToontownGlobals.PieBitmask | ToontownGlobals.CameraBitmask | ToontownGlobals.FloorBitmask)
            node.setIntoCollideMask(BitMask32.allOff())
            self.__flyBallBubble = NodePath(node)
            self.flyBallHandler = CollisionHandlerEvent()
            self.flyBallHandler.addInPattern('flyBallHit-%d' % self.index)
        return self.__flyBallBubble

    def __flyBallHit(self, entry):
        print entry

    def flyBallFinishedFlying(self, sequence):
        if self.flyBallTracks.has_key(sequence):
            del self.flyBallTracks[sequence]

    def __finishFlyBallTrack(self, sequence):
        if self.flyBallTracks.has_key(sequence):
            flyBallTrack = self.flyBallTracks[sequence]
            del self.flyBallTracks[sequence]
            flyBallTrack.finish()

    def flyBallFinishedSplatting(self, sequence):
        if self.splatTracks.has_key(sequence):
            del self.splatTracks[sequence]

    def __flyBallHit(self, entry):
        if not entry.hasSurfacePoint() or not entry.hasInto():
            return
        if not entry.getInto().isTangible():
            return
        sequence = int(entry.getFromNodePath().getNetTag('pieSequence'))
        self.__finishFlyBallTrack(sequence)
        if self.splatTracks.has_key(sequence):
            splatTrack = self.splatTracks[sequence]
            del self.splatTracks[sequence]
            splatTrack.finish()
        flyBallCode = 0
        flyBallCodeStr = entry.getIntoNodePath().getNetTag('pieCode')
        if flyBallCodeStr:
            flyBallCode = int(flyBallCodeStr)
        pos = entry.getSurfacePoint(render)
        timestamp32 = globalClockDelta.getFrameNetworkTime(bits=32)
        throwerId = int(entry.getFromNodePath().getNetTag('throwerId'))
        splat = self.getFlyBallSplatInterval(pos[0], pos[1], pos[2], flyBallCode, throwerId)
        splat = Sequence(splat, Func(self.flyBallFinishedSplatting, sequence))
        self.splatTracks[sequence] = splat
        splat.start()
        self.notify.debug('doId=%d into=%s flyBallCode=%d, throwerId=%d' % (self.doId,
         entry.getIntoNodePath(),
         flyBallCode,
         throwerId))
        if flyBallCode == ToontownGlobals.PieCodeBossCog and self.avId == localAvatar.doId and self.lastHitSequenceNum != self.__flyBallSequenceNum:
            self.lastHitSequenceNum = self.__flyBallSequenceNum
            self.boss.d_ballHitBoss(1)
        elif flyBallCode == ToontownGlobals.PieCodeToon and self.avId == localAvatar.doId and self.lastHitSequenceNum != self.__flyBallSequenceNum:
            self.lastHitSequenceNum = self.__flyBallSequenceNum
            avatarDoId = entry.getIntoNodePath().getNetTag('avatarDoId')
            if avatarDoId == '':
                self.notify.warning('Toon %s has no avatarDoId tag.' % repr(entry.getIntoNodePath()))
                return
            doId = int(avatarDoId)
            if doId != localAvatar.doId:
                pass

    def getFlyBallSplatInterval(self, x, y, z, flyBallCode, throwerId):
        from toontown.toonbase import ToontownBattleGlobals
        from toontown.battle import BattleProps
        splatName = 'dust'
        splat = BattleProps.globalPropPool.getProp(splatName)
        splat.setBillboardPointWorld(2)
        color = ToontownGlobals.PieCodeColors.get(flyBallCode)
        if color:
            splat.setColor(*color)
        if flyBallCode == ToontownGlobals.PieCodeBossCog:
            self.notify.debug('changing color to %s' % self.ballColor)
            splat.setColor(self.ballColor)
        sound = loader.loadSfx('phase_11/audio/sfx/LB_evidence_miss.ogg')
        vol = 1.0
        if flyBallCode == ToontownGlobals.PieCodeBossCog:
            sound = loader.loadSfx('phase_4/audio/sfx/Golf_Hit_Barrier_1.ogg')
        soundIval = SoundInterval(sound, node=splat, volume=vol)
        if flyBallCode == ToontownGlobals.PieCodeBossCog and localAvatar.doId == throwerId:
            vol = 1.0
            soundIval = SoundInterval(sound, node=localAvatar, volume=vol)
        ival = Parallel(Func(splat.reparentTo, render), Func(splat.setPos, x, y, z), soundIval, Sequence(ActorInterval(splat, splatName), Func(splat.detachNode)))
        return ival

    def setGoingToReward(self):
        self.goingToReward = True

    def gotBossZapped(self):
        self.showExiting()
        self.d_requestFree(True)
class ExperimentChallengeGUI(NodePath):
    def __init__(self, description, needed, icon):
        NodePath.__init__(self, 'objective-%s' % id(self))

        self.needed = needed
        self.visible = False

        self.fadeInTrack = None
        self.fadeOutTrack = None

        gui = loader.loadModel('phase_5/models/cogdominium/tt_m_gui_csa_flyThru')
        self.background = gui.find('**/*background').copyTo(self)
        self.background.setScale(2.5)
        gui.removeNode()

        self.icon = icon.copyTo(self.background)
        self.icon.setScale(0.08)
        self.icon.setPos(-0.167, 0, -0.002)

        text = TextNode('challenge')
        text.setText('Challenge')
        text.setFont(ToontownGlobals.getSignFont())
        text.setTextColor(0.95, 0.95, 0, 1)
        self.objText = self.background.attachNewNode(text)
        self.objText.setScale(0.03)
        self.objText.setPos(-0.04, 0.0, 0.02)

        text = TextNode('description')
        text.setText(description)
        text.setFont(ToontownGlobals.getSignFont())
        text.setTextColor(0.95, 0.95, 0, 1)
        text.setAlign(TextNode.ACenter)
        self.objText = self.background.attachNewNode(text)
        self.objText.setScale(0.015)
        self.objText.setPos(0.048, 0.0, -0.009)

        self.progressBar = DirectWaitBar(guiId='ChallengeProgressBar', parent=self.background, frameSize=(-0.11, 0.11, -0.007, 0.007), pos=(0.048, 0, -0.0338), text='')
        self.progressBar['range'] = needed

        self.progressText = DirectLabel(guiId='ChallengeProgressText', parent=self.progressBar, relief=None, pos=(0, 0, -0.0048), text='', textMayChange=1, text_scale=0.014, text_fg=(0.03, 0.83, 0, 1), text_align=TextNode.ACenter, text_font=ToontownGlobals.getSignFont())

        self.updateProgress(0)

        self.reparentTo(base.a2dBottomLeft)
        self.stash()

    def updateProgress(self, count):
        self.progressBar.update(count)
        self.progressText['text'] = '%s/%s' % (count, self.needed)

    def fadeIn(self):
        if self.fadeOutTrack:
            self.fadeOutTrack.finish()
            self.fadeOutTrack = None

        self.visible = True
        self.fadeInTrack = Sequence(Func(self.unstash),
                 Func(self.setTransparency, 1),
                 LerpColorScaleInterval(self, 1, Vec4(1, 1, 1, 1), startColorScale=Vec4(1, 1, 1, 0)),
                 Func(self.clearColorScale),
                 Func(self.clearTransparency))
        self.fadeInTrack.start()

    def fadeOut(self):
        if self.fadeInTrack:
            self.fadeInTrack.finish()
            self.fadeInTrack = None

        self.visible = False
        self.fadeOutTrack = Sequence(Func(self.setTransparency, 1),
                 LerpColorScaleInterval(self, 1, Vec4(1, 1, 1, 0), startColorScale=Vec4(1, 1, 1, 1)),
                 Func(self.clearColorScale),
                 Func(self.clearTransparency),
                 Func(self.stash))
        self.fadeOutTrack.start()

    def fadeOutDestroy(self):
        self.visible = False
        Sequence(Func(self.setTransparency, 1),
                 LerpColorScaleInterval(self, 1, Vec4(1, 1, 1, 0), startColorScale=Vec4(1, 1, 1, 1)),
                 Func(self.clearColorScale),
                 Func(self.clearTransparency),
                 Func(self.stash),
                 Func(self.destroy)).start()

    def destroy(self):
        self.removeNode()
class PartyCogActivityGui(DirectObject):
    notify = directNotify.newCategory('PartyCogActivityGui')

    def __init__(self):
        DirectObject.__init__(self)
        self._piePowerMeter = None
        self._victoryBalanceBar = None
        self._scoreLabel = None
        self._cogTracker = None
        self._piePowerTitle = None
        self._victoryBalanceTitle = None
        self._scoreTitle = None
        self._spamWarning = None
        self._spamWarningIvalName = 'PartyCogActivityGui-SpamWarning'

    def load(self):
        self._initPiePowerMeter()
        self._initScore()
        self._initCogTracker()
        self._initSpamWarning()
        self._initControlGui()
        self._initVictoryBalanceBar()

    def unload(self):
        if self._cogTracker is not None:
            self._cogTracker.destory()
            self._cogTracker = None
        if self._piePowerMeter is not None:
            self._piePowerMeter.destroy()
            self._piePowerMeter = None
        if self._piePowerTitle is not None:
            self._piePowerTitle.destroy()
            self._piePowerTitle = None
        if self._scoreLabel is not None:
            self._scoreLabel.destroy()
            self._scoreLabel = None
        if self._scoreTitle is not None:
            self._scoreTitle.destroy()
            self._scoreTitle = None
        taskMgr.remove(self._spamWarningIvalName)
        if self._spamWarning:
            self._spamWarning.destroy()
            self._spamWarning = None
        if hasattr(self, '_attackKeys'):
            self._attackKeys.detachNode()
            del self._attackKeys
        if hasattr(self, '_moveKeys'):
            self._moveKeys.detachNode()
            del self._moveKeys
        if self._victoryBalanceBar:
            self._victoryBalanceBar.detachNode()
            self._victoryBalanceBar = None
        if self._victoryBalanceBarOrange:
            self._victoryBalanceBarOrange.detachNode()
            self._victoryBalanceBarOrange = None
        if self._victoryBalanceBarPie:
            self._victoryBalanceBarPie.detachNode()
            self._victoryBalanceBarPie = None
        if self._victoryBalanceBarArrow:
            self._victoryBalanceBarArrow.detachNode()
            self._victoryBalanceBarArrow = None

    def _initVictoryBalanceBar(self):
        h = PartyGlobals.CogActivityPowerMeterHeight / 2.0
        w = PartyGlobals.CogActivityPowerMeterWidth / 2.0
        victoryBalanceBar = loader.loadModel('phase_13/models/parties/tt_m_gui_pty_pieToss_balanceBar')
        self._victoryBalanceBar = victoryBalanceBar.find('**/*tt_t_gui_pty_pieToss_balanceBarBG')
        self._victoryBalanceBar.reparentTo(aspect2d)
        self._victoryBalanceBar.setBin('fixed', 0)
        self._victoryBalanceBar.setPos(PartyGlobals.CogActivityVictoryBarPos)
        self._victoryBalanceBar.setScale(1)
        self._victoryBalanceBarOrange = victoryBalanceBar.find('**/*tt_t_gui_pty_pieToss_balanceBarOrange')
        self._victoryBalanceBarOrange.reparentTo(self._victoryBalanceBar)
        self._victoryBalanceBarOrange.setBin('fixed', 1)
        self._victoryBalanceBarOrange.setPos(PartyGlobals.CogActivityVictoryBarOrangePos)
        self._victoryBalanceBarOrange.setScale(PartyGlobals.CogActivityBarStartScale, 1.0, 1.0)
        self._victoryBalanceBarPie = victoryBalanceBar.find('**/*tt_t_gui_pty_pieToss_balanceBarPie')
        self._victoryBalanceBarPie.reparentTo(self._victoryBalanceBar)
        self._victoryBalanceBarPie.setBin('fixed', 2)
        self._victoryBalanceBarPie.setX(PartyGlobals.CogActivityVictoryBarPiePos[0])
        self._victoryBalanceBarPie.setY(PartyGlobals.CogActivityVictoryBarPiePos[1])
        self._victoryBalanceBarPie.setZ(PartyGlobals.CogActivityVictoryBarPiePos[2])
        self._victoryBalanceBarPie.setScale(PartyGlobals.CogActivityBarPieScale)
        self._victoryBalanceBarArrow = victoryBalanceBar.find('**/*tt_t_gui_pty_pieToss_balanceArrow')
        self._victoryBalanceBarArrow.reparentTo(self._victoryBalanceBarPie)
        self._victoryBalanceBarArrow.setBin('fixed', 2)
        self._victoryBalanceBarArrow.setPos(PartyGlobals.CogActivityVictoryBarArrow)
        self._victoryBalanceBarArrow.setScale(1 / PartyGlobals.CogActivityBarPieScale)

    def _initControlGui(self):
        self._attackIvalName = 'PartyCogActivityGui-attackKeys'
        self._moveIvalName = 'PartyCogActivityGui-moveKeys'
        pieTossControls = loader.loadModel('phase_13/models/parties/tt_m_gui_pty_pieToss_controls')
        self._attackKeys = pieTossControls.find('**/*control*')
        self._moveKeys = pieTossControls.find('**/*arrow*')
        self._moveKeys.reparentTo(aspect2d)
        self._moveKeys.setPos(1.0, 0.0, -0.435)
        self._moveKeys.setScale(0.15)
        self._attackKeys.reparentTo(aspect2d)
        self._attackKeys.setPos(0.85, 0.0, -0.45)
        self._attackKeys.setScale(0.15)
        self._moveKeys.hide()
        self._attackKeys.hide()

    def _initPiePowerMeter(self):
        h = PartyGlobals.CogActivityPowerMeterHeight / 2.0
        w = PartyGlobals.CogActivityPowerMeterWidth / 2.0
        self._piePowerMeter = DirectWaitBar(frameSize=(-h,
         h,
         -w,
         w), relief=DGG.GROOVE, frameColor=(0.9, 0.9, 0.9, 1.0), borderWidth=(0.01, 0.01), barColor=PartyGlobals.CogActivityColors[0], pos=PartyGlobals.CogActivityPowerMeterPos, hpr=(0.0, 0.0, -90.0))
        self._piePowerMeter.setBin('fixed', 0)
        self._piePowerTitle = OnscreenText(text=TTLocalizer.PartyCogGuiPowerLabel, pos=PartyGlobals.CogActivityPowerMeterTextPos, scale=0.05, fg=(1.0, 1.0, 1.0, 1.0), align=TextNode.ACenter)
        self._piePowerTitle.setBin('fixed', 0)
        self._piePowerMeter.hide()
        self._piePowerTitle.hide()

    def _initScore(self):
        self._scoreLabel = OnscreenText(text='0', pos=PartyGlobals.CogActivityScorePos, scale=PartyGlobals.TugOfWarTextWordScale, fg=(1.0, 1.0, 0.0, 1.0), align=TextNode.ARight, font=ToontownGlobals.getSignFont(), mayChange=True)
        self._scoreTitle = OnscreenText(text=TTLocalizer.PartyCogGuiScoreLabel, pos=PartyGlobals.CogActivityScoreTitle, scale=0.05, fg=(1.0, 1.0, 1.0, 1.0), align=TextNode.ARight)
        self._scoreLabel.hide()
        self._scoreTitle.hide()

    def _initCogTracker(self):
        self._cogTracker = PartyCogTrackerGui()

    def _initSpamWarning(self):
        self._spamWarning = OnscreenText(text=TTLocalizer.PartyCogGuiSpamWarning, scale=0.15, fg=(1.0, 1.0, 0, 1.0), shadow=(0, 0, 0, 0.62), mayChange=False, pos=(0, 0.33))
        self._spamWarning.hide()

    def showScore(self):
        self._scoreLabel.show()
        self._scoreTitle.show()

    def hideScore(self):
        self._scoreLabel.hide()
        self._scoreTitle.hide()

    def setScore(self, score = 0):
        self._scoreLabel['text'] = str(score)

    def resetPiePowerMeter(self):
        self._piePowerMeter['value'] = 0

    def showPiePowerMeter(self):
        self._piePowerMeter.show()
        self._piePowerTitle.show()

    def hidePiePowerMeter(self):
        self._piePowerMeter.hide()
        self._piePowerTitle.hide()

    def updatePiePowerMeter(self, value):
        self._piePowerMeter['value'] = value

    def getPiePowerMeterValue(self):
        return self._piePowerMeter['value']

    def hideSpamWarning(self):
        taskMgr.remove(self._spamWarningIvalName)
        if self._spamWarning:
            self._spamWarning.hide()

    def showSpamWarning(self):
        if self._spamWarning.isHidden():
            self._spamWarning.show()
            taskMgr.remove(self._spamWarningIvalName)
            Sequence(ToontownIntervals.getPulseLargerIval(self._spamWarning, ''), Wait(PartyGlobals.CogActivitySpamWarningShowTime), Func(self.hideSpamWarning), name=self._spamWarningIvalName, autoFinish=1).start()

    def hide(self):
        self.hidePiePowerMeter()
        self.hideScore()
        self.hideSpamWarning()
        self.hideControls()

    def disableToontownHUD(self):
        base.localAvatar.hideName()
        base.localAvatar.laffMeter.hide()
        base.setCellsAvailable(base.bottomCells + [base.rightCells[1]], False)

    def enableToontownHUD(self):
        base.localAvatar.showName()
        base.localAvatar.laffMeter.show()
        base.setCellsAvailable(base.bottomCells + [base.rightCells[1]], True)

    def setTeam(self, team):
        self.team = team
        if team == 0:
            self._cogTracker.frame.setR(180)
        self._piePowerMeter['barColor'] = PartyGlobals.CogActivityColors[team]

    def startTrackingCogs(self, cogs):
        self.cogs = cogs
        taskMgr.add(self.trackCogs, 'trackCogs')

    def trackCogs(self, task):
        if self.cogs is None:
            return
        self._updateVictoryBar()
        for i, cog in enumerate(self.cogs):
            self._cogTracker.updateCog(i, cog, self.team)

        return task.cont

    def _updateVictoryBar(self):
        if not (hasattr(self, '_victoryBalanceBar') and self._victoryBalanceBar):
            return
        netDistance = 0
        for cog in self.cogs:
            netDistance = netDistance + cog.targetDistance

        teamDistance = netDistance / 6.0
        self._victoryBalanceBarOrange.setScale(PartyGlobals.CogActivityBarStartScale + teamDistance * 10 * PartyGlobals.CogActivityBarUnitScale, 1.0, 1.0)
        self._victoryBalanceBarPie.setX(PartyGlobals.CogActivityVictoryBarPiePos[0] + teamDistance * 10 * PartyGlobals.CogActivityBarPieUnitMove)
        self._victoryBalanceBarPie.setY(PartyGlobals.CogActivityVictoryBarPiePos[1])
        self._victoryBalanceBarPie.setZ(PartyGlobals.CogActivityVictoryBarPiePos[2])
        if teamDistance > 0.0:
            self._victoryBalanceBarArrow.setColor(PartyGlobals.CogActivityColors[1])
        elif teamDistance < 0.0:
            self._victoryBalanceBarArrow.setColor(PartyGlobals.CogActivityColors[0])
        else:
            self._victoryBalanceBarArrow.setColor(VBase4(1.0, 1.0, 1.0, 1.0))

    def stopTrackingCogs(self):
        taskMgr.remove('trackCogs')

    def showAttackControls(self):
        if self._attackKeys.isHidden():
            self._attackKeys.show()
            taskMgr.remove(self._attackIvalName)
            Sequence(ToontownIntervals.getPulseLargerIval(self._attackKeys, '', scale=0.15), Wait(PartyGlobals.CogActivityControlsShowTime), Func(self.hideAttackControls), name=self._attackIvalName, autoFinish=1).start()

    def showMoveControls(self):
        if self._moveKeys.isHidden() and not self._attackKeys.isHidden():
            self._moveKeys.show()
            taskMgr.remove(self._moveIvalName)
            Sequence(ToontownIntervals.getPulseLargerIval(self._moveKeys, '', scale=0.15), Wait(PartyGlobals.CogActivityControlsShowTime), Func(self.hideMoveControls), name=self._moveIvalName, autoFinish=1).start()

    def hideAttackControls(self):
        taskMgr.remove(self._attackIvalName)
        if hasattr(self, '_attackKeys') and self._attackKeys:
            self._attackKeys.hide()

    def hideMoveControls(self):
        taskMgr.remove(self._moveIvalName)
        if hasattr(self, '_moveKeys') and self._moveKeys:
            self._moveKeys.hide()

    def hideControls(self):
        self.hideMoveControls()
        self.hideAttackControls()
Пример #56
0
 def __init__(self, barColor=(255,0,0,1), pos=(1.0,0,0.9)): 
     self.bar = DirectWaitBar(pos = pos, barColor = barColor, text="",
     value=70, range=100, frameSize=(-0.3,0.3,0,0.03), frameColor=(0,0,255,1))
Пример #57
0
 def createInterface(self):
     self.cogProgressBar = DirectWaitBar(pos=(0, 0, -0.9), relief=DGG.RAISED, scale=0.6, frameColor=(1, 0.5, 0.3, 0.75), barColor=(1, 0.25, 0.25, 0.5), value=0, range=self.getTotalCogs(), text='', text_scale=0.08)
     self.__updateProgressBar()