//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); } }
public DraughtPiece(PlayerColours pieceColour, int horizontalPostion, int verticalPostion) { isKing = false; PieceColour = pieceColour; HorizontalPostion = horizontalPostion; VerticalPostion = verticalPostion; }
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); } } }
private PlayerColours ColourDecrement(PlayerColours c1, PlayerColours c2) { c1--; if (c1 < PlayerColours.Red) { c1 = PlayerColours.Violet; } if (c1 == c2) { c1 = ColourDecrement(c1, c2); } return(c1); }
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; } }
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); }
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); } }
private void CompleteCurrentTurn(PlayerColours currentPlayerColour) { if (IsGameOver()) { gameState = GameStates.GameOver; winner = currentPlayerColour; } else { gameTurn = GetWhosTurnIsIt(gameTurn); UnSelectPiece(); gameState = GameStates.Playing; } }
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(); }
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))); }
public void ForcePlayerToPlay(PlayerColours player) { IsLeftPlayerMove = (player == PlayerColours.Black); }
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); } }
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; }
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; } }
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; }
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); }
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; }
public static string PlayerColourToStr(PlayerColours colour) { return((colour == PlayerColours.Black) ? "b" : "w"); }
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; }
public Player(PlayerTypes playerType, PlayerColours colour) { CurrentNoOfPieces = maximumNoOfPieces; PlayerColour = colour; this.PlayerType = playerType; }
private PlayerColours GetOpponentColour(PlayerColours playerColour) { if (playerColour == PlayerColours.White) return PlayerColours.Black; else return PlayerColours.White; }
public static string genmove(PlayerColours colour) { return(string.Format("genmove {0}", BenzeneUtil.PlayerColourToStr(colour))); }
public void DrawWinner(SpriteBatch spriteBatch, PlayerColours winningColour) { DrawWinningCrown(spriteBatch); DrawWinningLabel(spriteBatch, winningColour); }