Beispiel #1
0
        private void CreateGrid()
        {
            Vector2 size = _cellPrefab.GetComponent <BoxCollider2D>().size + _cellOffset;

            Vector2 cellPosition = transform.position;

            for (int i = 0; i < _grid.GridSize.x; i++)
            {
                for (int j = 0; j < _grid.GridSize.y; j++)
                {
                    FarmCell cell = _grid.GetCell(i, j);

                    _cellGrid[i, j] = Instantiate(_cellPrefab, cellPosition, Quaternion.identity, transform);
                    _cellGrid[i, j].Initialization(cell);

                    if (!cell.IsEmpty)
                    {
                        _cellGrid[i, j]
                        .CreateFarmItem(GetItem(cell.CellItem.ItemType), cell.CellItem);
                    }

                    cellPosition.x += size.x;
                }

                cellPosition.y += size.y;
                cellPosition.x  = transform.position.x;
            }
        }
Beispiel #2
0
        private void EnterInCell(FarmCell cell)
        {
            if (cell == null)
            {
                return;
            }

            if (cell.IsEmpty && _chooseCellForItem)
            {
                _cellGrid[cell.Coordinates.x, cell.Coordinates.y]
                .CreateChooseItem(_chooseFarmItemController.gameObject);
            }
        }
Beispiel #3
0
        private void ClickOnCell(FarmCell cell)
        {
            if (cell == null)
            {
                return;
            }

            if (cell.IsEmpty && _chooseCellForItem)
            {
                _cellGrid[cell.Coordinates.x, cell.Coordinates.y]
                .CreateFarmItem(_chooseFarmItemController);

                _chooseCellForItem        = false;
                _chooseFarmItemController = null;
            }
        }
Beispiel #4
0
 public void Initialization(FarmCell farmCell)
 {
     _farmCell = farmCell;
 }