Beispiel #1
0
        // ------------------------
        // Undo
        // ------------------------

        #region UNDO
        public void AddToActionStack(CellScript _cell)
        {
            BoardAction boardAction = new BoardAction();

            // finding where the cell is on the list
            int index = m_cellList.FindIndex(cell => {
                return(cell == _cell);
            });

            boardAction.cellListPosition  = index;
            boardAction.currentCellStatus = GetSerializableCellFromCellScript(_cell);

            m_actionStack.Push(boardAction);
        }
Beispiel #2
0
        public void GenerateEmptyBoard(int _size)
        {
            DestroyAllChildren(gridObject.transform);
            InitializeDependencies();
            GridLayoutGroup gridLayoutGroup = gridObject.GetComponent <GridLayoutGroup>();

            gridLayoutGroup.constraintCount = _size;

            for (int i = 0; i < (_size * _size); i++)
            {
                CellScript cell = Instantiate(singleCellPrefab, gridObject.transform).GetComponent <CellScript>();
                cell.InitializeEmptyCell();
                m_cellList.Add(cell);
            }
        }
Beispiel #3
0
        private void GenerateBoard(SerializableBoard _board)
        {
            InitializeDependencies();
            GridLayoutGroup gridLayoutGroup = gridObject.GetComponent <GridLayoutGroup>();

            gridLayoutGroup.constraintCount = _board.boardSize;

            for (int i = 0; i < (_board.boardSize * _board.boardSize); i++)
            {
                // Instantiating Cells
                CellScript instantiatedCell = Instantiate(singleCellPrefab, gridObject.transform).GetComponent <CellScript>();
                instantiatedCell.FetchDependencies();
                instantiatedCell.CopyFrom(_board.serializableGrid[i]);
                instantiatedCell.UpdateUI();
                m_cellList.Add(instantiatedCell);
            }
        }
Beispiel #4
0
        public SerializableCell GetSerializableCellFromCellScript(CellScript _cellScript)
        {
            if (_cellScript.cellType == CellScript.ECellType.None && _cellScript.cellStatus == CellScript.ECellStatus.None)
            {
                _cellScript.cellType   = CellScript.ECellType.Unused;
                _cellScript.cellStatus = CellScript.ECellStatus.Unused;
            }

            string content = "";

            if (_cellScript.cellType == CellScript.ECellType.Number)
            {
                content = _cellScript.intCellContent.ToString();
            }
            else if (_cellScript.cellType == CellScript.ECellType.Operation)
            {
                content = _cellScript.charCellContent.ToString();
            }

            return(new SerializableCell(_cellScript.cellStatus.GetHashCode(), _cellScript.cellType.GetHashCode(), content));
        }