示例#1
0
    public void AddObjectToTile(TileObject _tileObject, int _x, int _y, bool _selectable)
    {
        if (_x > m_gridWidth - 1 || _y > m_gridHeight - 1)
        {
            Debug.LogError("Grid position out of bounds");
            return;
        }

        FloorTile tile = m_grid[_x, _y];

        if (tile == null)
        {
            return;
        }

        tile.AddObject(_tileObject, _selectable);
    }
示例#2
0
    public void AddObjectToRandomTile(TileObject _tileObject)
    {
        FloorTile tile  = null;
        int       tries = 0;

        //try to find a free tile to use
        while (tries < 100)
        {
            tile = m_grid[Random.Range(0, m_gridWidth), Random.Range(0, m_gridHeight)];
            if (tile != null && tile.IsEmpty())
            {
                break;
            }

            tries++;
        }

        if (tile == null)
        {
            return;
        }

        tile.AddObject(_tileObject, true);
    }