Exemplo n.º 1
0
        private static Action CreateUpdateBoardAction(JObject jObject)
        {
            var action = new UpdateBoardAction();

            ApplyUpdateData(action.Data, jObject);
            return(action);
        }
Exemplo n.º 2
0
    public void Redo()
    {
        undoStack.Push(currentPuzzleData.cellData.Cells.Clone() as CellType[, ]);

        RedrawGameBoard(redoStack.Pop());
        UpdateRowColumnData();
        UpdateBoardAction.Invoke(currentPuzzleData.cellData);
    }
Exemplo n.º 3
0
    //fill in all cells in all elements of hintCellCoordinates
    //elements of hintcellCoordinates are determined by HintHandler
    void FillHintCells(List <Vector2Int> hintCellCoordinates)
    {
        Do(currentPuzzleData.cellData.Cells.Clone() as CellType[, ]);

        hintCellCoordinates.ForEach(i =>
        {
            SetCellType(i.x, i.y, CellType.Filled);
        });

        UpdateRowColumnData();
        UpdateBoardAction.Invoke(currentPuzzleData.cellData);
    }
Exemplo n.º 4
0
    public void Restart()
    {
        for (int r = 0; r < targetPuzzleData.RowCount; r++)
        {
            for (int c = 0; c < targetPuzzleData.ColCount; c++)
            {
                SetCellType(r, c, CellType.Empty);
            }
        }

        undoStack.Clear();
        redoStack.Clear();

        UpdateRowColumnData();
        UpdateBoardAction.Invoke(currentPuzzleData.cellData);
    }
Exemplo n.º 5
0
    void SetCells(List <Vector2Int> selectedCells)
    {
        //make sure at least 1 cell is selected
        if (selectedCells.Count == 0)
        {
            return;
        }

        //push current puzzle data
        Do(currentPuzzleData.cellData.Cells.Clone() as CellType[, ]);

        //determine whether or not all CellTypes are the same within selectedCells
        bool allSameCellType = false;

        if (selectedCells.Count == 1)
        {
            allSameCellType = true;
        }
        else
        {
            allSameCellType = selectedCells.TrueForAll(i => cells[i.x, i.y].CurrentCellType == cells[selectedCells[0].x, selectedCells[0].y].CurrentCellType);
        }

        //set CellType based on current CellType and current input tool
        foreach (var cell in selectedCells)
        {
            switch (currentInputTool)
            {
            case InputTool.Pencil:
                switch (cells[cell.x, cell.y].CurrentCellType)
                {
                case CellType.Empty:
                    SetCellType(cell.x, cell.y, CellType.Filled);
                    break;

                case CellType.Filled:
                    if (allSameCellType)
                    {
                        SetCellType(cell.x, cell.y, CellType.Empty);
                    }
                    break;

                case CellType.Crossed:
                    if (allSameCellType)
                    {
                        SetCellType(cell.x, cell.y, CellType.Filled);
                    }
                    break;
                }
                break;

            case InputTool.Eraser:
                switch (cells[cell.x, cell.y].CurrentCellType)
                {
                case CellType.Empty:
                    SetCellType(cell.x, cell.y, CellType.Crossed);
                    break;

                case CellType.Filled:
                    SetCellType(cell.x, cell.y, CellType.Crossed);
                    break;

                case CellType.Crossed:
                    if (allSameCellType)
                    {
                        SetCellType(cell.x, cell.y, CellType.Empty);
                    }
                    break;
                }
                break;
            }
        }

        UpdateRowColumnData(selectedCells);
        UpdateBoardAction.Invoke(currentPuzzleData.cellData);
    }