Esempio n. 1
0
class CogdoMazeGuiManager:
    def __init__(self, maze):
        self.maze = maze

        self.mazeMapGui = MazeMapGui(self.maze.collisionTable)
        self.mazeMapGui.setScale(.25)
        self.mazeMapGui.setPos(1.07, 0.0, 0.73)

        self.hud = CogdoMazeHud()

        self.timer = None

    def _initTimer(self):
        self.timer = ToontownTimer()
        self.timer.hide()
        self.timer.setPos(1.16, 0, -0.83)

    def destroy(self):
        self.hud.destroy()
        self.hud = None
        self.destroyMazeMap()
        self.destroyTimer()

    def destroyMazeMap(self):
        if hasattr(self, "mazeMapGui") and self.mazeMapGui is not None:
            self.mazeMapGui.destroy()
            del self.mazeMapGui

    def destroyTimer(self):
        if self.timer is not None:
            self.timer.stop()
            self.timer.destroy()
            self.timer = None

    def updateMazeMapPlayer(self, player, tileX, tileY):
        self.mazeMapGui.revealCell(tileX, tileY, player)

    def revealMazeMap(self):
        self.mazeMapGui.revealAll()

    def addPlayerToMazeMap(self, keyTilePos, doorTilePos, color):
        self.mazeMapGui.addPlayer(0, 0, color)
        self.mazeMapGui.addKey(keyTilePos[0], keyTilePos[1], color)
        self.mazeMapGui.addDoor(doorTilePos[0], doorTilePos[1], color)

    def showTimer(self, duration, timerExpiredCallback=None):
        if self.timer is None:
            self._initTimer()

        self.timer.setTime(duration)
        self.timer.countdown(duration, timerExpiredCallback)
        self.timer.show()

    def hideTimer(self):
        assert hasattr(self, "timer") and self.timer is not None

        self.timer.hide()
        self.timer.stop()

    def displayNotification(self, message, nextMessage=None):
        self.hud.displayNotification(message, nextMessage)