예제 #1
0
 def showExitCheckDialog(self):
     dialogText = PLocalizer.FishingGui['AreYouSure']
     self.OkDialog = PDialog(text=dialogText,
                             style=OTPDialog.Acknowledge,
                             giveMouse=False,
                             command=self.closeDialogGotoPlayerIdle)
     self.OkDialog.setPos(0.80000000000000004, 0.0, 0.5)
 def __init__(self, parent = None, type = PiratesGuiGlobals.REWARD_PANEL_BLACK_PEARL, doneCallback = None, **kw):
     optiondefs = (('pad', (0.55000000000000004, 0.47499999999999998), self.resetFrameSize), ('pos', (0.40000000000000002, 0, 0), None))
     self.defineoptions(kw, optiondefs)
     PDialog.__init__(self, parent)
     self.type = type
     if doneCallback:
         self.doneCallback = doneCallback
     else:
         self.doneCallback = self.cleanup
     self.showWeaponsTrack = None
     skillIcons = loader.loadModel('models/textureCards/skillIcons')
     weaponIcons = loader.loadModel('models/gui/gui_icons_weapon')
     isWeapon = TextDict[type]['isWeapon']
     if isWeapon:
         background = skillIcons.find('**/box_base_over')
         background.setTransparency(0.5)
         icon = weaponIcons.find('**/' + TextDict[type]['icon'])
         icon.setScale(0.75)
     else:
         background = skillIcons.find('**/base_over')
         icon = skillIcons.find('**/' + TextDict[type]['icon'])
     icon.reparentTo(background)
     self.congratsText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, textMayChange = 1, text = PLocalizer.RewardCongratulations, text_font = PiratesGlobals.getInterfaceOutlineFont(), text_align = TextNode.ACenter, text_scale = 0.12, text_fg = PiratesGuiGlobals.TextFG1, pos = (0.0, 0, 0.34000000000000002))
     self.completeText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, textMayChange = 1, text = TextDict[type]['title'], text_font = PiratesGlobals.getInterfaceOutlineFont(), text_align = TextNode.ACenter, text_scale = 0.050000000000000003, text_fg = PiratesGuiGlobals.TextFG2, pos = (0, 0, 0.26000000000000001))
     self.iconLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, geom = background, geom_scale = 0.29999999999999999, text = TextDict[type]['summary'], text_font = PiratesGlobals.getInterfaceFont(), text_align = TextNode.ACenter, text_scale = 0.040000000000000001, text_fg = PiratesGuiGlobals.TextFG1, text_pos = (0, 0.20000000000000001), pos = (0, 0, -0.029999999999999999))
     self.descriptionText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, textMayChange = 1, text = TextDict[type]['description'], text_font = PiratesGlobals.getInterfaceFont(), text_align = TextNode.ACenter, text_scale = 0.037999999999999999, text_fg = PiratesGuiGlobals.TextFG1, pos = (0, 0, -0.26000000000000001))
     self.nextButton = GuiButton.GuiButton(parent = self, state = DGG.NORMAL, text = PLocalizer.lOk, textMayChange = 1, text_scale = PiratesGuiGlobals.TextScaleMed, text_pos = (0, -0.01), pos = (0, 0, -0.5), command = self.doneCallback)
     self.borderFrame['borderScale'] = 1
     self.setupCustomReward()
     self.initialiseoptions(RewardPanel)
     self.setScale(1.25)
예제 #3
0
 def __init__(self):
     self.resetImages()
     imageFrame = PDialog(parent=aspect2dp, pos=(0, 0, 0.1), image_scale=(1.3 * 4 / 3.0, 1, 1.3), fadeScreen=0.85, scale=1.1)
     imageFrame.hide()
     imX = 0.85
     imY = imX * 3 / 4.0
     self.imageObj = OnscreenImage(parent=imageFrame, image=self.screens[0], scale=(imX, 1, imY), pos=(0, 0, -0.025))
     self.imageLabel = DirectLabel(parent=imageFrame, relief=None, state=DGG.DISABLED, pos=(0,
                                                                                            0,
                                                                                            -0.75), textMayChange=1, text_fg=(0.6,
                                                                                                                              0.6,
                                                                                                                              0.6,
                                                                                                                              1), text_scale=0.04)
     self.imageLabel.hide()
     topGui = loader.loadModel('models/gui/toplevel_gui')
     arrow = topGui.find('**/generic_arrow')
     buttons = loader.loadModel('models/gui/lookout_gui')
     closeButton = (buttons.find('**/lookout_close_window'), buttons.find('**/lookout_close_window_down'), buttons.find('**/lookout_close_window_over'))
     xs = 1.2
     self.nextButton = DirectButton(parent=imageFrame, relief=None, command=self.next, pos=(0.7,
                                                                                            0,
                                                                                            0), image=arrow, image_scale=(-xs, xs, xs), sortOrder=-5)
     self.prevButton = DirectButton(parent=imageFrame, relief=None, command=self.prev, pos=(-0.7,
                                                                                            0,
                                                                                            0), image=arrow, image_scale=xs, sortOrder=-5)
     self.closeButton = DirectButton(parent=imageFrame, relief=None, command=self.close, pos=(0.78,
                                                                                              0,
                                                                                              -0.5), image=closeButton, image_scale=0.3, text=PLocalizer.lClose, text_fg=PiratesGuiGlobals.TextFG1, text_scale=0.05, text_pos=(0,
                                                                                                                                                                                                                               -0.1), sortOrder=-5)
     self.showIval = Sequence(Func(imageFrame.show), Wait(1), Parallel(LerpPosInterval(self.closeButton, 0.2, Vec3(0.78, 0, -0.8), Vec3(0.78, 0, -0.5)), LerpPosInterval(self.nextButton, 0.2, Vec3(1, 0, 0), Vec3(0.7, 0, 0)), LerpPosInterval(self.prevButton, 0.2, Vec3(-1, 0, 0), Vec3(-0.7, 0, 0))), Func(self.imageLabel.show))
     self.imageFrame = imageFrame
     base.transitions.fadeScreen(0.85)
     return
예제 #4
0
 def __init__(self, parent = None, type = PiratesGuiGlobals.REWARD_PANEL_BLACK_PEARL, doneCallback = None, **kw):
     optiondefs = (('pad', (0.55000000000000004, 0.47499999999999998), self.resetFrameSize), ('pos', (0.40000000000000002, 0, 0), None))
     self.defineoptions(kw, optiondefs)
     PDialog.__init__(self, parent)
     self.type = type
     if doneCallback:
         self.doneCallback = doneCallback
     else:
         self.doneCallback = self.cleanup
     self.showWeaponsTrack = None
     skillIcons = loader.loadModel('models/textureCards/skillIcons')
     weaponIcons = loader.loadModel('models/gui/gui_icons_weapon')
     isWeapon = TextDict[type]['isWeapon']
     if isWeapon:
         background = skillIcons.find('**/box_base_over')
         background.setTransparency(0.5)
         icon = weaponIcons.find('**/' + TextDict[type]['icon'])
         icon.setScale(0.75)
     else:
         background = skillIcons.find('**/base_over')
         icon = skillIcons.find('**/' + TextDict[type]['icon'])
     icon.reparentTo(background)
     self.congratsText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, textMayChange = 1, text = PLocalizer.RewardCongratulations, text_font = PiratesGlobals.getInterfaceOutlineFont(), text_align = TextNode.ACenter, text_scale = 0.12, text_fg = PiratesGuiGlobals.TextFG1, pos = (0.0, 0, 0.34000000000000002))
     self.completeText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, textMayChange = 1, text = TextDict[type]['title'], text_font = PiratesGlobals.getInterfaceOutlineFont(), text_align = TextNode.ACenter, text_scale = 0.050000000000000003, text_fg = PiratesGuiGlobals.TextFG2, pos = (0, 0, 0.26000000000000001))
     self.iconLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, geom = background, geom_scale = 0.29999999999999999, text = TextDict[type]['summary'], text_font = PiratesGlobals.getInterfaceFont(), text_align = TextNode.ACenter, text_scale = 0.040000000000000001, text_fg = PiratesGuiGlobals.TextFG1, text_pos = (0, 0.20000000000000001), pos = (0, 0, -0.029999999999999999))
     self.descriptionText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, textMayChange = 1, text = TextDict[type]['description'], text_font = PiratesGlobals.getInterfaceFont(), text_align = TextNode.ACenter, text_scale = 0.037999999999999999, text_fg = PiratesGuiGlobals.TextFG1, pos = (0, 0, -0.26000000000000001))
     self.nextButton = GuiButton.GuiButton(parent = self, state = DGG.NORMAL, text = PLocalizer.lOk, textMayChange = 1, text_scale = PiratesGuiGlobals.TextScaleMed, text_pos = (0, -0.01), pos = (0, 0, -0.5), command = self.doneCallback)
     self.borderFrame['borderScale'] = 1
     self.setupCustomReward()
     self.initialiseoptions(RewardPanel)
     self.setScale(1.25)
예제 #5
0
 def showExitDialog(self):
     if self._DefenseCannonGUI__dialog == None:
         self._DefenseCannonGUI__dialog = PDialog(
             text=PLocalizer.CannonDefense['ExitCannon'],
             style=OTPDialog.YesNo,
             giveMouse=False,
             command=self._DefenseCannonGUI__onDialogItemSelected)
     else:
         self._DefenseCannonGUI__dialog.cleanup()
         self._DefenseCannonGUI__dialog = None
 def handleEndInteractKey(self):
     if self.fishingGame and not self.fishingGame.gui.resultsScreen.isHidden() or localAvatar.guiMgr.inventoryUIManager.hasPlunder():
         return
     if not self.fishingGame:
         return
     if self.__dialog == None:
         self.__dialog = PDialog(text=PLocalizer.FishingGui['ExitText'], style=OTPDialog.YesNo, giveMouse=False, command=self.__onDialogItemSelected)
     else:
         self.__dialog.cleanup()
         self.__dialog = None
     return
 def handleEndInteractKey(self):
     if self.fishingGame or not self.fishingGame.gui.resultsScreen.isHidden() or localAvatar.guiMgr.inventoryUIManager.hasPlunder():
         return None
     
     if self._DistributedFishingSpot__dialog == None:
         self._DistributedFishingSpot__dialog = PDialog(text = PLocalizer.FishingGui['ExitText'], style = OTPDialog.YesNo, giveMouse = False, command = self._DistributedFishingSpot__onDialogItemSelected)
     else:
         self._DistributedFishingSpot__dialog.cleanup()
         self._DistributedFishingSpot__dialog = None
 def __init__(self):
     self.resetImages()
     imageFrame = PDialog(parent = aspect2dp, pos = (0, 0, 0.10000000000000001), image_scale = (1.3 * 4 / 3.0, 1, 1.3), fadeScreen = 0.84999999999999998, scale = 1.1000000000000001)
     imageFrame.hide()
     imX = 0.84999999999999998
     imY = imX * 3 / 4.0
     self.imageObj = OnscreenImage(parent = imageFrame, image = self.screens[0], scale = (imX, 1, imY), pos = (0, 0, -0.025000000000000001))
     self.imageLabel = DirectLabel(parent = imageFrame, relief = None, state = DGG.DISABLED, pos = (0, 0, -0.75), textMayChange = 1, text_fg = (0.59999999999999998, 0.59999999999999998, 0.59999999999999998, 1), text_scale = 0.040000000000000001)
     self.imageLabel.hide()
     topGui = loader.loadModel('models/gui/toplevel_gui')
     arrow = topGui.find('**/generic_arrow')
     buttons = loader.loadModel('models/gui/lookout_gui')
     closeButton = (buttons.find('**/lookout_close_window'), buttons.find('**/lookout_close_window_down'), buttons.find('**/lookout_close_window_over'))
     xs = 1.2
     self.nextButton = DirectButton(parent = imageFrame, relief = None, command = self.next, pos = (0.69999999999999996, 0, 0), image = arrow, image_scale = (-xs, xs, xs), sortOrder = -5)
     self.prevButton = DirectButton(parent = imageFrame, relief = None, command = self.prev, pos = (-0.69999999999999996, 0, 0), image = arrow, image_scale = xs, sortOrder = -5)
     self.closeButton = DirectButton(parent = imageFrame, relief = None, command = self.close, pos = (0.78000000000000003, 0, -0.5), image = closeButton, image_scale = 0.29999999999999999, text = PLocalizer.lClose, text_fg = PiratesGuiGlobals.TextFG1, text_scale = 0.050000000000000003, text_pos = (0, -0.10000000000000001), sortOrder = -5)
     self.showIval = Sequence(Func(imageFrame.show), Wait(1), Parallel(LerpPosInterval(self.closeButton, 0.20000000000000001, Vec3(0.78000000000000003, 0, -0.80000000000000004), Vec3(0.78000000000000003, 0, -0.5)), LerpPosInterval(self.nextButton, 0.20000000000000001, Vec3(1, 0, 0), Vec3(0.69999999999999996, 0, 0)), LerpPosInterval(self.prevButton, 0.20000000000000001, Vec3(-1, 0, 0), Vec3(-0.69999999999999996, 0, 0))), Func(self.imageLabel.show))
     self.imageFrame = imageFrame
     base.transitions.fadeScreen(0.84999999999999998)
예제 #9
0
class DefenseCannonGUI(CannonGUI):
    notify = DirectNotifyGlobal.directNotify.newCategory('DefenseCannonGUI')

    def __init__(self, cannon):
        CannonGUI.__init__(self, cannon)
        self.exitEvent = None
        self.__dialog = None
        self.helpButton = None
        self.helpUI = None
        self.flashHelp = None
        self.ammoFade = None
        self.__ammoCountersHidden = False
        self.setupExtraButtons()
        self.exitCannon['command'] = self.showExitDialog
        self.volleyLabel.setPos(-0.28, 0, 0.09)
        self.reloadBar.setPos(-0.13, 0, 0.08)
        self.ammoImage.setPos(-0.38, 0, 0.06)
        self.repMeter = ReputationMeter(InventoryType.DefenseCannonRep,
                                        width=0.7)
        self.repMeter.reparentTo(base.a2dBottomCenter)
        self.repMeter.setPos(0.0, 0.0, 0.025)
        self.hud = CannonDefenseHUD()
        self.hud.create()
        self._exp = 0
        self.lastLevel = 1
        self.accept('incDefenseCannonExp', self.increaseExp)
        if __dev__:
            base.dcg = self
        return

    def destroy(self):
        if self.ammoFade:
            self.ammoFade.finish()
            self.ammoFade = None
        if self.flashHelp:
            self.flashHelp.finish()
            self.flashHelp = None
        if self.helpButton:
            self.helpButton.destroy()
            self.helpButton = None
        if self.helpUI:
            self.helpUI.destroy()
            self.helpUI = None
        if self.hud:
            self.hud.destroy()
            self.hud = None
        base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_MINIGAME_CANNON)
        self.repMeter.destroy()
        self.ignore('incDefenseCannonExp')
        CannonGUI.destroy(self)
        return

    def setupExtraButtons(self):
        weaponIcons = loader.loadModel('models/gui/gui_icons_weapon')
        self.helpButton = DirectButton(
            parent=base.a2dBottomRight,
            relief=None,
            pos=(-0.6, 0, 0.09),
            scale=0.5,
            text='?',
            text_pos=(0, -0.055),
            text_scale=0.21,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            sortOrder=2,
            command=self.toggleHelpUI)
        DirectLabel(parent=self.helpButton,
                    text=PLocalizer.CannonDefense['Help'],
                    text_pos=(0, -0.15),
                    text_scale=0.08,
                    text_fg=PiratesGuiGlobals.TextFG2,
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    text_font=PiratesGlobals.getPirateBoldOutlineFont(),
                    frameColor=(1, 1, 1, 0))
        return

    def increaseExp(self, amt, total):
        self._exp += amt
        if self._exp > total:
            return
        level, leftoverValue = ReputationGlobals.getLevelFromTotalReputation(
            InventoryType.DefenseCannonRep, self._exp)
        self.repMeter.update(self._exp)
        if level > self.lastLevel:
            base.localAvatar.levelUpMsg(InventoryType.DefenseCannonRep, level,
                                        0)
            self.lastLevel = level

    def toggleHelpUI(self):
        if self.helpUI == None:
            self.__createHelpUI()
            self.fadeOutAmmoCounters()
            if self.cannon.ammoPanel.state == pirates.minigame.AmmoPanel.CLOSED:
                self.cannon.ammoPanel.onTabClick()
        else:
            self.__destroyHelpUI()
            self.fadeInAmmoCounters()
            if self.cannon.ammoPanel.state == pirates.minigame.AmmoPanel.OPENED:
                self.cannon.ammoPanel.onTabClick()
        return

    def __createHelpUI(self):
        self.helpUI = CannonDefenseHelpManager(0.5)
        self.helpUI.exit.reparentTo(self.exitCannon)
        self.helpUI.exit.setScale(2.0)
        self.helpUI.help.reparentTo(self.helpButton)
        self.helpUI.help.setScale(2.0)
        self.helpUI.ammoPanel.reparentTo(self.cannon.ammoPanel.panel)
        self.helpUI.ammoPanel.setScale(1.0 / 3.0)
        self.helpUI.ammo.reparentTo(base.a2dBottomCenter)
        self.helpUI.mine.reparentTo(self.hud.goldRemainingUI.mineCounter)
        self.helpUI.mine.setScale(2.0 / 3.0)
        self.helpUI.wave.reparentTo(self.hud.timeRemainingUI.timeRemaining)
        self.helpUI.wave.setScale(1.0 / 0.75)
        self.helpUI.fadeIn.start()

    def __destroyHelpUI(self):
        cleanup = Sequence(Func(self.helpUI.fadeIn.pause),
                           self.helpUI.fadeOut,
                           Func(self.helpUI.destroy),
                           name=self.cannon.uniqueName('HelpUI_FadeIn'))
        cleanup.start()
        self.helpUI = None
        return

    def isHelpUIVisible(self):
        return self.helpUI != None

    def flashHelpButton(self, delay=0.2, length=5):
        if self.flashHelp:
            self.flashHelp.finish()
            self.flashHelp = None
        self.flashHelp = Sequence(
            name=self.cannon.uniqueName('HelpButton_Flash'))

        def setColor(key, value):
            self.helpButton[key] = value

        for i in range(0, length):
            self.flashHelp.append(Wait(delay))
            self.flashHelp.append(
                Func(setColor, 'text_fg', PiratesGuiGlobals.TextFG19))
            self.flashHelp.append(Wait(delay))
            self.flashHelp.append(
                Func(setColor, 'text_fg', PiratesGuiGlobals.TextFG2))

        self.flashHelp.start()
        return

    def fadeOutAmmoCounters(self, length=0.5):
        if self.__ammoCountersHidden:
            return
        transparent = Vec4(1, 1, 1, 0)
        if self.ammoFade:
            self.ammoFade.finish()
        self.ammoFade = Parallel(
            self.volleyLabel.colorScaleInterval(length, transparent),
            self.reloadBar.colorScaleInterval(length, transparent),
            self.ammoImage.colorScaleInterval(length, transparent))
        self.ammoFade.start()
        self.__ammoCountersHidden = True

    def fadeInAmmoCounters(self, length=0.5):
        if self.__ammoCountersHidden == False:
            return
        opaque = Vec4(1, 1, 1, 1)
        transparent = Vec4(1, 1, 1, 0)
        if self.ammoFade:
            self.ammoFade.finish()
        self.ammoFade = Parallel(
            self.volleyLabel.colorScaleInterval(length, opaque, transparent),
            self.reloadBar.colorScaleInterval(length, opaque, transparent),
            self.ammoImage.colorScaleInterval(length, opaque, transparent))
        self.ammoFade.start()
        self.__ammoCountersHidden = False

    def showExitDialog(self):
        if self.__dialog == None:
            self.__dialog = PDialog(
                text=PLocalizer.CannonDefense['ExitCannon'],
                style=OTPDialog.YesNo,
                giveMouse=False,
                command=self.__onDialogItemSelected)
        else:
            self.__dialog.cleanup()
            self.__dialog = None
        return

    def __onDialogItemSelected(self, value):
        if value == 1:
            if self.exitEvent:
                self.exitEvent()
        self.__dialog.cleanup()
        self.__dialog = None
        return
예제 #10
0
 def destroy(self):
     if self.showWeaponsTrack:
         self.showWeaponsTrack.pause()
         self.showWeaponsTrack = None
     PDialog.destroy(self)
     return
class FishingGameGUI:
    
    def __init__(self, gameObject = None):
        base.loadingScreen.beginStep('GameGUI', 3, 20)
        self.gameObject = gameObject
        gui = loader.loadModel('models/gui/toplevel_gui')
        guiIcons = loader.loadModel('models/textureCards/icons')
        weaponIcons = loader.loadModel('models/gui/gui_icons_weapon')
        fishingIcons = loader.loadModel('models/textureCards/fishing_icons')
        self.tackleBoxButton = DirectButton(parent = base.a2dBottomRight, relief = None, pos = (-0.53000000000000003, 0.0, 0.10000000000000001), scale = 0.5, text = PLocalizer.FishingGui['Lures'], text_pos = (0, -0.14999999999999999), text_scale = 0.065000000000000002, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateBoldOutlineFont(), image_pos = (0, 0, 0), image_scale = 0.17999999999999999, geom = (fishingIcons.find('**/pir_t_gui_fsh_tackleBasket'), fishingIcons.find('**/pir_t_gui_fsh_tackleBasket'), fishingIcons.find('**/pir_t_gui_fsh_tackleBasket_over')), geom_pos = (0, 0, 0), geom_scale = 0.25, geom_color = (1.0, 1.0, 1.0, 1), sortOrder = 2, command = self.toggleLureSelectionDialog)
        self.tackleBoxInterval = Sequence(self.tackleBoxButton.colorScaleInterval(0.5, Vec4(1.0, 0.59999999999999998, 0.59999999999999998, 1.0)), self.tackleBoxButton.colorScaleInterval(0.5, Vec4(1.0, 1.0, 1.0, 1.0)))
        self.exitButton = DirectButton(parent = base.a2dBottomRight, relief = None, pos = (-0.29999999999999999, 0.0, 0.10000000000000001), scale = 0.5, text = PLocalizer.FishingGui['ExitButton'], text_pos = (0, -0.14999999999999999), text_scale = 0.065000000000000002, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateBoldOutlineFont(), image_pos = (0, 0, 0), image_scale = 0.17999999999999999, geom = (fishingIcons.find('**/pir_t_gui_fsh_esc'), fishingIcons.find('**/pir_t_gui_fsh_esc'), fishingIcons.find('**/pir_t_gui_fsh_esc_over')), geom_pos = (0, 0, 0), geom_scale = 0.25, geom_color = (1.0, 1.0, 1.0, 1), sortOrder = 2, command = self.handleExitGame)
        self.OkDialog = None
        base.loadingScreen.tick()
        dialogText = PLocalizer.FishingGui['ChooseYourLure']
        self.lureSelectionPanel = GuiPanel.GuiPanel(dialogText, 0.75, 0.5, True, 1)
        self.lureSelectionPanel.reparentTo(base.a2dBottomRight)
        self.lureSelectionPanel.setPos(-0.90000000000000002, 0.0, 0.22)
        self.lureSelectionPanel.regularLureButton = DirectButton(parent = self.lureSelectionPanel, relief = None, pos = (0.20000000000000001, 0, 0.25), scale = 0.5, text = '', text_pos = (0, 0), text_scale = PiratesGuiGlobals.TextScaleSmall, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateBoldOutlineFont(), image = fishingIcons.find('**/pir_t_gui_fsh_lureReg'), image_pos = (0, 0, 0), image_scale = 0.17999999999999999, geom = (gui.find('**/pir_t_gui_but_circle'), gui.find('**/pir_t_gui_but_circle'), gui.find('**/pir_t_gui_but_circle_over')), geom_pos = (0, 0, 0), geom_scale = 1, geom_hpr = (0, 0, 90), geom_color = (1.0, 1.0, 1.0, 1), sortOrder = 2, command = self.chooseRegularLure)
        self.lureSelectionPanel.regularLureButtonText = DirectLabel(parent = self.lureSelectionPanel, relief = None, text = PLocalizer.FishingGui['RegularLures'], text_align = TextNode.ARight, text_scale = PiratesGuiGlobals.TextScaleSmall, text_pos = (0.28000000000000003, 0.14999999999999999), text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateBoldOutlineFont(), textMayChange = 1)
        base.loadingScreen.tick()
        inv = localAvatar.getInventory()
        regQty = inv.getStackQuantity(InventoryType.RegularLure)
        self.lureSelectionPanel.regularLureQty = DirectLabel(parent = self.lureSelectionPanel, relief = None, text = 'x' + str(regQty), text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleSmall, text_pos = (0.29999999999999999, 0.20000000000000001), text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateBoldOutlineFont(), textMayChange = 1)
        self.lureSelectionPanel.legendaryLureButton = DirectButton(parent = self.lureSelectionPanel, relief = None, pos = (0.55000000000000004, 0.0, 0.25), scale = 0.5, text = '', text_pos = (0, 0), text_scale = PiratesGuiGlobals.TextScaleSmall, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateBoldOutlineFont(), image = fishingIcons.find('**/pir_t_gui_fsh_lureLegend'), image_pos = (0, 0, 0), image_scale = 0.17999999999999999, geom = (gui.find('**/pir_t_gui_but_circle'), gui.find('**/pir_t_gui_but_circle'), gui.find('**/pir_t_gui_but_circle_over')), geom_pos = (0, 0, 0), geom_scale = 1, geom_hpr = (0, 0, 90), geom_color = (1.0, 1.0, 1.0, 1), sortOrder = 2, command = self.chooseLegendaryLure)
        self.lureSelectionPanel.legendaryLureButtonText = DirectLabel(parent = self.lureSelectionPanel, relief = None, text = PLocalizer.FishingGui['LegendaryLures'], text_align = TextNode.ARight, text_scale = PiratesGuiGlobals.TextScaleSmall, text_pos = (0.65000000000000002, 0.14999999999999999), text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateBoldOutlineFont(), textMayChange = 1)
        inv = localAvatar.getInventory()
        legQty = inv.getStackQuantity(InventoryType.LegendaryLure)
        self.lureSelectionPanel.legendaryLureQty = DirectLabel(parent = self.lureSelectionPanel, relief = None, text = 'x' + str(legQty), text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleSmall, text_pos = (0.66000000000000003, 0.20000000000000001), text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateBoldOutlineFont(), textMayChange = 1)
        self.lureSelectionPanel.hide()
        self.lureSelectionPanelShowing = False
        self.resultsScreen = FishingResults(self.gameObject)
        self.resultsScreen.hide()
        bestRod = self.gameObject.getAvatarsBestRod()
        if bestRod == -1:
            base.notify.error('Somehow the avatar got into the fishing game without a rod in their inventory!')
        
        if bestRod == ItemGlobals.FISHING_ROD_3:
            self.castPowerMeterModel = loader.loadModel('models/gui/pir_m_gui_fsh_fishingBarExpert')
        elif bestRod == ItemGlobals.FISHING_ROD_2:
            self.castPowerMeterModel = loader.loadModel('models/gui/pir_m_gui_fsh_fishingBarNovice')
        else:
            self.castPowerMeterModel = loader.loadModel('models/gui/pir_m_gui_fsh_fishingBarBeginner')
        base.loadingScreen.tick()
        self.castPowerMeter = NodePath('castPowerMeter')
        self.castPowerMeter.reparentTo(base.a2dLeftCenter)
        self.castMeterBackground = self.castPowerMeterModel.find('**/background')
        self.castMeterBackground.setBin('fixed', 32)
        self.castMeterBackground.reparentTo(self.castPowerMeter)
        self.castMeterBar = self.castPowerMeterModel.find('**/meter')
        self.castMeterBar.setBin('fixed', 33)
        self.castMeterBar.reparentTo(self.castPowerMeter)
        self.castMeterBar.setColorScale(0.5, 0.5, 1.0, 1.0)
        self.castMeterFrame = self.castPowerMeterModel.find('**/bar')
        self.castMeterFrame.setBin('fixed', 34)
        self.castMeterFrame.reparentTo(self.castPowerMeter)
        self.castPowerMeter.setPos(0.13700000000000001, 0, 0.22800000000000001)
        self.castPowerMeter.setScale(1)
        self.lineHealthMeter = NodePath('lineHealthMeter')
        self.lineHealthMeter.reparentTo(base.a2dLeftCenter)
        self.lineHealthMeterModel = loader.loadModel('models/gui/pir_m_gui_fsh_fishingBarHealth')
        self.lineHealthMeterBackground = self.lineHealthMeterModel.find('**/background')
        self.lineHealthMeterBackground.setBin('fixed', 32)
        self.lineHealthMeterBackground.reparentTo(self.lineHealthMeter)
        self.lineHealthMeterBar = self.lineHealthMeterModel.find('**/meter')
        self.lineHealthMeterBar.setBin('fixed', 33)
        self.lineHealthMeterBar.reparentTo(self.lineHealthMeter)
        self.lineHealthMeterFrame = self.lineHealthMeterModel.find('**/bar')
        self.lineHealthMeterFrame.setBin('fixed', 34)
        self.lineHealthMeterFrame.reparentTo(self.lineHealthMeter)
        self.lineHealthMeter.setPos(0.13700000000000001, 0, 0.25)
        self.lineHealthMeter.setScale(1)
        self.lineLengthLabel = TextPrinter()
        self.lineLengthLabel.text.setScale(1.2)
        self.lineLengthLabel.text.setHpr(0.0, 0.0, 0.0)
        self.lineLengthLabel.text['sortOrder'] = 200
        self.lineLengthLabel.text.setBin('gui-fixed', 10)
        self.lineLengthLabel.text.setDepthTest(0)
        self.lineLengthLabel.text.setDepthWrite(0)
        self.lineLengthLabel.showText('0', (1, 1, 1, 1))
        base.loadingScreen.endStep('GameGUI')

    
    def updateLureQuantities(self, caller = None):
        inv = localAvatar.getInventory()
        regQty = inv.getStackQuantity(InventoryType.RegularLure)
        legQty = inv.getStackQuantity(InventoryType.LegendaryLure)
        self.lureSelectionPanel.regularLureQty['text'] = 'x' + str(regQty)
        self.lureSelectionPanel.legendaryLureQty['text'] = 'x' + str(legQty)

    
    def handleExitGame(self):
        messenger.send('escape')

    
    def chooseRegularLure(self):
        inv = localAvatar.getInventory()
        qty = inv.getStackQuantity(InventoryType.RegularLure)
        if qty > 0:
            self.gameObject.chooseLure(InventoryType.RegularLure)
            self.lureSelectionPanel.hide()
            self.lureSelectionPanelShowing = False
            self.gameObject.sfx['lureEquip'].play()
        else:
            localAvatar.guiMgr.createWarning(PLocalizer.NotEnoughFishingLures, PiratesGuiGlobals.TextFG6)
            self.gameObject.tutorialManager.showTutorial(InventoryType.FishingNoMoreLures)

    
    def chooseLegendaryLure(self):
        inv = localAvatar.getInventory()
        qty = inv.getStackQuantity(InventoryType.LegendaryLure)
        if qty > 0:
            self.gameObject.chooseLure(InventoryType.LegendaryLure)
            self.lureSelectionPanel.hide()
            self.lureSelectionPanelShowing = False
            self.gameObject.sfx['lureEquip'].play()
        else:
            localAvatar.guiMgr.createWarning(PLocalizer.NotEnoughFishingLures, PiratesGuiGlobals.TextFG6)

    
    def hideGui(self):
        self.tackleBoxInterval.finish()
        self.castPowerMeter.reparentTo(hidden)
        self.lineHealthMeter.reparentTo(hidden)
        self.tackleBoxButton.reparentTo(hidden)
        self.exitButton.hide()
        self.resultsScreen.cleanUp()
        self.lureSelectionPanelShowing = False
        self.lureSelectionPanel.hide()
        self.lineLengthLabel.text.hide()
        if self.OkDialog is not None:
            self.OkDialog.cleanup()
            self.OkDialog = None
        

    
    def showGui(self):
        self.toggleGuiElements()

    
    def hideExitButton(self):
        self.exitButton.hide()

    
    def toggleGuiElements(self):
        if self.gameObject.fsm.getCurrentOrNextState() == 'LegendaryFish':
            self.hideGui()
            return None
        
        if self.gameObject.fsm.getCurrentOrNextState() in [
            'Offscreen',
            'ChargeCast',
            'Cast',
            'PlayerIdle']:
            self.lineHealthMeter.reparentTo(hidden)
            self.castPowerMeter.reparentTo(base.a2dLeftCenter)
            self.lineLengthLabel.text.reparentTo(base.a2dLeftCenter)
            self.lineLengthLabel.text.setPos(0.13700000000000001, 0.0, 0.52800000000000002)
            self.exitButton.show()
            self.tackleBoxButton.show()
            if self.tackleBoxInterval.isPlaying():
                self.toggleLureSelectionDialog()
            
        
        if self.gameObject.fsm.getCurrentOrNextState() in [
            'Fishing',
            'Reeling',
            'QuickReel',
            'FishFight']:
            self.castPowerMeter.reparentTo(hidden)
            self.lineHealthMeter.reparentTo(base.a2dLeftCenter)
            self.lineLengthLabel.text.reparentTo(base.a2dLeftCenter)
            self.lineLengthLabel.text.setPos(0.13700000000000001, 0.0, 0.53800000000000003)
            self.updateLineHealthMeter(self.gameObject.lineHealth)
            self.tackleBoxButton.hide()
            self.lureSelectionPanel.hide()
            self.lureSelectionPanelShowing = False
        
        self.tackleBoxButton.reparentTo(base.a2dBottomRight)

    
    def setTackleBoxPulse(self, bool):
        if bool:
            self.tackleBoxInterval.loop()
        else:
            self.tackleBoxInterval.finish()

    
    def resetGui(self):
        self.castMeterBar.setScale(1.0, 1.0, 0.01)
        self.lineHealthMeterBar.setScale(1.0, 1.0, 1.0)
        self.toggleGuiElements()

    
    def destroy(self):
        self.castPowerMeter.removeNode()
        self.lineHealthMeter.removeNode()
        self.lureSelectionPanel.destroy()
        self.lureSelectionPanel.regularLureButton = None
        self.lureSelectionPanel.regularLureButtonText = None
        self.lureSelectionPanel.legendaryLureButton = None
        self.lureSelectionPanel.legendaryLureButtonText = None
        self.lureSelectionPanel = None
        self.lineLengthLabel = None
        self.tackleBoxButton.destroy()
        self.tackleBoxButton = None
        self.exitButton.destroy()
        self.exitButton = None

    
    def startPowerMeter(self):
        self.startCastFrameTime = globalClock.getFrameTime()

    
    def updateCastPowerMeter(self, value):
        self.castMeterBar.setScale(1.0, 1.0, value / 100.0)

    
    def updateCastPowerMeterTask(self, task):
        time = globalClock.getFrameTime()
        elapsed = max(time - self.startCastFrameTime, 0.0)
        value = round(-math.cos(elapsed * 5.0) * 50.0 + 50.0)
        value = max(value, 0.0)
        self.updateCastPowerMeter(value)
        return Task.again

    
    def updateLineHealthMeter(self, value):
        self.lineHealthMeterBar.setScale(1.0, 1.0, value / 100.0)
        self.lineHealthMeterBar.setColorScale(self.gameObject.getLineColorBasedOnHealth())

    
    def showRewardDialog(self, fish):
        self.resultsScreen.showAll()
        self.exitButton.hide()

    
    def showExitCheckDialog(self):
        dialogText = PLocalizer.FishingGui['AreYouSure']
        self.OkDialog = PDialog(text = dialogText, style = OTPDialog.Acknowledge, giveMouse = False, command = self.closeDialogGotoPlayerIdle)
        self.OkDialog.setPos(0.80000000000000004, 0.0, 0.5)

    
    def closeDialogGotoPlayerIdle(self, arg):
        self.OkDialog.cleanup()
        self.OkDialog = None
        self.gameObject.fsm.request('PlayerIdle')

    
    def toggleLureSelectionDialog(self):
        if self.lureSelectionPanelShowing:
            self.lureSelectionPanel.hide()
        else:
            self.lureSelectionPanel.show()
        self.lureSelectionPanelShowing = not (self.lureSelectionPanelShowing)
예제 #12
0
class FishingGameGUI:
    def __init__(self, gameObject=None):
        base.loadingScreen.beginStep('GameGUI', 3, 20)
        self.gameObject = gameObject
        gui = loader.loadModel('models/gui/toplevel_gui')
        guiIcons = loader.loadModel('models/textureCards/icons')
        weaponIcons = loader.loadModel('models/gui/gui_icons_weapon')
        fishingIcons = loader.loadModel('models/textureCards/fishing_icons')
        self.tackleBoxButton = DirectButton(
            parent=base.a2dBottomRight,
            relief=None,
            pos=(-0.53000000000000003, 0.0, 0.10000000000000001),
            scale=0.5,
            text=PLocalizer.FishingGui['Lures'],
            text_pos=(0, -0.14999999999999999),
            text_scale=0.065000000000000002,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            image_pos=(0, 0, 0),
            image_scale=0.17999999999999999,
            geom=(fishingIcons.find('**/pir_t_gui_fsh_tackleBasket'),
                  fishingIcons.find('**/pir_t_gui_fsh_tackleBasket'),
                  fishingIcons.find('**/pir_t_gui_fsh_tackleBasket_over')),
            geom_pos=(0, 0, 0),
            geom_scale=0.25,
            geom_color=(1.0, 1.0, 1.0, 1),
            sortOrder=2,
            command=self.toggleLureSelectionDialog)
        self.tackleBoxInterval = Sequence(
            self.tackleBoxButton.colorScaleInterval(
                0.5, Vec4(1.0, 0.59999999999999998, 0.59999999999999998, 1.0)),
            self.tackleBoxButton.colorScaleInterval(0.5,
                                                    Vec4(1.0, 1.0, 1.0, 1.0)))
        self.exitButton = DirectButton(
            parent=base.a2dBottomRight,
            relief=None,
            pos=(-0.29999999999999999, 0.0, 0.10000000000000001),
            scale=0.5,
            text=PLocalizer.FishingGui['ExitButton'],
            text_pos=(0, -0.14999999999999999),
            text_scale=0.065000000000000002,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            image_pos=(0, 0, 0),
            image_scale=0.17999999999999999,
            geom=(fishingIcons.find('**/pir_t_gui_fsh_esc'),
                  fishingIcons.find('**/pir_t_gui_fsh_esc'),
                  fishingIcons.find('**/pir_t_gui_fsh_esc_over')),
            geom_pos=(0, 0, 0),
            geom_scale=0.25,
            geom_color=(1.0, 1.0, 1.0, 1),
            sortOrder=2,
            command=self.handleExitGame)
        self.OkDialog = None
        base.loadingScreen.tick()
        dialogText = PLocalizer.FishingGui['ChooseYourLure']
        self.lureSelectionPanel = GuiPanel.GuiPanel(dialogText, 0.75, 0.5,
                                                    True, 1)
        self.lureSelectionPanel.reparentTo(base.a2dBottomRight)
        self.lureSelectionPanel.setPos(-0.90000000000000002, 0.0, 0.22)
        self.lureSelectionPanel.regularLureButton = DirectButton(
            parent=self.lureSelectionPanel,
            relief=None,
            pos=(0.20000000000000001, 0, 0.25),
            scale=0.5,
            text='',
            text_pos=(0, 0),
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            image=fishingIcons.find('**/pir_t_gui_fsh_lureReg'),
            image_pos=(0, 0, 0),
            image_scale=0.17999999999999999,
            geom=(gui.find('**/pir_t_gui_but_circle'),
                  gui.find('**/pir_t_gui_but_circle'),
                  gui.find('**/pir_t_gui_but_circle_over')),
            geom_pos=(0, 0, 0),
            geom_scale=1,
            geom_hpr=(0, 0, 90),
            geom_color=(1.0, 1.0, 1.0, 1),
            sortOrder=2,
            command=self.chooseRegularLure)
        self.lureSelectionPanel.regularLureButtonText = DirectLabel(
            parent=self.lureSelectionPanel,
            relief=None,
            text=PLocalizer.FishingGui['RegularLures'],
            text_align=TextNode.ARight,
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_pos=(0.28000000000000003, 0.14999999999999999),
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            textMayChange=1)
        base.loadingScreen.tick()
        inv = localAvatar.getInventory()
        regQty = inv.getStackQuantity(InventoryType.RegularLure)
        self.lureSelectionPanel.regularLureQty = DirectLabel(
            parent=self.lureSelectionPanel,
            relief=None,
            text='x' + str(regQty),
            text_align=TextNode.ACenter,
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_pos=(0.29999999999999999, 0.20000000000000001),
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            textMayChange=1)
        self.lureSelectionPanel.legendaryLureButton = DirectButton(
            parent=self.lureSelectionPanel,
            relief=None,
            pos=(0.55000000000000004, 0.0, 0.25),
            scale=0.5,
            text='',
            text_pos=(0, 0),
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            image=fishingIcons.find('**/pir_t_gui_fsh_lureLegend'),
            image_pos=(0, 0, 0),
            image_scale=0.17999999999999999,
            geom=(gui.find('**/pir_t_gui_but_circle'),
                  gui.find('**/pir_t_gui_but_circle'),
                  gui.find('**/pir_t_gui_but_circle_over')),
            geom_pos=(0, 0, 0),
            geom_scale=1,
            geom_hpr=(0, 0, 90),
            geom_color=(1.0, 1.0, 1.0, 1),
            sortOrder=2,
            command=self.chooseLegendaryLure)
        self.lureSelectionPanel.legendaryLureButtonText = DirectLabel(
            parent=self.lureSelectionPanel,
            relief=None,
            text=PLocalizer.FishingGui['LegendaryLures'],
            text_align=TextNode.ARight,
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_pos=(0.65000000000000002, 0.14999999999999999),
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            textMayChange=1)
        inv = localAvatar.getInventory()
        legQty = inv.getStackQuantity(InventoryType.LegendaryLure)
        self.lureSelectionPanel.legendaryLureQty = DirectLabel(
            parent=self.lureSelectionPanel,
            relief=None,
            text='x' + str(legQty),
            text_align=TextNode.ACenter,
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_pos=(0.66000000000000003, 0.20000000000000001),
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            textMayChange=1)
        self.lureSelectionPanel.hide()
        self.lureSelectionPanelShowing = False
        self.resultsScreen = FishingResults(self.gameObject)
        self.resultsScreen.hide()
        bestRod = self.gameObject.getAvatarsBestRod()
        if bestRod == -1:
            base.notify.error(
                'Somehow the avatar got into the fishing game without a rod in their inventory!'
            )

        if bestRod == ItemGlobals.FISHING_ROD_3:
            self.castPowerMeterModel = loader.loadModel(
                'models/gui/pir_m_gui_fsh_fishingBarExpert')
        elif bestRod == ItemGlobals.FISHING_ROD_2:
            self.castPowerMeterModel = loader.loadModel(
                'models/gui/pir_m_gui_fsh_fishingBarNovice')
        else:
            self.castPowerMeterModel = loader.loadModel(
                'models/gui/pir_m_gui_fsh_fishingBarBeginner')
        base.loadingScreen.tick()
        self.castPowerMeter = NodePath('castPowerMeter')
        self.castPowerMeter.reparentTo(base.a2dLeftCenter)
        self.castMeterBackground = self.castPowerMeterModel.find(
            '**/background')
        self.castMeterBackground.setBin('fixed', 32)
        self.castMeterBackground.reparentTo(self.castPowerMeter)
        self.castMeterBar = self.castPowerMeterModel.find('**/meter')
        self.castMeterBar.setBin('fixed', 33)
        self.castMeterBar.reparentTo(self.castPowerMeter)
        self.castMeterBar.setColorScale(0.5, 0.5, 1.0, 1.0)
        self.castMeterFrame = self.castPowerMeterModel.find('**/bar')
        self.castMeterFrame.setBin('fixed', 34)
        self.castMeterFrame.reparentTo(self.castPowerMeter)
        self.castPowerMeter.setPos(0.13700000000000001, 0, 0.22800000000000001)
        self.castPowerMeter.setScale(1)
        self.lineHealthMeter = NodePath('lineHealthMeter')
        self.lineHealthMeter.reparentTo(base.a2dLeftCenter)
        self.lineHealthMeterModel = loader.loadModel(
            'models/gui/pir_m_gui_fsh_fishingBarHealth')
        self.lineHealthMeterBackground = self.lineHealthMeterModel.find(
            '**/background')
        self.lineHealthMeterBackground.setBin('fixed', 32)
        self.lineHealthMeterBackground.reparentTo(self.lineHealthMeter)
        self.lineHealthMeterBar = self.lineHealthMeterModel.find('**/meter')
        self.lineHealthMeterBar.setBin('fixed', 33)
        self.lineHealthMeterBar.reparentTo(self.lineHealthMeter)
        self.lineHealthMeterFrame = self.lineHealthMeterModel.find('**/bar')
        self.lineHealthMeterFrame.setBin('fixed', 34)
        self.lineHealthMeterFrame.reparentTo(self.lineHealthMeter)
        self.lineHealthMeter.setPos(0.13700000000000001, 0, 0.25)
        self.lineHealthMeter.setScale(1)
        self.lineLengthLabel = TextPrinter()
        self.lineLengthLabel.text.setScale(1.2)
        self.lineLengthLabel.text.setHpr(0.0, 0.0, 0.0)
        self.lineLengthLabel.text['sortOrder'] = 200
        self.lineLengthLabel.text.setBin('gui-fixed', 10)
        self.lineLengthLabel.text.setDepthTest(0)
        self.lineLengthLabel.text.setDepthWrite(0)
        self.lineLengthLabel.showText('0', (1, 1, 1, 1))
        base.loadingScreen.endStep('GameGUI')

    def updateLureQuantities(self, caller=None):
        inv = localAvatar.getInventory()
        regQty = inv.getStackQuantity(InventoryType.RegularLure)
        legQty = inv.getStackQuantity(InventoryType.LegendaryLure)
        self.lureSelectionPanel.regularLureQty['text'] = 'x' + str(regQty)
        self.lureSelectionPanel.legendaryLureQty['text'] = 'x' + str(legQty)

    def handleExitGame(self):
        messenger.send('escape')

    def chooseRegularLure(self):
        inv = localAvatar.getInventory()
        qty = inv.getStackQuantity(InventoryType.RegularLure)
        if qty > 0:
            self.gameObject.chooseLure(InventoryType.RegularLure)
            self.lureSelectionPanel.hide()
            self.lureSelectionPanelShowing = False
            self.gameObject.sfx['lureEquip'].play()
        else:
            localAvatar.guiMgr.createWarning(PLocalizer.NotEnoughFishingLures,
                                             PiratesGuiGlobals.TextFG6)
            self.gameObject.tutorialManager.showTutorial(
                InventoryType.FishingNoMoreLures)

    def chooseLegendaryLure(self):
        inv = localAvatar.getInventory()
        qty = inv.getStackQuantity(InventoryType.LegendaryLure)
        if qty > 0:
            self.gameObject.chooseLure(InventoryType.LegendaryLure)
            self.lureSelectionPanel.hide()
            self.lureSelectionPanelShowing = False
            self.gameObject.sfx['lureEquip'].play()
        else:
            localAvatar.guiMgr.createWarning(PLocalizer.NotEnoughFishingLures,
                                             PiratesGuiGlobals.TextFG6)

    def hideGui(self):
        self.tackleBoxInterval.finish()
        self.castPowerMeter.reparentTo(hidden)
        self.lineHealthMeter.reparentTo(hidden)
        self.tackleBoxButton.reparentTo(hidden)
        self.exitButton.hide()
        self.resultsScreen.cleanUp()
        self.lureSelectionPanelShowing = False
        self.lureSelectionPanel.hide()
        self.lineLengthLabel.text.hide()
        if self.OkDialog is not None:
            self.OkDialog.cleanup()
            self.OkDialog = None

    def showGui(self):
        self.toggleGuiElements()

    def hideExitButton(self):
        self.exitButton.hide()

    def toggleGuiElements(self):
        if self.gameObject.fsm.getCurrentOrNextState() == 'LegendaryFish':
            self.hideGui()
            return None

        if self.gameObject.fsm.getCurrentOrNextState() in [
                'Offscreen', 'ChargeCast', 'Cast', 'PlayerIdle'
        ]:
            self.lineHealthMeter.reparentTo(hidden)
            self.castPowerMeter.reparentTo(base.a2dLeftCenter)
            self.lineLengthLabel.text.reparentTo(base.a2dLeftCenter)
            self.lineLengthLabel.text.setPos(0.13700000000000001, 0.0,
                                             0.52800000000000002)
            self.exitButton.show()
            self.tackleBoxButton.show()
            if self.tackleBoxInterval.isPlaying():
                self.toggleLureSelectionDialog()

        if self.gameObject.fsm.getCurrentOrNextState() in [
                'Fishing', 'Reeling', 'QuickReel', 'FishFight'
        ]:
            self.castPowerMeter.reparentTo(hidden)
            self.lineHealthMeter.reparentTo(base.a2dLeftCenter)
            self.lineLengthLabel.text.reparentTo(base.a2dLeftCenter)
            self.lineLengthLabel.text.setPos(0.13700000000000001, 0.0,
                                             0.53800000000000003)
            self.updateLineHealthMeter(self.gameObject.lineHealth)
            self.tackleBoxButton.hide()
            self.lureSelectionPanel.hide()
            self.lureSelectionPanelShowing = False

        self.tackleBoxButton.reparentTo(base.a2dBottomRight)

    def setTackleBoxPulse(self, bool):
        if bool:
            self.tackleBoxInterval.loop()
        else:
            self.tackleBoxInterval.finish()

    def setTackleBoxPulse(self, bool):
        if bool:
            self.tackleBoxInterval.loop()
        else:
            self.tackleBoxInterval.finish()

    def resetGui(self):
        self.castMeterBar.setScale(1.0, 1.0, 0.01)
        self.lineHealthMeterBar.setScale(1.0, 1.0, 1.0)
        self.toggleGuiElements()

    def destroy(self):
        self.castPowerMeter.removeNode()
        self.lineHealthMeter.removeNode()
        self.lureSelectionPanel.destroy()
        self.lureSelectionPanel.regularLureButton = None
        self.lureSelectionPanel.regularLureButtonText = None
        self.lureSelectionPanel.legendaryLureButton = None
        self.lureSelectionPanel.legendaryLureButtonText = None
        self.lureSelectionPanel = None
        self.lineLengthLabel = None
        self.tackleBoxButton.destroy()
        self.tackleBoxButton = None
        self.exitButton.destroy()
        self.exitButton = None

    def startPowerMeter(self):
        self.startCastFrameTime = globalClock.getFrameTime()

    def updateCastPowerMeter(self, value):
        self.castMeterBar.setScale(1.0, 1.0, value / 100.0)

    def updateCastPowerMeterTask(self, task):
        time = globalClock.getFrameTime()
        elapsed = max(time - self.startCastFrameTime, 0.0)
        value = round(-math.cos(elapsed * 5.0) * 50.0 + 50.0)
        value = max(value, 0.0)
        self.updateCastPowerMeter(value)
        return Task.again

    def updateLineHealthMeter(self, value):
        self.lineHealthMeterBar.setScale(1.0, 1.0, value / 100.0)
        self.lineHealthMeterBar.setColorScale(
            self.gameObject.getLineColorBasedOnHealth())

    def showRewardDialog(self, fish):
        self.resultsScreen.showAll()
        self.exitButton.hide()

    def showExitCheckDialog(self):
        dialogText = PLocalizer.FishingGui['AreYouSure']
        self.OkDialog = PDialog(text=dialogText,
                                style=OTPDialog.Acknowledge,
                                giveMouse=False,
                                command=self.closeDialogGotoPlayerIdle)
        self.OkDialog.setPos(0.80000000000000004, 0.0, 0.5)

    def closeDialogGotoPlayerIdle(self, arg):
        self.OkDialog.cleanup()
        self.OkDialog = None
        self.gameObject.fsm.request('PlayerIdle')

    def toggleLureSelectionDialog(self):
        if self.lureSelectionPanelShowing:
            self.lureSelectionPanel.hide()
        else:
            self.lureSelectionPanel.show()
        self.lureSelectionPanelShowing = not (self.lureSelectionPanelShowing)
class DistributedFishingSpot(DistributedInteractive.DistributedInteractive,
                             Lootable):
    __module__ = __name__
    notify = DirectNotifyGlobal.directNotify.newCategory(
        'DistributedFishingSpot')

    def __init__(self, cr):
        DistributedInteractive.DistributedInteractive.__init__(self, cr)
        Lootable.__init__(self)
        self.index = -1
        self.onABoat = False
        self.fadeTime = 0.5
        self.loadingSequence = None
        self.fishingGame = None
        self.xpBonus = 0
        self.goldBonus = 0
        self.showTutorial = False
        self.__dialog = None
        self.prevBaseCamParent = None
        self.prevCamPos = None
        self.prevCamHpr = None
        self.oldAvatarPos = None
        return

    def generate(self):
        DistributedInteractive.DistributedInteractive.generate(self)
        NodePath.__init__(self, 'DistributedFishingSpot')
        self.setInteractOptions(proximityText=PLocalizer.InteractFishingSpot,
                                sphereScale=8,
                                diskRadius=8)
        self.setAllowInteract(True)

    def announceGenerate(self):
        DistributedInteractive.DistributedInteractive.announceGenerate(self)
        if self.getOnABoat() and self.getParentObj():
            self.getParentObj().registerFishingSpot(self)

    def setXpBonus(self, xpBonusAmount):
        self.xpBonus = xpBonusAmount
        if self.fishingGame:
            self.fishingGame.updateResultsScreen()

    def getXpBonus(self):
        return self.xpBonus

    def setGoldBonus(self, goldBonusAmount):
        self.goldBonus = goldBonusAmount
        if self.fishingGame:
            self.fishingGame.updateResultsScreen()

    def getGoldBonus(self):
        return self.goldBonus

    def setOnABoat(self, onABoat):
        self.onABoat = onABoat

    def getOnABoat(self):
        return self.onABoat

    def setOceanOffset(self, offset):
        self.oceanOffset = offset

    def requestInteraction(self, avId, interactType=0):
        inv = localAvatar.getInventory()
        rodQty = inv.getStackQuantity(InventoryType.FishingRod)
        regLureQty = inv.getStackQuantity(InventoryType.RegularLure)
        legendaryLureQty = inv.getStackQuantity(InventoryType.LegendaryLure)
        if rodQty > 0:
            if regLureQty + legendaryLureQty <= 0:
                localAvatar.guiMgr.createWarning(
                    PLocalizer.FishingNoLuresWarning,
                    PiratesGuiGlobals.TextFG6)
            elif localAvatar.isUndead():
                localAvatar.guiMgr.createWarning(
                    PLocalizer.NoFishingWhileUndeadWarning,
                    PiratesGuiGlobals.TextFG6)
            else:
                localAvatar.motionFSM.off()
                DistributedInteractive.DistributedInteractive.requestInteraction(
                    self, avId, interactType)
        else:
            localAvatar.guiMgr.createWarning(PLocalizer.FishingNoRodWarning,
                                             PiratesGuiGlobals.TextFG6)

    def rejectInteraction(self):
        localAvatar.motionFSM.on()
        localAvatar.gameFSM.request('LandRoam')
        self.refreshState()
        DistributedInteractive.DistributedInteractive.rejectInteraction(self)

    def requestExit(self):
        DistributedInteractive.DistributedInteractive.requestExit(self)
        taskMgr.remove('tryFishingSpotAgain')
        if (self.onABoat and self).oldAvatarPos:
            localAvatar.setPos(self.oldAvatarPos)
            self.oldAvatarPos = None
        if not localAvatar.gameFSM.isInTransition():
            localAvatar.b_setGameState(localAvatar.gameFSM.defaultState)
        if self.loadingSequence:
            self.loadingSequence.pause()
            self.loadingSequence.clearToInitial()
        base.transitions.fadeIn(self.fadeTime)
        if self.fishingGame is not None:
            self.fishingGame.delete()
            self.fishingGame = None
        if self.prevBaseCamParent is not None:
            base.cam.reparentTo(self.prevBaseCamParent)
            base.cam.setPos(self.prevCamPos)
            base.cam.setHpr(self.prevCamHpr)
            self.prevBaseCamParent = None
            self.prevCamPos = None
            self.prevCamHpr = None
        taskMgr.remove(self.uniqueName('bootFromFishing'))
        localAvatar.motionFSM.on()
        self.setAllowInteract(True)
        base.localAvatar.guiMgr.setIgnoreEscapeHotKey(False)
        self.refreshState()
        return

    def checkAndLoadFishingGame(self):
        localAvatar.b_setGameState('Fishing')
        if self.fishingGame is None:
            self.fishingGame = FishingGame(self)
        if self.onABoat:
            self.oldAvatarPos = localAvatar.getPos()
            localAvatar.collisionGhost()
            localAvatar.setPos(
                *FishingGlobals.fishingSpotPosHprBoatInformation[
                    self.index]['pos'])
            localAvatar.setHpr(
                *FishingGlobals.fishingSpotPosHprBoatInformation[
                    self.index]['hpr'])
            self.setHpr(*FishingGlobals.fishingSpotPosHprBoatInformation[
                self.index]['fishingSpotHpr'])
            base.cam.reparentTo(self.fishingGame.fishingSpot)
            base.cam.setPos(13.0, -18.0, 7.0)
            base.cam.setHpr(0.0, 0.0, 0.0)
        else:
            par = localAvatar.getParentObj()
            uid = par.getUniqueId()
            if uid == LocationIds.DEL_FUEGO_ISLAND:
                localAvatar.setHpr(50.0, 0.0, 0.0)
            else:
                if localAvatar.onWelcomeWorld:
                    localAvatar.setHpr(self.getH(render) - 196.0, 0.0, 0.0)
                else:
                    localAvatar.setHpr(self.getH(render) - 16.0, 0.0, 0.0)
            localAvatar.setPos(self,
                               Point3(*FishingGlobals.fishingSpotPosOffset))
            base.cam.reparentTo(self.fishingGame.fishingSpot)
            base.cam.setHpr(0.0, 0.0, 0.0)
        localAvatar.sendCurrentPosition()
        return

    def requestPlayerIdleState(self, task=None):
        if base.localAvatar.find('**/fishingRod').isEmpty():
            taskMgr.doMethodLater(0.5,
                                  self.requestPlayerIdleState,
                                  name='tryFishingSpotAgain')
        else:
            self.fishingGame.fsm.request('PlayerIdle')
            self.fishingGame.checkLures()

    def enterUse(self):
        DistributedInteractive.DistributedInteractive.enterUse(self)
        self.prevBaseCamParent = base.cam.getParent()
        self.prevCamPos = base.cam.getPos()
        self.prevCamHpr = base.cam.getHpr()
        if not base.transitions.fadeOutActive():
            self.loadingSequence = Sequence(Func(self.fadeOut),
                                            Wait(self.fadeTime + 0.1),
                                            Func(self.checkAndLoadFishingGame),
                                            Wait(1.5),
                                            Func(self.requestPlayerIdleState),
                                            Func(self.fadeIn))
            self.loadingSequence.start()
        else:
            print '--------------------- DistributedFishingSpot : Trouble fading out!'
        taskMgr.doMethodLater(FishingGlobals.idleDuration,
                              self.bootFromFishing,
                              self.uniqueName('bootFromFishing'))
        self.accept('mouse1', self.resetBootCheck)
        self.accept('fishing-skill-used', self.resetBootCheck)
        self.accept('newItemHeld', self.resetBootCheck)
        self.accept('releaseHeld', self.resetBootCheck)
        self.accept('plunderClosed', self.requestPlayerIdle)

    def fadeOut(self):
        base.transitions.setFadeColor(0, 0, 0)
        if base.transitions.fadeOutActive():
            return
        base.transitions.fadeOut(self.fadeTime)
        base.localAvatar.guiMgr.inventoryUIManager.hidePlunder()
        base.loadingScreen.showTarget(fishing=True)
        base.cr.loadingScreen.show()

    def fadeIn(self):
        base.transitions.fadeIn(self.fadeTime)
        base.musicMgr.request(SoundGlobals.MUSIC_MINIGAME_FISHING,
                              looping=True,
                              priority=1)
        base.cr.loadingScreen.hide()
        base.localAvatar.guiMgr.inventoryUIManager.showPlunder()

    def exitUse(self):
        self.ignoreAll()
        DistributedInteractive.DistributedInteractive.exitUse(self)
        base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_MINIGAME_FISHING)

    def firstTimeFisher(self):
        self.showTutorial = True

    def spotFilledByAvId(self, avId):
        if avId == 0:
            self.setAllowInteract(True)
            self.showTutorial = False
            return
        if base.localAvatar.doId != avId:
            self.setAllowInteract(False)

    def delete(self):
        self.ignoreAll()
        taskMgr.remove(self.uniqueName('bootFromFishing'))
        if self.fishingGame is not None:
            self.fishingGame.delete()
            del self.fishingGame
        if self.prevBaseCamParent is not None:
            base.cam.reparentTo(self.prevBaseCamParent)
            base.cam.setPos(self.prevCamPos)
            base.cam.setHpr(self.prevCamHpr)
            self.prevBaseCamParent = None
            self.prevCamPos = None
            self.prevCamHpr = None
        DistributedInteractive.DistributedInteractive.delete(self)
        return

    def b_setIndex(self, index):
        self.index = index
        self.sendUpdate('setIndex', [index])

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

    def getIndex(self):
        return self.index

    def d_caughtFish(self, fishId, weight):
        self.sendUpdate('caughtFish', [fishId, weight])

    def lostLure(self, lureId):
        pass

    def d_lostLure(self, lureId):
        self.sendUpdate('lostLure', [lureId])

    def handleEndInteractKey(self):
        if self.fishingGame and not self.fishingGame.gui.resultsScreen.isHidden(
        ) or localAvatar.guiMgr.inventoryUIManager.hasPlunder():
            return
        if not self.fishingGame:
            return
        if self.__dialog == None:
            self.__dialog = PDialog(text=PLocalizer.FishingGui['ExitText'],
                                    style=OTPDialog.YesNo,
                                    giveMouse=False,
                                    command=self.__onDialogItemSelected)
        else:
            self.__dialog.cleanup()
            self.__dialog = None
        return

    def __onDialogItemSelected(self, value):
        if value == 1:
            self.requestExit()
        self.__dialog.cleanup()
        self.__dialog = None
        return

    def bootFromFishing(self, task=None):
        self.requestExit()

    def resetBootCheck(self, arg1=None, arg2=None):
        taskMgr.remove(self.uniqueName('bootFromFishing'))
        taskMgr.doMethodLater(FishingGlobals.idleDuration,
                              self.bootFromFishing,
                              self.uniqueName('bootFromFishing'))

    def requestPlayerIdle(self, arg1=None):
        if self.fishingGame.fsm.getCurrentOrNextState() == 'Reward':
            self.fishingGame.fsm.request('PlayerIdle')

    def startLooting(self,
                     plunderList,
                     itemsToTake=0,
                     timer=0,
                     autoShow=False,
                     customName=None):
        Lootable.startLooting(self,
                              plunderList,
                              itemsToTake,
                              timer=timer,
                              autoShow=autoShow,
                              customName=PLocalizer.FoundFishing)
        if self.fishingGame and not self.fishingGame.gui.resultsScreen.isHidden(
        ):
            localAvatar.guiMgr.inventoryUIManager.hidePlunder()

    def handleArrivedOnShip(self, ship):
        pass

    def handleLeftShip(self, ship):
        pass
class DefenseCannonGUI(CannonGUI):
    notify = DirectNotifyGlobal.directNotify.newCategory('DefenseCannonGUI')
    
    def __init__(self, cannon):
        CannonGUI.__init__(self, cannon)
        self.exitEvent = None
        self._DefenseCannonGUI__dialog = None
        self.helpButton = None
        self.helpUI = None
        self.flashHelp = None
        self.ammoFade = None
        self._DefenseCannonGUI__ammoCountersHidden = False
        self.setupExtraButtons()
        self.exitCannon['command'] = self.showExitDialog
        self.volleyLabel.setPos(-0.28000000000000003, 0, 0.089999999999999997)
        self.reloadBar.setPos(-0.13, 0, 0.080000000000000002)
        self.ammoImage.setPos(-0.38, 0, 0.059999999999999998)
        self.repMeter = ReputationMeter(InventoryType.DefenseCannonRep, width = 0.69999999999999996)
        self.repMeter.reparentTo(base.a2dBottomCenter)
        self.repMeter.setPos(0.0, 0.0, 0.025000000000000001)
        self.hud = CannonDefenseHUD()
        self.hud.create()
        self._exp = 0
        self.lastLevel = 1
        self.accept('incDefenseCannonExp', self.increaseExp)
        if __dev__:
            base.dcg = self
        

    
    def destroy(self):
        if self.ammoFade:
            self.ammoFade.finish()
            self.ammoFade = None
        
        if self.flashHelp:
            self.flashHelp.finish()
            self.flashHelp = None
        
        if self.helpButton:
            self.helpButton.destroy()
            self.helpButton = None
        
        if self.helpUI:
            self.helpUI.destroy()
            self.helpUI = None
        
        if self.hud:
            self.hud.destroy()
            self.hud = None
        
        base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_MINIGAME_CANNON)
        self.repMeter.destroy()
        self.ignore('incDefenseCannonExp')
        CannonGUI.destroy(self)

    
    def setupExtraButtons(self):
        weaponIcons = loader.loadModel('models/gui/gui_icons_weapon')
        self.helpButton = DirectButton(parent = base.a2dBottomRight, relief = None, pos = (-0.59999999999999998, 0, 0.089999999999999997), scale = 0.5, text = '?', text_pos = (0, -0.055), text_scale = 0.20999999999999999, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateBoldOutlineFont(), sortOrder = 2, command = self.toggleHelpUI)
        DirectLabel(parent = self.helpButton, text = PLocalizer.CannonDefense['Help'], text_pos = (0, -0.14999999999999999), text_scale = 0.080000000000000002, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateBoldOutlineFont(), frameColor = (1, 1, 1, 0))

    
    def increaseExp(self, amt, total):
        self._exp += amt
        if self._exp > total:
            return None
        
        (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(InventoryType.DefenseCannonRep, self._exp)
        self.repMeter.update(self._exp)
        if level > self.lastLevel:
            base.localAvatar.levelUpMsg(InventoryType.DefenseCannonRep, level, 0)
            self.lastLevel = level
        

    
    def toggleHelpUI(self):
        if self.helpUI == None:
            self._DefenseCannonGUI__createHelpUI()
            self.fadeOutAmmoCounters()
            if self.cannon.ammoPanel.state == pirates.minigame.AmmoPanel.CLOSED:
                self.cannon.ammoPanel.onTabClick()
            
        else:
            self._DefenseCannonGUI__destroyHelpUI()
            self.fadeInAmmoCounters()
            if self.cannon.ammoPanel.state == pirates.minigame.AmmoPanel.OPENED:
                self.cannon.ammoPanel.onTabClick()
            

    
    def _DefenseCannonGUI__createHelpUI(self):
        self.helpUI = CannonDefenseHelpManager(0.5)
        self.helpUI.exit.reparentTo(self.exitCannon)
        self.helpUI.exit.setScale(2.0)
        self.helpUI.help.reparentTo(self.helpButton)
        self.helpUI.help.setScale(2.0)
        self.helpUI.ammoPanel.reparentTo(self.cannon.ammoPanel.panel)
        self.helpUI.ammoPanel.setScale(1.0 / 3.0)
        self.helpUI.ammo.reparentTo(base.a2dBottomCenter)
        self.helpUI.mine.reparentTo(self.hud.goldRemainingUI.mineCounter)
        self.helpUI.mine.setScale(2.0 / 3.0)
        self.helpUI.wave.reparentTo(self.hud.timeRemainingUI.timeRemaining)
        self.helpUI.wave.setScale(1.0 / 0.75)
        self.helpUI.fadeIn.start()

    
    def _DefenseCannonGUI__destroyHelpUI(self):
        cleanup = Sequence(Func(self.helpUI.fadeIn.pause), self.helpUI.fadeOut, Func(self.helpUI.destroy), name = self.cannon.uniqueName('HelpUI_FadeIn'))
        cleanup.start()
        self.helpUI = None

    
    def isHelpUIVisible(self):
        return self.helpUI != None

    
    def flashHelpButton(self, delay = 0.20000000000000001, length = 5):
        if self.flashHelp:
            self.flashHelp.finish()
            self.flashHelp = None
        
        self.flashHelp = Sequence(name = self.cannon.uniqueName('HelpButton_Flash'))
        
        def setColor(key, value):
            self.helpButton[key] = value

        for i in range(0, length):
            self.flashHelp.append(Wait(delay))
            self.flashHelp.append(Func(setColor, 'text_fg', PiratesGuiGlobals.TextFG19))
            self.flashHelp.append(Wait(delay))
            self.flashHelp.append(Func(setColor, 'text_fg', PiratesGuiGlobals.TextFG2))
        
        self.flashHelp.start()

    
    def fadeOutAmmoCounters(self, length = 0.5):
        if self._DefenseCannonGUI__ammoCountersHidden:
            return None
        
        transparent = Vec4(1, 1, 1, 0)
        if self.ammoFade:
            self.ammoFade.finish()
        
        self.ammoFade = Parallel(self.volleyLabel.colorScaleInterval(length, transparent), self.reloadBar.colorScaleInterval(length, transparent), self.ammoImage.colorScaleInterval(length, transparent))
        self.ammoFade.start()
        self._DefenseCannonGUI__ammoCountersHidden = True

    
    def fadeInAmmoCounters(self, length = 0.5):
        if self._DefenseCannonGUI__ammoCountersHidden == False:
            return None
        
        opaque = Vec4(1, 1, 1, 1)
        transparent = Vec4(1, 1, 1, 0)
        if self.ammoFade:
            self.ammoFade.finish()
        
        self.ammoFade = Parallel(self.volleyLabel.colorScaleInterval(length, opaque, transparent), self.reloadBar.colorScaleInterval(length, opaque, transparent), self.ammoImage.colorScaleInterval(length, opaque, transparent))
        self.ammoFade.start()
        self._DefenseCannonGUI__ammoCountersHidden = False

    
    def showExitDialog(self):
        if self._DefenseCannonGUI__dialog == None:
            self._DefenseCannonGUI__dialog = PDialog(text = PLocalizer.CannonDefense['ExitCannon'], style = OTPDialog.YesNo, giveMouse = False, command = self._DefenseCannonGUI__onDialogItemSelected)
        else:
            self._DefenseCannonGUI__dialog.cleanup()
            self._DefenseCannonGUI__dialog = None

    
    def _DefenseCannonGUI__onDialogItemSelected(self, value):
        if value == 1:
            if self.exitEvent:
                self.exitEvent()
            
        
        self._DefenseCannonGUI__dialog.cleanup()
        self._DefenseCannonGUI__dialog = None
 def showExitDialog(self):
     if self._DefenseCannonGUI__dialog == None:
         self._DefenseCannonGUI__dialog = PDialog(text = PLocalizer.CannonDefense['ExitCannon'], style = OTPDialog.YesNo, giveMouse = False, command = self._DefenseCannonGUI__onDialogItemSelected)
     else:
         self._DefenseCannonGUI__dialog.cleanup()
         self._DefenseCannonGUI__dialog = None
 def showExitCheckDialog(self):
     dialogText = PLocalizer.FishingGui['AreYouSure']
     self.OkDialog = PDialog(text = dialogText, style = OTPDialog.Acknowledge, giveMouse = False, command = self.closeDialogGotoPlayerIdle)
     self.OkDialog.setPos(0.80000000000000004, 0.0, 0.5)
class DistributedFishingSpot(DistributedInteractive.DistributedInteractive, Lootable):
    notify = DirectNotifyGlobal.directNotify.newCategory('DistributedFishingSpot')
    
    def __init__(self, cr):
        DistributedInteractive.DistributedInteractive.__init__(self, cr)
        Lootable.__init__(self)
        self.index = -1
        self.onABoat = False
        self.fadeTime = 0.5
        self.loadingSequence = None
        self.fishingGame = None
        self.xpBonus = 0
        self.goldBonus = 0
        self.showTutorial = False
        self._DistributedFishingSpot__dialog = None
        self.prevBaseCamParent = None
        self.prevCamPos = None
        self.prevCamHpr = None
        self.oldAvatarPos = None

    
    def generate(self):
        DistributedInteractive.DistributedInteractive.generate(self)
        NodePath.__init__(self, 'DistributedFishingSpot')
        self.setInteractOptions(proximityText = PLocalizer.InteractFishingSpot, sphereScale = 8, diskRadius = 8)
        self.setAllowInteract(True)

    
    def announceGenerate(self):
        DistributedInteractive.DistributedInteractive.announceGenerate(self)
        if self.getOnABoat() and self.getParentObj():
            self.getParentObj().registerFishingSpot(self)
        

    
    def setXpBonus(self, xpBonusAmount):
        self.xpBonus = xpBonusAmount
        if self.fishingGame:
            self.fishingGame.updateResultsScreen()
        

    
    def getXpBonus(self):
        return self.xpBonus

    
    def setGoldBonus(self, goldBonusAmount):
        self.goldBonus = goldBonusAmount
        if self.fishingGame:
            self.fishingGame.updateResultsScreen()
        

    
    def getGoldBonus(self):
        return self.goldBonus

    
    def setOnABoat(self, onABoat):
        self.onABoat = onABoat

    
    def getOnABoat(self):
        return self.onABoat

    
    def setOceanOffset(self, offset):
        self.oceanOffset = offset

    
    def requestInteraction(self, avId, interactType = 0):
        inv = localAvatar.getInventory()
        rodQty = inv.getStackQuantity(InventoryType.FishingRod)
        regLureQty = inv.getStackQuantity(InventoryType.RegularLure)
        legendaryLureQty = inv.getStackQuantity(InventoryType.LegendaryLure)
        if rodQty > 0:
            if regLureQty + legendaryLureQty <= 0:
                localAvatar.guiMgr.createWarning(PLocalizer.FishingNoLuresWarning, PiratesGuiGlobals.TextFG6)
            elif localAvatar.isUndead():
                localAvatar.guiMgr.createWarning(PLocalizer.NoFishingWhileUndeadWarning, PiratesGuiGlobals.TextFG6)
            else:
                localAvatar.motionFSM.off()
                DistributedInteractive.DistributedInteractive.requestInteraction(self, avId, interactType)
        else:
            localAvatar.guiMgr.createWarning(PLocalizer.FishingNoRodWarning, PiratesGuiGlobals.TextFG6)

    
    def rejectInteraction(self):
        localAvatar.motionFSM.on()
        localAvatar.gameFSM.request('LandRoam')
        self.refreshState()
        DistributedInteractive.DistributedInteractive.rejectInteraction(self)

    
    def requestExit(self):
        DistributedInteractive.DistributedInteractive.requestExit(self)
        taskMgr.remove('tryFishingSpotAgain')
        if self.onABoat and self.oldAvatarPos:
            localAvatar.setPos(self.oldAvatarPos)
            self.oldAvatarPos = None
        
        if not localAvatar.gameFSM.isInTransition():
            localAvatar.b_setGameState(localAvatar.gameFSM.defaultState)
        
        self.loadingSequence.pause()
        self.loadingSequence.clearToInitial()
        base.transitions.fadeIn(self.fadeTime)
        if self.fishingGame is not None:
            self.fishingGame.delete()
            self.fishingGame = None
        
        if self.prevBaseCamParent is not None:
            base.cam.reparentTo(self.prevBaseCamParent)
            base.cam.setPos(self.prevCamPos)
            base.cam.setHpr(self.prevCamHpr)
            self.prevBaseCamParent = None
            self.prevCamPos = None
            self.prevCamHpr = None
        
        taskMgr.remove(self.uniqueName('bootFromFishing'))
        localAvatar.motionFSM.on()
        self.setAllowInteract(True)
        base.localAvatar.guiMgr.setIgnoreEscapeHotKey(False)
        self.refreshState()

    
    def checkAndLoadFishingGame(self):
        localAvatar.b_setGameState('Fishing')
        if self.fishingGame is None:
            self.fishingGame = FishingGame(self)
        
        if self.onABoat:
            self.oldAvatarPos = localAvatar.getPos()
            localAvatar.collisionGhost()
            localAvatar.setPos(*FishingGlobals.fishingSpotPosHprBoatInformation[self.index]['pos'])
            localAvatar.setHpr(*FishingGlobals.fishingSpotPosHprBoatInformation[self.index]['hpr'])
            self.setHpr(*FishingGlobals.fishingSpotPosHprBoatInformation[self.index]['fishingSpotHpr'])
            base.cam.reparentTo(self.fishingGame.fishingSpot)
            base.cam.setPos(13.0, -18.0, 7.0)
            base.cam.setHpr(0.0, 0.0, 0.0)
        else:
            par = localAvatar.getParentObj()
            uid = par.getUniqueId()
            if uid == LocationIds.DEL_FUEGO_ISLAND:
                localAvatar.setHpr(50.0, 0.0, 0.0)
            elif localAvatar.onWelcomeWorld:
                localAvatar.setHpr(self.getH(render) - 196.0, 0.0, 0.0)
            else:
                localAvatar.setHpr(self.getH(render) - 16.0, 0.0, 0.0)
            localAvatar.setPos(self, Point3(*FishingGlobals.fishingSpotPosOffset))
            base.cam.reparentTo(self.fishingGame.fishingSpot)
            base.cam.setHpr(0.0, 0.0, 0.0)
        localAvatar.sendCurrentPosition()

    
    def requestPlayerIdleState(self, task = None):
        if base.localAvatar.find('**/fishingRod').isEmpty():
            taskMgr.doMethodLater(0.5, self.requestPlayerIdleState, name = 'tryFishingSpotAgain')
        else:
            self.fishingGame.fsm.request('PlayerIdle')
            self.fishingGame.checkLures()

    
    def enterUse(self):
        DistributedInteractive.DistributedInteractive.enterUse(self)
        self.prevBaseCamParent = base.cam.getParent()
        self.prevCamPos = base.cam.getPos()
        self.prevCamHpr = base.cam.getHpr()
        if not base.transitions.fadeOutActive():
            self.loadingSequence = Sequence(Func(self.fadeOut), Wait(self.fadeTime + 0.10000000000000001), Func(self.checkAndLoadFishingGame), Wait(1.5), Func(self.requestPlayerIdleState), Func(self.fadeIn))
            self.loadingSequence.start()
        else:
            print '--------------------- DistributedFishingSpot : Trouble fading out!'
        taskMgr.doMethodLater(FishingGlobals.idleDuration, self.bootFromFishing, self.uniqueName('bootFromFishing'))
        self.accept('mouse1', self.resetBootCheck)
        self.accept('fishing-skill-used', self.resetBootCheck)
        self.accept('newItemHeld', self.resetBootCheck)
        self.accept('releaseHeld', self.resetBootCheck)
        self.accept('plunderClosed', self.requestPlayerIdle)

    
    def fadeOut(self):
        base.transitions.setFadeColor(0, 0, 0)
        if base.transitions.fadeOutActive():
            return None
        
        base.transitions.fadeOut(self.fadeTime)
        base.localAvatar.guiMgr.inventoryUIManager.hidePlunder()
        base.loadingScreen.showTarget(fishing = True)
        base.cr.loadingScreen.show()

    
    def fadeIn(self):
        base.transitions.fadeIn(self.fadeTime)
        base.musicMgr.request(SoundGlobals.MUSIC_MINIGAME_FISHING, looping = True, priority = 1)
        base.cr.loadingScreen.hide()
        base.localAvatar.guiMgr.inventoryUIManager.showPlunder()

    
    def exitUse(self):
        self.ignoreAll()
        DistributedInteractive.DistributedInteractive.exitUse(self)
        base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_MINIGAME_FISHING)

    
    def firstTimeFisher(self):
        self.showTutorial = True

    
    def spotFilledByAvId(self, avId):
        if avId == 0:
            self.setAllowInteract(True)
            self.showTutorial = False
            return None
        
        if base.localAvatar.doId != avId:
            self.setAllowInteract(False)
        

    
    def delete(self):
        self.ignoreAll()
        taskMgr.remove(self.uniqueName('bootFromFishing'))
        if self.fishingGame is not None:
            self.fishingGame.delete()
            del self.fishingGame
        
        if self.prevBaseCamParent is not None:
            base.cam.reparentTo(self.prevBaseCamParent)
            base.cam.setPos(self.prevCamPos)
            base.cam.setHpr(self.prevCamHpr)
            self.prevBaseCamParent = None
            self.prevCamPos = None
            self.prevCamHpr = None
        
        DistributedInteractive.DistributedInteractive.delete(self)

    
    def b_setIndex(self, index):
        self.index = index
        self.sendUpdate('setIndex', [
            index])

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

    
    def getIndex(self):
        return self.index

    
    def d_caughtFish(self, fishId, weight):
        self.sendUpdate('caughtFish', [
            fishId,
            weight])

    
    def lostLure(self, lureId):
        pass

    
    def d_lostLure(self, lureId):
        self.sendUpdate('lostLure', [
            lureId])

    
    def handleEndInteractKey(self):
        if self.fishingGame or not self.fishingGame.gui.resultsScreen.isHidden() or localAvatar.guiMgr.inventoryUIManager.hasPlunder():
            return None
        
        if self._DistributedFishingSpot__dialog == None:
            self._DistributedFishingSpot__dialog = PDialog(text = PLocalizer.FishingGui['ExitText'], style = OTPDialog.YesNo, giveMouse = False, command = self._DistributedFishingSpot__onDialogItemSelected)
        else:
            self._DistributedFishingSpot__dialog.cleanup()
            self._DistributedFishingSpot__dialog = None

    
    def _DistributedFishingSpot__onDialogItemSelected(self, value):
        if value == 1:
            self.requestExit()
        
        self._DistributedFishingSpot__dialog.cleanup()
        self._DistributedFishingSpot__dialog = None

    
    def bootFromFishing(self, task = None):
        self.requestExit()

    
    def resetBootCheck(self, arg1 = None, arg2 = None):
        taskMgr.remove(self.uniqueName('bootFromFishing'))
        taskMgr.doMethodLater(FishingGlobals.idleDuration, self.bootFromFishing, self.uniqueName('bootFromFishing'))

    
    def requestPlayerIdle(self, arg1 = None):
        if self.fishingGame.fsm.getCurrentOrNextState() == 'Reward':
            self.fishingGame.fsm.request('PlayerIdle')
        

    
    def startLooting(self, plunderList, itemsToTake = 0, timer = 0, autoShow = False, customName = None):
        Lootable.startLooting(self, plunderList, itemsToTake, timer = timer, autoShow = autoShow, customName = PLocalizer.FoundFishing)
        if self.fishingGame and not self.fishingGame.gui.resultsScreen.isHidden():
            localAvatar.guiMgr.inventoryUIManager.hidePlunder()
 def destroy(self):
     if self.showWeaponsTrack:
         self.showWeaponsTrack.pause()
         self.showWeaponsTrack = None
     
     PDialog.destroy(self)