Exemple #1
0
    public void updateTokenPosition(Token token, Vector2Int newPosition, GameObject tilePositionGO)
    {
        if (!hasTileAt(newPosition) && token.spaceRounds == 0)
        {
            return;
        }

        if (hasTileAt(token.boardPosition))
        {
            getTileAt(token.boardPosition).removeToken(token);
        }
        if (hasSpaceAt(token.boardPosition))
        {
            spaceTiles[token.boardPosition].removeToken(token);
        }
        token.setBoardPosition(newPosition, tilePositionGO);
        if (hasTileAt(newPosition))
        {
            getTileAt(newPosition).addToken(token);
        }
        if (hasSpaceAt(newPosition))
        {
            spaceTiles[newPosition].addToken(token);
        }

        if (token is PlayerToken)
        {
            PlayerToken pt = (PlayerToken)token;
            if (pt.getPlayer() != null && pt.getPlayer().hasLoot)
            {
                LootToken.setBoardPosition(newPosition);
            }
        }
    }