Example #1
0
        /// <summary>
        /// Updates the tilemap based on map
        /// </summary>
        public void PopulateTiles()
        {
            // create a mapping from id to tile
            // int maxTileID = 0;
            // foreach (var wallTile in _wallTiles)
            //     maxTileID = (maxTileID < (int) wallTile.TileID) ?
            //         (int)wallTile.TileID : maxTileID;

            // OreTile[] wallTiles = new OreTile[maxTileID+1];

            // foreach (var wallTile in _wallTiles)
            //     _wallTiles[(int) wallTile.TileID] = wallTile;

            // Generate the tiles appropriately
            var width  = Map.GetLength(0);
            var height = Map.GetLength(1);

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    Tile currTile = Map[x, y];
                    OreMap.SetTile(IndexToCell(x, y), currTile);
                }
            }
        }
Example #2
0
        public Vector2 WorldPosFromGridIndex(Vector2Int position)
        {
            Vector2 pos = OreMap.CellToWorld(IndexToCell(position));

            return(pos);
        }
Example #3
0
        public Vector2Int GridIndexFromWorldPos(Vector3 pos)
        {
            Vector3Int cellPos = OreMap.WorldToCell(pos);

            return(CellToIndex(cellPos));
        }