예제 #1
0
        public void GetAdjacentCellsIds(int cellId)
        {
            MediumCell cell = _airMedium.Cells[cellId];

            GetSideTiles(cell);
            GetTopBotCells(cell);
        }
예제 #2
0
 void GetTopBotCells(MediumCell cell)
 {
     if (cell.GridPosition.y == -_airMedium.MapSize.y / 2)               // if tile is on the Buttom edge
     {
         _adjacentId[0] = cell.CellId + _airMedium.MapSize.x;            //Top Cell ID
         _adjacentId[2] = _dummyId;                                      // Buttom Cell ID = Dummy Cell
     }
     else if (cell.GridPosition.y == (_airMedium.MapSize.y / 2) - 1)     // if tile is on the Top edge
     {
         _adjacentId[0] = _dummyId;                                      // Top Cell ID = Dummy Cell
         _adjacentId[2] = cell.CellId - _airMedium.MapSize.x;            // Buttom Cell ID
     }
     else                                                                // else
     {
         _adjacentId[0] = cell.CellId + _airMedium.MapSize.x;            // Top Cell ID
         _adjacentId[2] = cell.CellId - _airMedium.MapSize.x;            // Buttom Cell ID
     }
 }
예제 #3
0
 void GetSideTiles(MediumCell cell)
 {
     if (cell.GridPosition.x == -_airMedium.MapSize.x / 2)              // if tile is on the Left edge
     {
         _adjacentId[1] = cell.CellId + 1;                              // Right Cell ID
         _adjacentId[3] = cell.CellId + _airMedium.MapSize.x - 1;       // Left Cell ID
     }
     else if (cell.GridPosition.x == (_airMedium.MapSize.x / 2) - 1)    // if tile is on the Right edge
     {
         _adjacentId[1] = cell.CellId - (_airMedium.MapSize.x - 1);     // Right Cell ID
         _adjacentId[3] = cell.CellId - 1;                              // Left Cell ID
     }
     else                                                               // else
     {
         _adjacentId[1] = cell.CellId + 1;                              // Right Cell ID
         _adjacentId[3] = cell.CellId - 1;                              // Left Cell ID
     }
 }
예제 #4
0
        public void InitializeMedium()
        {
            _mapCreator = GameObject.Find("MapCreator").GetComponent <MapCreator>();

            MapSize = new Vector2Int(_mapCreator.MapWidth, _mapCreator.MapHeight);

            Cells = new MediumCell[MapSize.x * MapSize.y + 1];

            int i = 0;

            for (int y = 0; y < MapSize.y; y++)
            {
                for (int x = 0; x < MapSize.x; x++)
                {
                    Cells[i] = new MediumCell(i, new Vector3Int(x - (MapSize.x / 2), y - (MapSize.y / 2), 0));
                    i++;
                }
            }

            //Cells[461].Content[4] = 21;
            //Cells[462].Content[4] = 22;

            //Cells[465].Content[1] = 2f;
            Cells[465].Content[4] = 50f;


            //Cells[436].Content[4] = 25;

            //Cells[405].Content[4] = 30;
            //Cells[406].Content[4] = 25;
            //Cells[377].Content[4] = 20;

            //Cells[305].Content[4] = 30;


            //Dummy Cell
            Cells[MapSize.x * MapSize.y] = new MediumCell(MapSize.x * MapSize.y, new Vector3Int(-(MapSize.x / 2) - 5, -(MapSize.y / 2) - 5, 0));

            Wind.Initialize();
        }
예제 #5
0
        public void Initialize()
        {
            _airMedium = GameObject.Find("MediumAir").GetComponent <Medium>();

            Color color = new Color(1f, 1f, 1f, 1f);

            WindTileMap.ClearAllTiles();

            // Initiate TempGrid
            _tempCells = new MediumCell[_airMedium.Cells.Length];
            Vector3Int tempV3 = new Vector3Int(0, 0, 0);

            for (int i = 0; i < _airMedium.Cells.Length; i++)
            {
                _tempCells[i] = new MediumCell(i, tempV3);
            }
            ClearTempCells();

            // Initiate Adjacent Cells
            for (int a = 0; a < 4; a++)
            {
                _adjacentCells[a] = new MediumCell(a, tempV3);
            }
            ClearAdjacentCells();

            for (int i = 0; i < _airMedium.Cells.Length; i++)
            {
                WindTileMap.SetTile(_airMedium.Cells[i].GridPosition, WindTile);

                WindTileMap.SetTileFlags(_airMedium.Cells[i].GridPosition, TileFlags.None);

                WindTileMap.SetColor(_airMedium.Cells[i].GridPosition, color);
            }

            _dummyId = _airMedium.MapSize.x * _airMedium.MapSize.y;
        }