Exemple #1
0
    /// <summary>
    /// Remove um chunk do mapa
    /// </summary>
    /// <param name="worldRenderX">Posição absoluta do mundo em X</param>
    /// <param name="worldRenderY">Posição absoluta do mundo em Y</param>
    public void RemoveChunk()
    {
        var listTiles = new List <ChunkTiles>();

        m_GM.ChunksLoaded.Where(o => o[0] == (int)ChunkAction.DESTROY).ToList().ForEach(chunkLoaded =>
        {
            var chunk = m_GM.Chunks.SingleOrDefault(o => o.WX == chunkLoaded[1] && o.WY == chunkLoaded[2]);

            if (chunk != null)
            {
                listTiles.AddRange(chunk.WT);
                chunkLoaded[0] = (int)ChunkAction.UNLOADED;
            }
        });

        var listPos = new Vector3Int[listTiles.Count];
        var listOre = new TileBase[listTiles.Count];

        for (int i = 0; i < listTiles.Count; i++)
        {
            listOre[i] = null;
            listPos[i] = new Vector3Int(listTiles[i].X, listTiles[i].Y, 0);
        }

        RenderTilemap.SetTiles(listPos.ToArray(), listOre.ToArray());
    }