Exemple #1
0
    private bool PlayerDidWin(PlayerColor player)
    {
        // Get the piece count for the other player
        var pieceCount = (player == PlayerColor.Black) ? _redPieceCount : _blackPieceCount;

        // TODO: Find out if the other player has any moves left

        // If the other player is out of pieces, this player won
        return(pieceCount == 0);
    }
Exemple #2
0
    void NextTurn()
    {
        if (playerTurn == Piece.PlayerColor.WHITE)
        {
            playerTurn = Piece.PlayerColor.BLACK;
            return;
        }

        playerTurn = Piece.PlayerColor.WHITE;
    }
Exemple #3
0
 public void CapturePiece(PlayerColor player)
 {
     if (player == PlayerColor.Black)
     {
         _blackPieceCount -= 1;
     }
     else
     {
         _redPieceCount -= 1;
     }
 }
Exemple #4
0
    // Instantiate a piece of the given type and color at the given location
    public Piece InstantiatePiece(Piece.PlayerColor _playerColor, Piece.ChessPieceType _chessPieceType, int _x, int _y)
    {
        GameObject _newGameObject = Instantiate(piecePrefab, Vector3.zero, Quaternion.identity);
        Piece      _newPiece      = _newGameObject.GetComponent <Piece>();

        _newPiece.playerColor    = _playerColor;
        _newPiece.chessPieceType = _chessPieceType;
        _newPiece.boardPosition  = new Vector2Int(_x, _y);
        _newPiece.Initialize();
        return(_newPiece);
    }
Exemple #5
0
 public void SetSprite(Piece.PlayerColor color, Piece.Type type)
 {
     if (color == Piece.PlayerColor.WHITE)
     {
         SetSprite(_whiteSprites, type.ToString());
     }
     else
     {
         SetSprite(_blackSprites, type.ToString());
     }
 }
Exemple #6
0
 public void PlayerWon(Piece.PlayerColor player)
 {
     _turnIndicatorMessage.text = $"{player.ToString()} Won!";
 }