class CogdoMazeBossGui(DirectFrame):

    def __init__(self, code):
        DirectFrame.__init__(self, relief=None, state=DGG.NORMAL, sortOrder=DGG.BACKGROUND_SORT_INDEX)
        self._code = str(code)
        self._codeLength = len(self._code)
        self._markersShown = 0
        self._markers = []
        self._initModel()
        self.setPos(*Globals.BossGuiPos)
        self.setScale(Globals.BossGuiScale)
        self.hide()

    def destroy(self):
        ToontownIntervals.cleanup('bosscodedoor')
        self._model.removeNode()
        del self._model
        self._titleLabel.removeNode()
        del self._titleLabel
        for marker in self._markers:
            marker.destroy()

        del self._markers
        DirectFrame.destroy(self)

    def _initModel(self):
        codeFrameGap = Globals.BossCodeFrameGap
        codeFrameWidth = Globals.BossCodeFrameWidth
        self._model = CogdoUtil.loadMazeModel('bossCog', group='gui')
        self._model.reparentTo(self)
        self._model.find('**/frame').setBin('fixed', 1)
        titleLabelPos = self._model.find('**/title_label_loc').getPos()
        self._titleLabel = DirectLabel(parent=self, relief=None, scale=Globals.BossGuiTitleLabelScale, text=TTLocalizer.CogdoMazeGameBossGuiTitle.upper(), pos=titleLabelPos, text_align=TextNode.ACenter, text_fg=(0, 0, 0, 1), text_shadow=(0, 0, 0, 0), text_font=ToontownGlobals.getSuitFont())
        self._titleLabel.setBin('fixed', 1)
        bossCard = self._model.find('**/bossCard')
        self._openDoor = self._model.find('**/doorOpen')
        self._closedDoor = self._model.find('**/doorClosed')
        self._openDoor.stash()
        spacingX = codeFrameWidth + codeFrameGap
        startX = -0.5 * ((self._codeLength - 1) * spacingX - codeFrameGap)
        for i in range(self._codeLength):
            marker = CogdoMazeBossCodeFrame(i, self._code[i], bossCard)
            marker.reparentTo(self)
            marker.setPos(bossCard, startX + spacingX * i, 0, 0)
            self._markers.append(marker)

        bossCard.removeNode()

    def showHit(self, bossIndex):
        self._markers[bossIndex].setHit(True)

    def showNumber(self, bossIndex):
        self._markers[bossIndex].setHit(False)
        self._markers[bossIndex].showNumber()
        self._markersShown += 1
        if self._markersShown == self._codeLength:
            self._openDoor.unstash()
            self._closedDoor.stash()
            ToontownIntervals.start(ToontownIntervals.getPulseLargerIval(self._openDoor, 'bosscodedoor'))
Ejemplo n.º 2
0
class CogdoMazeBossGui(DirectFrame):

    def __init__(self, code):
        DirectFrame.__init__(self, relief=None, state=DGG.NORMAL, sortOrder=DGG.BACKGROUND_SORT_INDEX)
        self._code = str(code)
        self._codeLength = len(self._code)
        self._markersShown = 0
        self._markers = []
        self._initModel()
        self.setPos(*Globals.BossGuiPos)
        self.setScale(Globals.BossGuiScale)
        self.hide()

    def destroy(self):
        ToontownIntervals.cleanup('bosscodedoor')
        self._model.removeNode()
        del self._model
        self._titleLabel.removeNode()
        del self._titleLabel
        for marker in self._markers:
            marker.destroy()

        del self._markers
        DirectFrame.destroy(self)

    def _initModel(self):
        codeFrameGap = Globals.BossCodeFrameGap
        codeFrameWidth = Globals.BossCodeFrameWidth
        self._model = CogdoUtil.loadMazeModel('bossCog', group='gui')
        self._model.reparentTo(self)
        self._model.find('**/frame').setBin('fixed', 1)
        titleLabelPos = self._model.find('**/title_label_loc').getPos()
        self._titleLabel = DirectLabel(parent=self, relief=None, scale=Globals.BossGuiTitleLabelScale, text=TTLocalizer.CogdoMazeGameBossGuiTitle.upper(), pos=titleLabelPos, text_align=TextNode.ACenter, text_fg=(0, 0, 0, 1), text_shadow=(0, 0, 0, 0), text_font=ToontownGlobals.getSuitFont())
        self._titleLabel.setBin('fixed', 1)
        bossCard = self._model.find('**/bossCard')
        self._openDoor = self._model.find('**/doorOpen')
        self._closedDoor = self._model.find('**/doorClosed')
        self._openDoor.stash()
        spacingX = codeFrameWidth + codeFrameGap
        startX = -0.5 * ((self._codeLength - 1) * spacingX - codeFrameGap)
        for i in xrange(self._codeLength):
            marker = CogdoMazeBossCodeFrame(i, self._code[i], bossCard)
            marker.reparentTo(self)
            marker.setPos(bossCard, startX + spacingX * i, 0, 0)
            self._markers.append(marker)

        bossCard.removeNode()

    def showHit(self, bossIndex):
        self._markers[bossIndex].setHit(True)

    def showNumber(self, bossIndex):
        self._markers[bossIndex].setHit(False)
        self._markers[bossIndex].showNumber()
        self._markersShown += 1
        if self._markersShown == self._codeLength:
            self._openDoor.unstash()
            self._closedDoor.stash()
            ToontownIntervals.start(ToontownIntervals.getPulseLargerIval(self._openDoor, 'bosscodedoor'))
Ejemplo n.º 3
0
class HUD():
    def __init__(self):
        self.canPlantLabel = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.15,
            pos=(0, 0, 0.25),
            pad=(0.2,0.2),
            text=_("Plant Seed"))
        self.canPlantLabel.setTransparency(True)
        self.canPlantLabel.reparentTo(base.a2dBottomCenter)
        self.canPlantLabel.hide()

        self.speekLabel = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.15,
            pos=(0, 0, 0.5),
            pad=(0.2,0.2),
            text="...")
        self.speekLabel.reparentTo(render)
        self.speekLabel.hide()
        self.speekLabel.setTransparency(True)
        self.speekLabel.setEffect(BillboardEffect.makePointEye())
        self.speekLabel.setBin("fixed", 11)
        self.speekLabel.setDepthWrite(False)

        self.storyText = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.08,
            pos=(0, 0, 0.25),
            pad=(0.2,0.2),
            text="Story text")
        self.storyText.setTransparency(True)
        self.storyText.reparentTo(base.a2dBottomCenter)
        self.storyText.hide()

        self.points = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.075,
            pos=(0.05, 0, -0.1),
            pad=(0.2,0.2),
            text_align=TextNode.ALeft,
            text=_("Points: %d")%0)
        self.points.setTransparency(True)
        self.points.reparentTo(base.a2dTopLeft)

        self.playerWater = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.075,
            pos=(0.05, 0, -0.2),
            pad=(0.2,0.2),
            text_align=TextNode.ALeft,
            text=_("Remaining Water: %d")%100)
        self.playerWater.setTransparency(True)
        self.playerWater.reparentTo(base.a2dTopLeft)


        self.helpInfo = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.075,
            pos=(-0.05, 0, -0.1),
            pad=(0.2,0.2),
            text_align=TextNode.ARight,
            text=_("F1 - show help"))
        self.helpInfo.setTransparency(True)
        self.helpInfo.reparentTo(base.a2dTopRight)

        self.hide()

    def show(self):
        self.points.show()
        self.playerWater.show()
        self.helpInfo.show()

    def hide(self):
        self.points.hide()
        self.playerWater.hide()
        self.helpInfo.hide()

    def hideAll(self):
        self.canPlantLabel.hide()
        self.speekLabel.hide()
        self.points.hide()
        self.playerWater.hide()
        self.helpInfo.hide()

    def showStory(self):
        self.storyText.show()

    def hideStory(self):
        self.storyText.hide()

    def cleanup(self):
        self.hideAll()
        self.canPlantLabel.destroy()
        self.speekLabel.destroy()
        self.points.destroy()
        self.playerWater.destroy()
        self.helpInfo.destroy()

    def showCanPlant(self):
        self.canPlantLabel.show()

    def hideCanPlant(self):
        self.canPlantLabel.hide()

    def setPoints(self, points):
        self.points["text"] = _("Points: %d")%points
        self.points.resetFrameSize()

    def setWater(self, water):
        self.playerWater["text"] = _("Remaining Water: %d")%water
        self.playerWater.resetFrameSize()

    def setStory(self, storytext):
        self.storyText["text"] = storytext
        self.storyText.resetFrameSize()

    def showSpeekText(self, text, newPos):
        self.speekLabel.setPos(newPos)
        self.speekLabel["text"] = text
        self.speekLabel.resetFrameSize()
        self.speekLabel.show()

    def hideSpeekText(self):
        self.speekLabel.hide()