Esempio n. 1
0
 void Awake()
 {
     if (Root == null)
         Root = transform;
     int dim = 2 * MapRadius + 1;
     InitCells(dim, dim);
     Width = dim * UnitsPerTile;
     Height = dim * UnitsPerTile;
     Dict = new LRUSpriteDictionary((dim + 1) * (dim + 1));
     Grid = new SmartGrid<RenderCell, RefCountedSprite>(Cells.ToArray(), dim, dim);
     _loadedPosition = new MapUtils.ProjectedPos(MapRadius, MapRadius, ZoomLevel, 0, 0);
     _position = new Vector3();
 }
Esempio n. 2
0
 private void LoadNewTiles()
 {
     if (Equals(CurrentPosition, default(MapUtils.ProjectedPos)))
         return;
     Grid.Shift(_loadedPosition.X - CurrentPosition.X, _loadedPosition.Y - CurrentPosition.Y);
     _loadedPosition = CurrentPosition;
     for (int i = _loadedPosition.Y - MapRadius; i <= _loadedPosition.Y + MapRadius; i++)
     {
         for (int j = _loadedPosition.X - MapRadius; j <= _loadedPosition.X + MapRadius; j++)
         {
             if (Grid[j, i] == null)
             {
                 Grid[j, i] = SpawnTile(j, i);
             }
         }
     }
 }