Ejemplo n.º 1
0
    def _addPlayerInfo(self, player, playerLayers, isBottomPlayer):
        """Add the player display (life, mana, etc.) layers to the game.
        """

        lifeMeter = MeterLayer(192, 16, player.maxLife,
                               (255, 255, 255, 127), # background color
                               (255, 0, 0, 255),     # empty life color
                               (0, 255, 0, 255))     # full life color
        lifeMeter.value = player.life
        self.add(lifeMeter)
        # Don't tie the life meter directly to the display, because for animating
        # attacks we prefer to update the life to sync up with the attack.
        #player.lifeChanged.addHandler(lambda x: lifeMeter.setValue(x))

        manaMeter = MeterLayer(192, 16, player.maxMana,
                               (255, 255, 255, 127), # background color
                               (130, 130, 130, 255), # empty mana color
                               (0, 0, 255, 255))     # full mana color
        manaMeter.value = player.mana
        self.add(manaMeter)
        player.manaChanged.addHandler(lambda x: manaMeter.setValue(x))

        movesTextBox = TextBoxLayer(player.maxMoves)
        self.add(movesTextBox)
        player.moveChanged.addHandler(lambda x: movesTextBox.setValue(x))

        unitsTextBox = TextBoxLayer(player.maxUnitTotal)
        self.add(unitsTextBox)
        player.unitChanged.addHandler(lambda x: unitsTextBox.setValue(x))

        boardY = BOTTOM_MARGIN
        if not isBottomPlayer:
            boardY += BOARD_HEIGHT + BOARD_GAP

        lifeMeter.position = (32, boardY + 112 + 16 + 32)
        manaMeter.position = (32, boardY + 112)
        movesTextBox.position = (32, boardY + 80)
        unitsTextBox.position = (32, boardY + 50)

        playerLayers.lifeMeter = lifeMeter
        playerLayers.manaMeter = manaMeter
        playerLayers.movesCounter = movesTextBox
        playerLayers.unitsCounter = unitsTextBox