Ejemplo n.º 1
0
        public TileInstance[][] CreateTilemapStorage(TilemapLayerAsset type)
        {
            var storage = new TileInstance[m_size.y][];
            int chunkY  = 0;

            foreach (var chunk in levelChunks)
            {
                bool hasTilemap       = chunk.TryGetTilemap(type, out var tilemap);
                var  tilemapInterface = tilemap.GetInterface();
                for (int y = 0; y < chunk.size.y; y++)
                {
                    storage[chunkY + y] = new TileInstance[m_size.x];
                    if (hasTilemap)
                    {
                        for (int x = 0; x < chunk.size.x; x++)
                        {
                            var slicePosition = new Vector3Int(x, y, 0);
                            if (tilemap.TryGetTile(slicePosition, out var tile))
                            {
                                var storagePosition = new Vector3Int(x, chunkY + y, 0);
                                storage[chunkY + y][x] = CreateTileInstance(storagePosition, slicePosition, tile, tilemapInterface);
                            }
                        }
                    }
                }
                chunkY += chunk.size.y;
            }
            return(storage);
        }
Ejemplo n.º 2
0
 public void OnTileEnable(TileInstance instance)
 {
     isEnabled   = true;
     position    = instance.position;
     currentTile = instance.asset;
     StateChange(observedState.value);
 }
Ejemplo n.º 3
0
 public void OnTileDisable(TileInstance instance)
 {
     isEnabled = false;
 }
Ejemplo n.º 4
0
 public void OnTileEnable(TileInstance instance)
 {
     isEnabled = true;
     StateChange(observedState.value);
 }