/// <summary> /// 单机 /// </summary> public void One() { //设置背景色 Console.BackgroundColor = ConsoleColor.DarkYellow; Console.Clear(); //取消玩家2的优先权 u2.main = !u1.main; //设置音效开关 u1.voice = this.voice; u2.voice = this.voice; //玩家2设置信息 u2.SetInfo(); //玩家1设置信息 u1.SetInfo(); //设置玩家2的棋子颜色与玩家1相反 u2.black = !u1.black; //信息栏 Info info = new Info(); string[] black = { "黑棋:", "\t先出棋", "\t开始" }; string[] white = { "白棋", "\t等待黑棋", "\t等待。。。" }; info.ShowInfo(black, white); //创建棋盘 Chessboard board = new Chessboard(); board.Px = 0; board.Py = 5; board.ShowBord(u1.Px, u1.Py, ConsoleColor.Green); board.ShowFrom(); #region 对弈 sbyte success = 0; //胜利方0:平 1:白 -1:黑 for (int i = 0; i < 113; i++) { if (u1.black) { u1.Play(ref board); //玩家1出棋 if (jud.Umpire(board.bord)) //判断胜利方 { success = -1; break; } u2.Play(ref board); //玩家2出棋 if (jud.Umpire(board.bord)) //判断胜利方 { success = 1; break; } } else { u2.Play(ref board); //玩家2出棋 if (jud.Umpire(board.bord)) //判断胜利方 { success = -1; break; } u1.Play(ref board); //玩家1出棋 if (jud.Umpire(board.bord)) //判断胜利方 { success = 1; break; } } } #endregion #region 显示对弈结果 for (int i = 0; i < 10; i++) { //sleep一下 System.Threading.Thread.Sleep(100 + i * 60); Console.MoveBufferArea(0, i, Console.WindowWidth, 5, 0, i + 1, '*', ConsoleColor.Yellow, ConsoleColor.Red); } Console.SetCursorPosition(15, 6); this.PlayMusic("game over.wav", false); //sleep一下 System.Threading.Thread.Sleep(600); if (u1.black) { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; if (success == -1) { Console.Write("●胜利!"); } if (success == 1) { Console.Write("●失败"); } } else { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; if (success == 1) { Console.Write("●胜利!"); } if (success == -1) { Console.Write("●失败"); } } Console.ForegroundColor = ConsoleColor.Green; if (success == 0) { Console.Write("完美●平局"); } #endregion }