public void SwapBlockFromTo(VisualCell from, VisualCell to) { var block = from.VisualBlock; from.UnbindBlock(); to.SetBlock(block); }
public void GenerateBoard(Cell[,] boardCells) { _sizeX = boardCells.GetLength(0); _sizeY = boardCells.GetLength(1); _visualCells = new VisualCell[_sizeX, _sizeY]; for (int x = 0; x < _sizeX; x++) { for (int y = 0; y < _sizeY; y++) { //Create Cell VisualCell cell = Instantiate(_cellPref, transform); _visualCells[x, y] = cell; cell.Init(boardCells[x, y]); var cellTransform = cell.transform; cellTransform.position = new Vector3(x, y, 0); VisualBlock block = Instantiate(_blockPref, cellTransform); block.Init(boardCells[x, y].Block); cell.SetBlock(block, false); } } //Center the level map on the game screen transform.localPosition = new Vector2(-(_sizeX - 1) / 2.0f, -(_sizeY - 1) / 2.0f); BlockPlayersInput(false); Debug.Log($"Visual map was generated, size{_sizeX}x{_sizeY}"); }