Exemple #1
0
    public void CreateMap()
    {
        controlTileMap.CompressBounds();

        int countHorizontalSide = (int)(controlTileMap.size.x / 2f);
        int countVerticalSide   = (int)(controlTileMap.size.y / 2f);
    }
Exemple #2
0
        private void Start()
        {
            player          = FindObjectOfType <PlayerManager>();
            grid            = EnemyManager.Instance.grid;
            walkableTilemap = EnemyManager.Instance.walkableTilemap;
            _animator       = this.transform.GetComponentInChildren <Animator>();

            _healthBar = this.GetComponentInChildren <HealthBar>();
            _healthBar.SetBarPoints(enemyData.health, enemyData.defense);

            if (this.gameObject.GetComponentInChildren <SpriteRenderer>().gameObject.name == "EnemySprite")
            {
                spriteRenderer = this.gameObject.GetComponentInChildren <SpriteRenderer>();
            }
            else
            {
                Debug.Log("Sprite of player not found");
            }

            mainCamera = Camera.main;
            if (mainCamera)
            {
                shaker = mainCamera.GetComponent <CameraShaker>();
            }

            #region Astar Start Setup
            walkableTilemap.CompressBounds();   // réduit la taille de la tilemap à là où des tiles existent
            //roadMap.CompressBounds();
            bounds = walkableTilemap.cellBounds;
            CreateGrid();
            astar = new Astar(walkableTilesArray, bounds.size.x, bounds.size.y);
            #endregion
        }
Exemple #3
0
        void GetTiles(List <TileSingle> tileList)
        {
            tilemap.CompressBounds();
            bounds   = tilemap.cellBounds;
            allTiles = tilemap.GetTilesBlock(bounds);

            for (int x = 0; x < bounds.size.x; x++)
            {
                for (int y = 0; y < bounds.size.y; y++)
                {
                    TileBase tile = allTiles[x + y * bounds.size.x];
                    if (tile != null)
                    {
                        //tileList.Add(new TileSingle(x, y, true));
                        //Debug.Log(this.name +"x:" + x + " y:" + y + " tile:" + tile.name);
                        tileArr[x, y] = true;
                    }
                    else
                    {
                        //tileList.Add(new TileSingle(x, y, false));
                        //Debug.Log(this.name + "x:" + x + " y:" + y + " tile: (null)");
                        tileArr[x, y] = false;
                    }
                }
            }
        }
Exemple #4
0
    public void getName()
    {
        Tilemap tiles = GameObject.FindGameObjectWithTag("TileGrid").GetComponentInChildren <Tilemap>();

        tiles.CompressBounds();

        BoundsInt bounds = tilemap.cellBounds;

        TileBase[] allTiles = tilemap.GetTilesBlock(bounds);

        for (int x = 0; x < bounds.size.x; x++)
        {
            for (int y = bounds.size.y - 1; y > 0; y--)
            {
                TileBase tile = allTiles[x + y * bounds.size.x];
                if (tile != null)
                {
                    setType(tile.name, x, bounds.size.y - y);
                }
                else
                {
                    print("Casilla " + x + "," + y + " no encontrada");
                }
            }
        }
    }
    /// <summary>
    /// Convert a LayoutGrid to Pathfinding Grid.
    /// </summary>
    private Node[,] GenerateGrid(Tilemap tilemap)
    {
        tilemap.CompressBounds(); //Recalculates this tilemap's bounds.

        BoundsInt cellBounds = tilemap.cellBounds;

        Vector2Int nodesLength = new Vector2Int(
            Mathf.Abs(cellBounds.xMax) + Mathf.Abs(cellBounds.xMin),
            Mathf.Abs(cellBounds.yMax) + Mathf.Abs(cellBounds.yMin));  //Get bounds size

        Node[,] nodes = new Node[nodesLength.x, nodesLength.y];

        //tilemap.cellBounds.allPositionsWithin.GetEnumerator(); ??

        int numberOfTiles = 0;

        foreach (Vector3Int position in cellBounds.allPositionsWithin)
        {
            numberOfTiles++;

            Vector2Int gridIndex = TileIndexOnNavGrid(cellBounds, position);

            nodes[gridIndex.x, gridIndex.y] = new Node()
            {
                Walkable = tilemap.HasTile(position)
            };
        }

        Debug.Log(string.Format("NumberofTiles = {0}", numberOfTiles));

        return(nodes);
    }
Exemple #6
0
        public static bool IsGridPassableAtCoordinate(Grid gameWorldGrid, Vector2Int position)
        {
            bool foundPassible = false;

            for (var i = 0; i < gameWorldGrid.transform.childCount; i++)
            {
                Tilemap child = gameWorldGrid.transform.GetChild(i).GetComponent <Tilemap>();
                child.CompressBounds();
                TileBase tile = child.GetTile(new Vector3Int(position.x, position.y, 0));
                if (tile == null)
                {
                    continue;
                }
                BlockingTile convertedTile = tile as BlockingTile;

                if ((convertedTile != null) && (convertedTile.isImpassible))
                {
//                    Debug.Log("Tile is impassible: " + convertedTile.isImpassible);
                    return(false);
                }
                else
                {
                    foundPassible = true;
                }
            }
            return(foundPassible);
        }
Exemple #7
0
        void CreateWorld()
        {
            Debug.Log("SCClient.CreateWorld - All data received! Creating world.");

            Ground = Instantiate(GroundPrefab);

            Tilemap tilemap = Ground.GetComponentInChildren <Tilemap>();

            tilemap.ClearAllTiles();

            TileStore tileStore = GameObject.Find("Tile Registry").GetComponent <TileStore>();

            foreach (SCTileData data in tileDataBuffer)
            {
                tilemap.SetTile(new Vector3Int {
                    x = data.X, y = data.Y, z = data.Z
                }, tileStore.Get(data.TileID));
            }

            tilemap.CompressBounds();
            Vector3 center = tilemap.cellBounds.center;
            Vector3 camPos = tilemap.CellToWorld(new Vector3Int((int)center.x, (int)center.y, 0));

            camPos.z = -10;

            Camera.main.transform.position = camPos;

            loadingWorld = false;

            //GameObject.Find("Loading Screen").SetActive(false);
        }
Exemple #8
0
 // Start is called before the first frame update
 void Start()
 {
     tilemap.CompressBounds();
     bounds = tilemap.cellBounds;
     grid   = GetComponent <Grid>();
     aStar  = new AStar(bounds.size.x, bounds.size.y);
 }
    void CalculateCollision()
    {
        collisionMap = transform.parent.Find("Colider").gameObject.GetComponent <Tilemap>();
        collisionMap.CompressBounds();
        respawnMap = GetComponent <Tilemap>();

        int xMin = collisionMap.cellBounds.xMin;
        int xMax = collisionMap.cellBounds.xMax;
        int yMin = collisionMap.cellBounds.yMin;
        int yMax = collisionMap.cellBounds.yMax;

        for (int x = xMin; x < xMax; x++)
        {
            for (int y = yMin; y < yMax; y++)
            {
                Vector3Int pos  = new Vector3Int(x, y, 0);
                TileBase   tile = collisionMap.GetTile(pos);
                if (tile != null)
                {
                    Vector3Int newPos = new Vector3Int(x * 3 + 1, y * 3 + 1, 0);
                    respawnMap.SetTile(newPos, tile);
                }
            }
        }
    }
    void Grid_Inicializator()
    {
        tilemapPercolation.origin = tilemapFloor.origin;
        tilemapPercolation.size   = tilemapFloor.size;
        tilemapFloor.CompressBounds();
        tilemapPercolation.CompressBounds();

        bound = tilemapFloor.cellBounds;

        limitLine = transform.gameObject.GetComponent <LineRenderer>();

        //Getting corners
        Vector3 gridOrigin  = tilemapFloor.GetCellCenterWorld(tilemapFloor.origin);
        float   gridHip     = ((tilemapFloor.size.x - 1) * tilemapFloor.cellSize.y);
        float   limitAjustY = tilemapFloor.cellSize.y * (limit - .5f);
        float   limitAjustX = tilemapFloor.cellSize.x * (limit - .5f);

        homePlate  = gridOrigin + new Vector3(0, limitAjustY, 0);
        firstBase  = gridOrigin + new Vector3(gridHip, gridHip / 2, 0) - new Vector3(limitAjustX, 0, 0);
        secondBase = gridOrigin + new Vector3(0, gridHip, 0) - new Vector3(0, limitAjustY, 0);
        thirdBase  = gridOrigin + new Vector3(-gridHip, gridHip / 2, 0) + new Vector3(limitAjustX, 0, 0);

        if (debugPrintBallsCorner)
        {
            Instantiate(debugBallOrange, homePlate, Quaternion.identity, transform.Find("DEBUG"));
            Instantiate(debugBallGreen, firstBase, Quaternion.identity, transform.Find("DEBUG"));
            Instantiate(debugBallOrange, secondBase, Quaternion.identity, transform.Find("DEBUG"));
            Instantiate(debugBallGreen, thirdBase, Quaternion.identity, transform.Find("DEBUG"));
        }
    }
    public void InitFromArray(Vector2Int dimensions, int[] typeArray, Vector2Int playerStart, bool arrayOriginTopLeft)
    {
        _mapView.ClearAllTiles();
        int width  = dimensions.y;
        int height = dimensions.x;

        if (typeArray.Length != width * height)
        {
            Debug.LogError("Array dimensions not matching provided size");
            return;
        }

        _playerStart = playerStart;
        if (arrayOriginTopLeft)
        {
            _playerStart.x = height - (_playerStart.x + 1);
        }
        for (int row = 0; row < height; ++row)
        {
            for (int col = 0; col < width; ++col)
            {
                int rowCoord = (arrayOriginTopLeft) ? height - (row + 1) : row;
                _mapView.SetTile(new Vector3Int(rowCoord, col, 0), GetTileByType((KrbTileType)typeArray[width * row + col]));
            }
        }
        _mapView.CompressBounds();
    }
Exemple #12
0
    private void Start()
    {
        var sizes    = _gameData.Size.Split('x');
        var origin   = _gameZoneTilemap.origin;
        var cellSize = _gameZoneTilemap.cellSize;

        _gameZoneTilemap.ClearAllTiles();
        var currentCellPosition = origin;
        var width  = int.Parse(sizes[0]);
        var height = int.Parse(sizes[1]);

        for (var h = 0; h < height; h++)
        {
            for (var w = 0; w < width; w++)
            {
                _gameZoneTilemap.SetTile(currentCellPosition, _tilesHolder.GetBaseTile());
                currentCellPosition = new Vector3Int(
                    (int)(cellSize.x + currentCellPosition.x),
                    currentCellPosition.y, origin.z);
            }

            currentCellPosition = new Vector3Int(origin.x, (int)(cellSize.y + currentCellPosition.y), origin.z);
        }

        _gameZoneTilemap.CompressBounds();

        ModifyCamera(width);
    }
    public string ConvertTilemap(Tilemap tilemap)
    {
        tilemap.CompressBounds();
        var bounds   = tilemap.cellBounds;
        var allTiles = tilemap.GetTilesBlock(bounds);

        var width  = bounds.xMax - bounds.xMin;
        var height = bounds.yMax - bounds.yMin;

        string output = "";

        for (int y = 0; y < height; ++y)
        {
            for (int x = 0; x < width; ++x)
            {
                var tile = allTiles[x + width * y];
                if (tile != null)
                {
                    var tileID = tiles.FirstOrDefault(t => t.Value == tile);

                    output += tileID.Key + ":" + (bounds.xMin + x) + "," + (bounds.yMin + y) + " ";
                }
            }
            output += Environment.NewLine;
        }

        return(output);
    }
 private void UpdateTunnel()
 {
     _tunnelTileMap.CompressBounds();
     _tunnelTileMap.ResizeBounds();
     ClearTunnelColumn(_centerTileX - _tunnelSize.x - 1);
     GenerateTunnelColumn(_centerTileX + _tunnelSize.x);
 }
    private void ReadBoard()
    {
        var tilemaps = _grid.GetComponentsInChildren <Tilemap>();

        foreach (var tileMap in tilemaps)
        {
            if (tileMap.name == "Board")
            {
                _board = tileMap;
                break;
            }
        }

        if (_board == null)
        {
            throw new Exception("No Board tilemap found");
        }

        _board.CompressBounds();

        foreach (var position in _board.cellBounds.allPositionsWithin)
        {
            if (_board.GetTile(position) != null)
            {
                _boardTilesCubeCoordinates.Add(CoordinateUtils.OffsetToCube(position));
            }
        }
    }
Exemple #16
0
    private void GetTilemapTiles(Tilemap tileMap, Dictionary <Vector3, WorldTile> tileDict)
    {
        tileMap.CompressBounds();
        Tilemap groundTile = instance.groundTilemap;

        foreach (Vector3Int pos in groundTile.cellBounds.allPositionsWithin)
        {
            var localPlace = new Vector3Int(pos.x, pos.y, pos.z);

            /*if (!tileMap.HasTile(localPlace){
             *      continue;
             * }*/
            var tile = new WorldTile()
            {
                LocalPlace             = localPlace,
                WorldLocation          = Vector3Int.RoundToInt(groundTile.CellToWorld(localPlace)),
                TileBase               = tileMap.GetTile(localPlace),
                TilemapMember          = tileMap,
                Name                   = localPlace.x + "," + localPlace.y,
                WorldObject            = tileMap == instance.objectTilemap ? GetObjectInCell(Vector3Int.RoundToInt(groundTile.CellToWorld(localPlace))) : null,
                DefaultWorldObjectData = (tileMap == instance.objectTilemap && GetObjectInCell(Vector3Int.RoundToInt(groundTile.CellToWorld(localPlace))) != null) ? GetObjectInCell(Vector3Int.RoundToInt(groundTile.CellToWorld(localPlace))).Data : null,
                WaterLevel             = 0
            };
            if (tileDict.TryGetValue(tile.WorldLocation, out WorldTile tryTile))
            {
                tryTile = tile;
            }
            else
            {
                tileDict.Add(tile.WorldLocation, tile);
            }
        }
    }
Exemple #17
0
    private void Recenter()
    {
        Tilemap tilemap = GetComponent <Tilemap>();

        tilemap.CompressBounds();
        transform.localPosition = -tilemap.localBounds.center;
    }
Exemple #18
0
 public void RecalculateGridBounds()
 {
     tilemap.CompressBounds();
     tilemap.ResizeBounds();
     gridWidth  = tilemap.size.x;
     gridHeight = tilemap.size.y;
 }
Exemple #19
0
        static internal void CompressBounds(MenuCommand item)
        {
            Tilemap tilemap = (Tilemap)item.context;

            Undo.RegisterCompleteObjectUndo(tilemap, "Compress Tilemap Bounds");
            tilemap.CompressBounds();
        }
Exemple #20
0
/*
 * Graph section
 */

    public void InitializeGraph()
    {
        _mapGraph = new LifeGraph();
        MainTilemap.CompressBounds();

        //analyze tilemap and build map graph
        foreach (Vector3Int pos in MainTilemap.cellBounds.allPositionsWithin)
        {
            MapTile tile = MainTilemap.GetTile <Tile>(pos) as MapTile;
            if (tile != null)
            {
                LifeNode centralTileNode = _mapGraph.GetNode(pos) as LifeNode;
                if (centralTileNode == null)
                {
                    centralTileNode        = new LifeNode();
                    centralTileNode.Coords = pos;
                    if (tile.IsBlocked == false)
                    {
                        centralTileNode.Status = LifeNode.NodeStatus.Empty;
                    }
                    else
                    {
                        centralTileNode.Status = LifeNode.NodeStatus.Blocked;
                    }
                    centralTileNode.NewStatus = centralTileNode.Status;
                    _mapGraph.AddNode(centralTileNode);
                }
            }
        }
    }
Exemple #21
0
        public static BoundsInt GetMaxBoundsOfGrid(Grid grid)
        {
            var currentBounds = new BoundsInt();

            for (var i = 0; i < grid.transform.childCount; i++)
            {
                Tilemap child = grid.transform.GetChild(i).GetComponent <Tilemap>();
                child.CompressBounds();
                currentBounds.xMax = (child.cellBounds.xMax > currentBounds.xMax)
                    ? child.cellBounds.xMax
                    : currentBounds.xMax;
                currentBounds.yMax = (child.cellBounds.yMax > currentBounds.yMax)
                    ? child.cellBounds.yMax
                    : currentBounds.yMax;
                currentBounds.xMin = (child.cellBounds.xMin < currentBounds.xMin)
                    ? child.cellBounds.xMin
                    : currentBounds.xMin;
                currentBounds.yMin = (child.cellBounds.yMin < currentBounds.yMin)
                    ? child.cellBounds.yMin
                    : currentBounds.yMin;
            }

            currentBounds.zMin = 0;
            currentBounds.zMax = 1;
            return(currentBounds);
        }
Exemple #22
0
 public void InitTilesFromView()
 {
     // Cache all logic-related data
     _tilemap.CompressBounds();
     _halfCellSize = _tilemap.cellSize;
     _halfCellSize.Scale(new Vector3(0.5f, 0.5f, 1.0f));
 }
    private void UpdateGridProperties()
    {
        // Compress timemap bounds
        tilemap.CompressBounds();

        // Only populate in the editor
        if (!Application.IsPlaying(gameObject))
        {
            if (gridProperties != null)
            {
                Vector3Int startCell = tilemap.cellBounds.min;
                Vector3Int endCell   = tilemap.cellBounds.max;

                for (int x = startCell.x; x < endCell.x; x++)
                {
                    for (int y = startCell.y; y < endCell.y; y++)
                    {
                        TileBase tile = tilemap.GetTile(new Vector3Int(x, y, 0));

                        if (tile != null)
                        {
                            gridProperties.gridPropertyList.Add(new GridProperty(new GridCoordinate(x, y), gridBoolProperty, true));
                        }
                    }
                }
            }
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        if (PlayerController.instance != null)
        {
            target = PlayerController.instance.transform;
        }
        else
        {
            target = GameObject.FindWithTag("Player").transform;
        }


        halfHeight = Camera.main.orthographicSize; //gets the camera half size..
        halfWidth  = halfHeight * Camera.main.aspect;

        //compresses the tilemap size to where only tiles are actually painted

        theMap.CompressBounds();

        //clip the bounds of the camera to the edges of the map.
        bottomLeftLimit = theMap.localBounds.min + new Vector3(halfWidth, halfHeight, 0f);
        topRightLimit   = theMap.localBounds.max + new Vector3(-halfWidth, -halfHeight, 0f);


        PlayerController.instance.setBounds(theMap.localBounds.min, theMap.localBounds.max);
    }
Exemple #25
0
    /*
     * public void setBool()
     *  {
     *  playerSpawned = true;
     *  }
     */
    void Update()
    {
        bool gameActive    = true;
        bool playerSpawned = false;

        if (gameActive == true)
        {
            if (playerSpawned == false)/*(Input.GetKeyDown(KeyCode.Keypad1))*/
            {
                Debug.Log("Gstartet");
                _gameData = GameObject.FindWithTag("GameData").GetComponent <GameData>();
                Debug.Log(_gameData.GetWidth());

                IsoGroundMap.CompressBounds();

                for (int x = 0; x < _gameData.GetWidth(); x++)
                {
                    for (int y = 0; y < _gameData.GetHeight(); y++)
                    {
                        var feld = _gameData.GetFeld(x, y);
                        Debug.Log(_gameData.GetFeld(x, y));
                        if (feld.Terrain == FeldTerrain.Wiese)
                        {
                            Player.layer = 6;
                            Instantiate(Player, IsoGroundMap.GetCellCenterWorld(new Vector3Int(x, y, 0)), Quaternion.identity);
                            Debug.Log("Player was spawned at X: " + (IsoGroundMap.GetCellCenterWorld(new Vector3Int(x, y, 0)).x) + " Y: " + (IsoGroundMap.GetCellCenterWorld(new Vector3Int(x, y, 0)).y) + "Q: " + (Quaternion.identity) + "!");
                            //playerActive = true;
                            return;
                        }
                    }
                }
            }
        }
        playerSpawned = true;
    }
Exemple #26
0
    private void InitializeGraph()
    {
        tilemap.CompressBounds(); //When you draw a tilemap, its size can only grows, by using "CompressBounds" you allow it to shrink to its "real" size
        BoundsInt bounds = tilemap.cellBounds;

        //Creates a dictionary with a node for each tile in "tilemap" wich has for key the coordinates of the tile
        for (int x = bounds.xMin; x < bounds.xMax; x += 1)
        {
            for (int y = bounds.yMin; y < bounds.yMax; y += 1)
            {
                if (tilemap.HasTile(new Vector3Int(x, y, 0)))
                {
                    mazeDic[new Vector2Int(x, y)] = new Node(new Vector2Int(x, y));
                }
            }
        }
        //Puts all the neighbor nodes of each node in its "neighbors" list
        foreach (Vector2Int coord1 in mazeDic.Keys)
        {
            foreach (Vector2Int coord2 in mazeDic.Keys)
            {
                if (coord1 != coord2 &&
                    (((coord1.x - 1 == coord2.x || coord1.x + 1 == coord2.x) && coord1.y == coord2.y) ||
                     ((coord1.y - 1 == coord2.y || coord1.y + 1 == coord2.y) && coord1.x == coord2.x)))
                {
                    mazeDic[coord1].neighbors.Add(mazeDic[coord2]);
                }
            }
        }
    }
Exemple #27
0
    public void CreateGrid(Tilemap floor, Tilemap walls)
    {
        this.floor = floor;
        floor.CompressBounds();
        var bounds = floor.cellBounds;

        grid = new Node[bounds.size.x, bounds.size.y];

        for (int x = bounds.xMin; x < bounds.xMax; x++)
        {
            for (int y = bounds.yMin; y < bounds.yMax; y++)
            {
                var cellPos  = new Vector3Int(x, y, 0);
                var worldPos = floor.CellToWorld(cellPos) + new Vector3(0.5f, 0.5f, 0);
                var result   = Physics2D.OverlapBox(worldPos, Vector2.one * 2, 0, wallMask);
                var walkable = walls.GetTile(cellPos) == null;
                var xGrid    = x - bounds.xMin;
                var yGrid    = y - bounds.yMin;
                grid[xGrid, yGrid] = new Node(walkable, worldPos, xGrid, yGrid, result != null ? 5 : 0);
            }
        }
        lowerLeft       = grid[0, 0].WorldPosition;
        upperRight      = grid[GridSizeX - 1, GridSizeY - 1].WorldPosition;
        worldGridBounds = new Bounds(lowerLeft + (upperRight - lowerLeft) * 0.5f, upperRight - lowerLeft);
    }
Exemple #28
0
 // Start is called before the first frame update
 public int Awake()
 {
     tileMap = GetComponentInChildren <Tilemap>();
     tileMap.CompressBounds();
     width = tileMap.size.x;
     return(0);
 }
Exemple #29
0
    void CreateGrid()
    {
        tileMap.CompressBounds();
        BoundsInt tilemapBounds = tileMap.cellBounds;

        TileBase[] allTiles = tileMap.GetTilesBlock(tilemapBounds);
        grid = new Node[tilemapBounds.size.x, tilemapBounds.size.y];
        for (int x = 0; x < tilemapBounds.size.x; x++)
        {
            for (int y = 0; y < tilemapBounds.size.y; y++)
            {
                TileBase tile     = allTiles[x + y * tilemapBounds.size.x];
                bool     walkable = (tile.name.Contains("Floor"));
                TileType type;
                switch (tile.name)
                {
                case "Floor":
                    type = TileType.FLOOR;
                    break;

                case "Wall":
                    type = TileType.WALL;
                    break;

                default:
                    type = TileType.FLOOR;
                    break;
                }
                grid[x, y] = new Node(walkable, tileMap.GetCellCenterWorld(new Vector3Int(x, y, 0)), x, y, type);
            }
        }
    }
Exemple #30
0
    private void Awake()
    {
        parentGrid = GetComponentInParent <Grid>();
        tilemap    = GetComponent <Tilemap>();
        tilemap.CompressBounds();

        GameObject cell  = Resources.Load("ramka", typeof(GameObject)) as GameObject;
        int        count = 0;

        bounds   = tilemap.cellBounds;
        allTiles = tilemap.GetTilesBlock(bounds);
        cellGrid = new Cell[bounds.size.x * bounds.size.y];
        for (int x = 0; x < bounds.size.x; x++)
        {
            for (int y = 0; y < bounds.size.y; y++)
            {
                TileBase tile = allTiles[x + y * bounds.size.x];
                count++;
                if (tile != null)
                {
                    GameObject currentCell = Instantiate(cell, tilemap.CellToWorld(new Vector3Int(x + bounds.xMin, y + bounds.yMin, 0)) + new Vector3(tilemap.tileAnchor.x, tilemap.tileAnchor.y, 0), Quaternion.identity, cellParentTransform);
                    cellGrid[x + y * bounds.size.x] = currentCell.GetComponent <Cell>();
                }
                else
                {
                    cellGrid[x + y * bounds.size.x] = null;
                }
            }
        }
    }