private Player GetNextPlayer() { if (CurrentPlayer != null) { Quadrant currentQuadrant = CurrentPlayer.Quadrant; while (true) { Quadrant nextQuadrant = this.GameBoardForm.GetNextQuadrant(currentQuadrant); for (int i = 0; i < this.Players.Count; i++) { if (this.Players[i] != null && this.Players[i].Quadrant == nextQuadrant) { return(this.Players[i]); } else { currentQuadrant = nextQuadrant; continue; } } } } return(null); }
// 4. SetCurrentPlayer private void SetPiecePosition(Player player, GamePlayerPiecePosition gamePlayerPiecePosition) { Quadrant quadrant = GameBoardForm.Quadrants[gamePlayerPiecePosition.Quadrant]; Ghor ghor; if (gamePlayerPiecePosition.GhorType == "Home") { ghor = quadrant.QuadrantHome.GhorPositions[gamePlayerPiecePosition.GhorPosition]; } else { ghor = quadrant.GetGhorByPosition(gamePlayerPiecePosition.GhorPosition); } try { Piece piece = player.Pieces[gamePlayerPiecePosition.PieceNumber]; piece.Movable = false; //player.Pieces[gamePlayerPiecePosition.PieceNumber].TransitionPositions = new List<GameBoardPosition> //{ // new GameBoardPosition(quadrant, ghor) //}; //ShowTransitions(player.Pieces[gamePlayerPiecePosition.PieceNumber]); piece.GameBoardPosition = new GameBoardPosition(quadrant, ghor); ghor.UIControl.Controls.Add(piece.UIControl); piece.UIControl.BringToFront(); } catch (Exception) { } }
private bool TakeOpponentPiece(Piece piece) { foreach (Player player in Players) { if (CurrentPlayer != null && player != null && player != CurrentPlayer) { foreach (Piece piece1 in player.Pieces) { if (piece1.GameBoardPosition.Ghor.Position == piece.GameBoardPosition.Ghor.Position && piece1.GameBoardPosition.Quadrant.QuadrantPosition == piece.GameBoardPosition.Quadrant.QuadrantPosition) { Quadrant quadrant = player.Quadrant; piece1.GameBoardPosition.Quadrant = quadrant; piece1.GameBoardPosition.Ghor = quadrant.QuadrantHome.GhorPositions[piece1.Position]; piece1.TransitionPositions = new List <GameBoardPosition> { piece1.GameBoardPosition }; ShowTransitions(piece1); Load(); return(true); } } } } return(false); }
private void CreateQuadrants() { for (int i = 0; i < Quadrants.Length; i++) { Quadrants[i] = new Quadrant(i, BoardSize); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(Quadrants[i].UIControl.Container); } }
public QuadrantRenderer(Quadrant quadrant) { Quadrant = quadrant; QuadrantHomeRenderer = new QuadrantHomeRenderer(Quadrant.QuadrantHome); this.SetInitialParameters(quadrant.BoardSize, Quadrant.QuadrantPosition); this.Renderer(Quadrant.QuadrantPosition); this.timer1 = new System.Windows.Forms.Timer(); this.timer1.Interval = 300; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); }
public GameBoardPosition GetNextGhor(GameBoardPosition gameBoardPosition, Player player) { if (gameBoardPosition != null) { Ghor ghor = gameBoardPosition.Ghor; Quadrant quadrant = gameBoardPosition.Quadrant; if (ghor != null && ghor.Position == 18) { return(null); } else if (ghor.GhorType == GhorType.Home) { // Move to Home Star gameBoardPosition.Ghor = quadrant.GhorPath[1]; } else if (ghor.Position == 11) { //Move to Next Quadrant gameBoardPosition.Quadrant = this.GetNextQuadrant(quadrant); gameBoardPosition.Ghor = gameBoardPosition.Quadrant.GhorPath[12]; } else if (ghor.Position == 12) { if (gameBoardPosition.Quadrant.Color == player.Color) { // Move to Final Line gameBoardPosition.Ghor = gameBoardPosition.Quadrant.GhorPath[13]; } else { gameBoardPosition.Ghor = gameBoardPosition.Quadrant.GhorPath[0]; } } else if (ghor == quadrant.GetLastGhor()) { // Matured gameBoardPosition.Ghor = new Ghor(18); } else { // Proceed One ghor gameBoardPosition.Ghor = quadrant.GhorPath[ghor.Position + 1]; } return(gameBoardPosition); } else { return(null); } }
public Quadrant GetNextQuadrant(Quadrant quadrant) { switch (quadrant.Color) { case Color.Red: return(Quadrants[1]); case Color.Green: return(Quadrants[2]); case Color.Blue: return(Quadrants[3]); case Color.Yellow: return(Quadrants[0]); default: return(null); } }
public GameBoardPosition(Quadrant quadrant, Ghor ghor) { Quadrant = quadrant; Ghor = ghor; }