Esempio n. 1
0
        public bool GetFigureColor(Cell cell)  //Pass to BoardVisual
        {
            bool       ifColored        = false;
            BoardColor figureBoardColor = BoardColor.NoColor;

            if (cell != null)
            {
                if (cell is CellFigure)
                {
                    if ((cell as CellFigure).FigureColor == ChessColor.White)
                    {
                        figureBoardColor = VisualBoard.WHITE_FIGURE_COLOR;
                    }
                    else
                    {
                        figureBoardColor = VisualBoard.BLACK_FIGURE_COLOR;
                    }
                    ifColored = true;
                }
                else
                {
                    FigureColor = BoardColor.NoColor;
                }
            }

            FigureColor = figureBoardColor;
            return(ifColored);
        }
Esempio n. 2
0
    // Start is called before the first frame update
    void Start()
    {
        currentTurnID    = players[currentTurn].ID;
        currentTurnColor = players[currentTurn].boardColor;
        SetupBoard();

        UpdateCanvas(currentTurnColor);
    }
Esempio n. 3
0
    public PathPiece GetSpawnPathPieceFromColor(BoardColor boardColor)
    {
        for (int i = 0; i < players.Length; i++)
        {
            if (players[i].boardColor == boardColor)
            {
                return(players[i].boardArea.startPoint.GetComponent <PathPiece>());
            }
        }

        return(null);
    }
Esempio n. 4
0
    public Vector2 GetPieceSpawnPointFromColor(BoardColor boardColor)
    {
        for (int i = 0; i < players.Length; i++)
        {
            if (players[i].boardColor == boardColor)
            {
                return(players[i].boardArea.startPoint.position);
            }
        }

        return(new Vector2());
    }
Esempio n. 5
0
    public Color GetColorFromEnum(BoardColor boardColor)
    {
        for (int i = 0; i < colorToEnums.Length; i++)
        {
            if (colorToEnums[i].boardColor == boardColor)
            {
                return(colorToEnums[i].color);
            }
        }

        return(Color.white);
    }
    public void DropPieceAt(int column, BoardColor color)
    {
        for (int height = 0; height < _boardHeight; height++)
        {
            if (_boxes[column, height].State != BoxState.Empty)
            {
                continue;
            }

            _boxes[column, height].State = (BoxState)color;
            break;
        }
    }
Esempio n. 7
0
    private void GameEndMessage(int blackScore, int whiteScore, BoardColor winnerColor)
    {
        var winner  = winnerColor == BoardColor.Black ? "Черный" : "Белый";
        var message = $"Игра окончена со счетом:\n" +
                      $"Черные - {blackScore}\n" +
                      $"Белые - {whiteScore}\n" +
                      $"Победитель - {winner}\n" +
                      "Еще партию?";
        var caption = "Игра окончена.";
        var result  = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

        if (result == DialogResult.No)
        {
            Close();
        }
    }
Esempio n. 8
0
    public void SwitchTurn()
    {
        diceRolled = false;
        if (currentDiceNumber != 6)
        {
            currentTurn++;

            if (currentTurn == players.Length)
            {
                currentTurn = 0;
            }

            currentTurnID    = players[currentTurn].ID;
            currentTurnColor = players[currentTurn].boardColor;

            UpdateCanvas(currentTurnColor);
        }
    }
Esempio n. 9
0
        public bool GetCellColor(Cell cell)
        {
            bool       ifColored      = false;
            BoardColor cellBoardColor = BoardColor.NoColor;

            if (cell != null)
            {
                if (cell.CellColor == ChessColor.White)
                {
                    cellBoardColor = VisualBoard.WHITE_CELL_COLOR;
                }
                else
                {
                    cellBoardColor = VisualBoard.BLACK_CELL_COLOR;
                }
                ifColored = true;
            }

            CellColor = cellBoardColor;
            return(ifColored);
        }
Esempio n. 10
0
 private void ChangeScore(BoardColor addScoreColor, int scoreToAdd)
 {
     Score[addScoreColor] += scoreToAdd;
     ScoreChanged?.Invoke(addScoreColor);
 }
Esempio n. 11
0
 public static ConsoleColor ToConsoleColor(BoardColor boardColor)
 {
     return((ConsoleColor)boardColor);
 }
Esempio n. 12
0
 private void UpdateCanvas(BoardColor boardColor)
 {
     currentTurnText.text  = boardColor.ToString();
     currentTurnText.color = GetColorFromEnum(boardColor);
 }