コード例 #1
0
        public void CreateDict()
        {
            // Optimize bounds to use it easily.
            _tilemap.CompressBounds();

            foreach (var pos in _tilemap.cellBounds.allPositionsWithin)
            {
                TileBase tile = _tilemap.GetTile(pos);

                if (tile == null)
                {
                    continue;
                }
                // Try to get type from the tile.
                // If succeeded, add Cell to the dict.
                if (TryParse(tile.name, out CellType type))
                {
                    _mapDict.Add(pos, CellFactory.GetInstance(type));
                }
            }
        }
コード例 #2
0
 // NAME: There should be better name.
 public void DisableWalk(Vector3Int pos)
 {
     _mapDict.SetCell(pos, CellFactory.GetInstance(CellType.Wall));
     _tilemap.SetTileFlags(pos, TileFlags.None);
     _tilemap.SetColor(pos, _visitedColor);
 }