/// <summary> /// Устанавливает следующего ходящего /// </summary> /// <param name="loser"></param> private void SetNextMover(GamePlayer loser = null) { if (CurrentMover == null) { CurrentMover = GamePlayers.First(p => p.Priority == GamePlayers.Min(pm => pm.Priority)).Player; } else if (loser == null || loser.Player.Id == CurrentMover.Id) { CurrentMover = GetNextMover().Player; } }
private GamePlayer GetNextMover() { var gamePlayer = GamePlayers.First(gp => gp.Player.Id == CurrentMover.Id); if (GamePlayers.Max(gp => gp.Priority) == gamePlayer.Priority) { return(GamePlayers.First(gp => gp.Priority == GamePlayers.Min(p => p.Priority))); } else { return(GamePlayers .Where(gp => gp.Priority > gamePlayer.Priority) .First(gp => gp.Priority == GamePlayers.Where(p => p.Priority > gamePlayer.Priority).Min(p => p.Priority))); } }
/// <summary> /// 更新显示玩家信息 /// </summary> /// <param name="row"></param> /// <param name="col"></param> private void UpdatePlayerInfo(int row, int col, bool isReset = false, bool init = false) { Draw.FillRectangle(WhiteBrush, new Rectangle(0, 0, LayoutMap.Width, TitleHeight)); var p1 = GamePlayers.First() as FiveGamePlayer; var p2 = GamePlayers.Last() as FiveGamePlayer; int x = 5; int y_one = 0; int offset = 2; var Pixel = this.Pixel - 5; Draw.FillEllipse(Brushes[p1.Index - 1], new Rectangle(x, y_one, Pixel, Pixel)); Draw.DrawString(":" + p1.PlayerNickName, TextFont, BlackBrush, new PointF(x + Pixel + offset, y_one)); int y = y_one + Pixel + offset; Draw.FillEllipse(Brushes[p2.Index - 1], new Rectangle(x, y, Pixel, Pixel)); Draw.DrawString(":" + p2.PlayerNickName, TextFont, BlackBrush, new PointF(x + Pixel + offset, y)); if (!init) { string conent = isReset ? "玩家悔棋!" : "当前玩家:{0}, 下子:[{1},{2}]".Format(DoPlayer.PlayerNickName, row + 1, col + 1); Draw.DrawString(conent, TextFont, BlackBrush, new PointF(x, y + this.Pixel + offset)); } }