Beispiel #1
0
 //Converts the PlayerColours enum to actual colours you can initialize the players with
 private Color ColourConverter(PlayerColours c)
 {
     if (c == PlayerColours.Red)
     {
         return(Color.Red);
     }
     else if (c == PlayerColours.Orange)
     {
         return(Color.Orange);
     }
     else if (c == PlayerColours.Yellow)
     {
         return(Color.Yellow);
     }
     else if (c == PlayerColours.Green)
     {
         return(Color.Green);
     }
     else if (c == PlayerColours.Blue)
     {
         return(Color.Blue);
     }
     else if (c == PlayerColours.Indigo)
     {
         return(Color.Indigo);
     }
     else if (c == PlayerColours.Violet)
     {
         return(Color.Violet);
     }
     else
     {
         return(Color.White);
     }
 }
Beispiel #2
0
 public DraughtPiece(PlayerColours pieceColour, int horizontalPostion, int verticalPostion)
 {
     isKing = false;
     PieceColour = pieceColour;
     HorizontalPostion = horizontalPostion;
     VerticalPostion = verticalPostion;
 }
Beispiel #3
0
        public void HandleInput()
        {
            if (SwinGame.MouseClicked(MouseButton.LeftButton))
            {
                //1p Survival
                if (MouseRegion(30, 180, 350, 60))
                {
                    _gameHandler.GameState   = EnumState.Survival;
                    _gameHandler.Multiplayer = false;
                }

                //1p Score Attack
                if (MouseRegion(30, 270, 350, 60))
                {
                    _gameHandler.GameState   = EnumState.Timed;
                    _gameHandler.Multiplayer = false;
                }
                //2p Survival
                if (MouseRegion(30, 460, 350, 60))
                {
                    _gameHandler.GameState   = EnumState.Survival;
                    _gameHandler.Multiplayer = true;
                }
                //2p Score Attack
                if (MouseRegion(30, 540, 350, 60))
                {
                    _gameHandler.GameState   = EnumState.Timed;
                    _gameHandler.Multiplayer = true;
                }
                //2p Battle
                if (MouseRegion(30, 630, 350, 60))
                {
                    _gameHandler.GameState   = EnumState.Battle;
                    _gameHandler.Multiplayer = true;
                }

                //P1 Colour Left
                if (MouseRegion(660, 620, 135, 60))
                {
                    _p1Colour = ColourDecrement(_p1Colour, _p2Colour);
                }
                //P1 Colour Right
                if (MouseRegion(805, 620, 135, 60))
                {
                    _p1Colour = ColourIncrement(_p1Colour, _p2Colour);
                }
                //P2 Colour Left
                if (MouseRegion(960, 620, 135, 60))
                {
                    _p2Colour = ColourDecrement(_p2Colour, _p1Colour);
                }
                //P2 Colour Right
                if (MouseRegion(1105, 620, 135, 60))
                {
                    _p2Colour = ColourIncrement(_p2Colour, _p1Colour);
                }
            }
        }
Beispiel #4
0
 private PlayerColours ColourDecrement(PlayerColours c1, PlayerColours c2)
 {
     c1--;
     if (c1 < PlayerColours.Red)
     {
         c1 = PlayerColours.Violet;
     }
     if (c1 == c2)
     {
         c1 = ColourDecrement(c1, c2);
     }
     return(c1);
 }
Beispiel #5
0
 private PlayerColours ColourIncrement(PlayerColours c1, PlayerColours c2)
 {
     c1++;
     if (c1 > PlayerColours.Violet)
     {
         c1 = PlayerColours.Red;
     }
     if (c1 == c2)
     {
         c1 = ColourIncrement(c1, c2);
     }
     return(c1);
 }
 public void ShowWinner(List <Vector2Int> winningLine, PlayerColours winnerColours)
 {
     foreach (Transform piece in _piecesRoot)
     {
         if (piece.GetComponent <Piece>().PlayerColours == winnerColours)
         {
             piece.GetComponent <Animator>().SetTrigger(FlashPiecesHash);
         }
     }
     foreach (var location in winningLine)
     {
         _tiles[_board.GetBoardIndexFromLocation(location)].GetComponent <MeshRenderer>().material =
             (winnerColours == PlayerColours.White) ? _whiteTileBorderMaterial : _blackTileBorderMaterial;
     }
 }
Beispiel #7
0
        public int EvaluateBoard(PlayerColours playerColour)
        {
            const int MAXIMUMNUMBEROFOPPONENTPIECES = 12;
            int normalPieces = 0, kingPieces = 0, opponentPieces = 0;

            for (int i = 0; i <= GAMEBOARDWIDTH - 1; i++)
                for (int j = 0; j <= GAMEBOARDHEIGHT - 1; j++)
                {
                    if (gameBoardSpaces[i, j] != null)
                        if (gameBoardSpaces[i, j].PieceColour == playerColour)
                        {
                            if (gameBoardSpaces[i, j].IsKing == true)
                                kingPieces++;
                            else
                                normalPieces++;
                        }
                        else
                            opponentPieces++;
                }

            return normalPieces + (kingPieces * 3) + (MAXIMUMNUMBEROFOPPONENTPIECES - opponentPieces);
        }
Beispiel #8
0
 private void HandleAdditionalJumps(PlayerColours colour)
 {
     if (gameState == GameStates.NextJump)
     {
         Point jumpAbleSquare = new Point(selectedPiece.HorizontalPostion, selectedPiece.VerticalPostion);
         XNAGameBoardPostion selectedSquare = new XNAGameBoardPostion(jumpAbleSquare);
         HighLightPossibleJumps(selectedPiece, colour);
     }
 }
Beispiel #9
0
 private void CompleteCurrentTurn(PlayerColours currentPlayerColour)
 {
     if (IsGameOver())
     {
         gameState = GameStates.GameOver;
         winner = currentPlayerColour;
     }
     else
     {
         gameTurn = GetWhosTurnIsIt(gameTurn);
         UnSelectPiece();
         gameState = GameStates.Playing;
     }
 }
Beispiel #10
0
 private void DrawWinningLabel(SpriteBatch spriteBatch, PlayerColours winningColour)
 {
     spriteBatch.Begin();
     if (winningColour == PlayerColours.Black)
         spriteBatch.Draw(blackWins, new Rectangle(0, 0, 480, 100), Color.White);
     else
         spriteBatch.Draw(whiteWins, new Rectangle(0, 0, 480, 100), Color.White);
     spriteBatch.End();
 }
Beispiel #11
0
 public readonly static string clear_board = "clear_board";    public static string play(PlayerColours colour, Move move)
 {
     return(string.Format("play {0} {1}", BenzeneUtil.PlayerColourToStr(colour), BenzeneUtil.MoveToHexPoint(move)));
 }
Beispiel #12
0
 public void ForcePlayerToPlay(PlayerColours player)
 {
     IsLeftPlayerMove = (player == PlayerColours.Black);
 }
Beispiel #13
0
 private void HighLightPossibleMoves(DraughtPiece selectedPiece, PlayerColours colour)
 {
     List<GamePieceMove> moves;
     squaresMovableTo = new List<Rectangle>();
     moves = gameBoard.GetAllPossibleMovesForThisPiece(selectedPiece);
     foreach (GamePieceMove move in moves)
     {
             Rectangle rect = xnaGameBoard.BoardSpaces[move.NewHorizontalPostion, move.NewVerticalPostion];
             squaresMovableTo.Add(rect);
     }
 }
Beispiel #14
0
 public List<GamePieceMove> GetAllPossibleMoves(PlayerColours colour)
 {
     List<GamePieceMove> allPossibleMoves = new List<GamePieceMove>();
     allPossibleMoves.AddRange(GetAllPossibleJumps(colour));
     if(forcedJumpsOn && allPossibleMoves.Count == 0)
         allPossibleMoves.AddRange(GetAllPossibleNormalMoves(colour));
     else if(!forcedJumpsOn)
         allPossibleMoves.AddRange(GetAllPossibleNormalMoves(colour));
     return allPossibleMoves;
 }
Beispiel #15
0
 private void HandleBlackTurnForAIPlayer()
 {
     List<GamePieceMove> aiMoves = ai.GetAIMoves(gameBoard.CloneBoard());
     foreach(GamePieceMove move in aiMoves)
         gameBoard.ApplyMove(move);
     gameTurn = PlayerTurn.WhiteTurn;
     if (IsGameOver())
     {
         gameState = GameStates.GameOver;
         winner = PlayerColours.Black;
     }
 }
Beispiel #16
0
        public List<GameBoard> GetPossibleBoards(PlayerColours colour)
        {
            List<GameBoard> allPossibleBoards = new List<GameBoard>();

            foreach (GamePieceMove move in GetAllPossibleMoves(colour))
            {
                GameBoard newBoard = this.CloneBoard();
                newBoard.ApplyMove(move);
                allPossibleBoards.Add(newBoard);

            }
            return allPossibleBoards;
        }
Beispiel #17
0
 private void HandleTurnForHumanPlayer(PlayerColours currentPlayerColour, XNAGameBoardPostion selectedPoint)
 {
     switch (gameState)
         {
             case GameStates.Playing:
                 GetSelectedPiece(selectedPoint);
                 if(selectedPiece!=null)
                     if (gameBoard.IsMovablePieceSelected(selectedPiece, currentPlayerColour))
                     {
                         HighLightPossibleMoves(selectedPiece, currentPlayerColour);
                         gameState = GameStates.PieceSelected;
                     }
                     break;
             case GameStates.PieceSelected:
                 if (IsNextClickAMove())
                 {
                     if (MakeMove(selectedPoint))
                         CompleteCurrentTurn(currentPlayerColour);
                     else
                         gameState = GameStates.NextJump;
                 }
                 else
                 {
                     UnSelectPiece();
                     gameState = GameStates.Playing;
                 }
                 break;
             case GameStates.NextJump:
                 if (IsNextClickAMove())
                 {
                     if (MakeMove(selectedPoint))
                         CompleteCurrentTurn(currentPlayerColour);
                 }
                 break;
         }
     HandleAdditionalJumps(currentPlayerColour);
 }
Beispiel #18
0
 public Boolean IsMovablePieceSelected(DraughtPiece selectedPiece, PlayerColours colour)
 {
     bool allMovesFound = true;
     List<GamePieceMove> allPossibleMove = GetAllPossibleMoves(colour);
     List<GamePieceMove> allPossibleMoveForThisPiece = GetAllPossibleMovesForThisPiece(selectedPiece);
     foreach (GamePieceMove move in allPossibleMoveForThisPiece)
     {
         if (!allPossibleMove.Contains(move))
             allMovesFound = false;
     }
     return allMovesFound;
 }
Beispiel #19
0
 public static string PlayerColourToStr(PlayerColours colour)
 {
     return((colour == PlayerColours.Black) ? "b" : "w");
 }
Beispiel #20
0
 private List<GamePieceMove> GetAllPossibleNormalMoves(PlayerColours colour)
 {
     List<GamePieceMove> allPossibleNormalMoves = new List<GamePieceMove>();
     for (int i = 0; i <= GAMEBOARDWIDTH - 1; i++)
         for (int j = 0; j <= GAMEBOARDHEIGHT - 1; j++)
         {
             if (gameBoardSpaces[i, j] != null)
                 if (gameBoardSpaces[i, j].PieceColour == colour)
                     allPossibleNormalMoves.AddRange(GetAllPossibleNormalMovesForThisPiece(gameBoardSpaces[i, j]));
         }
     return allPossibleNormalMoves;
 }
Beispiel #21
0
 public Player(PlayerTypes playerType, PlayerColours colour)
 {
     CurrentNoOfPieces = maximumNoOfPieces;
     PlayerColour = colour;
     this.PlayerType = playerType;
 }
Beispiel #22
0
 private PlayerColours GetOpponentColour(PlayerColours playerColour)
 {
     if (playerColour == PlayerColours.White)
         return PlayerColours.Black;
     else
         return PlayerColours.White;
 }
Beispiel #23
0
 public static string genmove(PlayerColours colour)
 {
     return(string.Format("genmove {0}", BenzeneUtil.PlayerColourToStr(colour)));
 }
Beispiel #24
0
 public void DrawWinner(SpriteBatch spriteBatch, PlayerColours winningColour)
 {
     DrawWinningCrown(spriteBatch);
     DrawWinningLabel(spriteBatch, winningColour);
 }