void Update() { GameObject g = GameObject.Find("Board"); Checkers.Game game = BoardController.currentGame; if (game != null) { int w = 0, b = 0; foreach (Checkers.Piece piece in game.WhitePieces) { if (piece.Dead != 1) { w++; } } foreach (Checkers.Piece piece in game.BlackPieces) { if (piece.Dead != 1) { b++; } } text1.text = "White Pieces\n " + w; text2.text = "Black Pieces\n " + b; if (board.GetComponent <BoardController>().IsReady) { SetTime(); } } }
static void Main() { var meny = new SimpleMenu(@"main.bgr", ConsoleColor.Black, 1, 1, '*'); var musicForStart = new Audio(@"Logo.mp3"); var musicForEnd = new Audio(@"Game Over.mp3"); musicForStart.Play(); Console.Title = "ITLabs - Checkers v1.0"; Console.ForegroundColor = ConsoleColor.Green; Console.WindowWidth = 90; Console.WindowHeight = 30; meny.AddItem(41, 16, "S T A R T"); meny.AddItem(41, 18, " E X I T"); var choose = meny.StartMenu(); var game = new Game(); switch (choose) { case 1: Console.Clear(); musicForStart.Stop(); game.Start(); while (!game.IsGameOver()) { game.FindCheckersWithTakes(); game.SetMove(); game.SwitchPlayer(); } game.ClearMessageBar(); Console.SetCursorPosition(50, 10); Console.Write("Game Over"); musicForEnd.Play(); Console.ReadLine(); break; case 2: Environment.Exit(0); break; } }
public void initGame() { try { //Create a new game object game = new Game(); //Create me as the player Player player = new Player("Jessica", ChipColor.Red, Seat.Top); //Create the computer player. Player computer = new Player("Easy Computer", ChipColor.Black, Seat.Bottom); //Make sure to create the players list if it's null game.Players = game.Players == null ? new List<Player>() : game.Players; //Add the player to the master list game.Players.Add(player); //Add the computer to the master list game.Players.Add(computer); loadBoard(); loadChipsForPlayers(); assignAllChipsToBoard(); drawChips(); } catch (Exception ex) { MessageBox.Show(String.Format("{0}", ex.Message)); } }
public static void Gaming() { Logs.AddToLog("Game #" + GamesCount + ". " + firstPlayerFile + "(White) versus " + secondPlayerFile + "(Black). Let the battle begin!"); var movesCount = 0; var white = new MyRemotePlayer(firstPlayerFile, Color.White); var black = new MyRemotePlayer(secondPlayerFile, Color.Black); var validator = new Validator(); var field = new Game().CreateMap(); while (true) { movesCount++; if (movesCount > 150) { Logs.AddToLog("i'm done. it's a draw"); if (GamesCount != BestOf) { GamesCount++; var thr = new Thread(Gaming); thr.Start(); Thread.CurrentThread.Abort(); } else { Environment.Exit(0); Logs.Done(); } } if (usingTimer && movesCount > 1) { time.Reset(); time.Start(); } validator.IsCorrectMove(white.MakeTurn(field), field, Color.White); if (usingTimer && movesCount > 1) { time.Stop(); var ms = time.Elapsed.Milliseconds; Logs.AddToLog(ms.ToString()); MaxWhite = Math.Max(MaxWhite, ms); } if (usingForm) { Window.BeginInvoke(new Action<Checker[,]>(Window.Update), new object[] { field }); Thread.Sleep(TimeOutOfMove); } if (usingTimer && movesCount > 1) { time.Reset(); time.Start(); } validator.IsCorrectMove(black.MakeTurn(field), field, Color.Black); if (usingTimer && movesCount > 1) { time.Stop(); var ms = time.Elapsed.Milliseconds; Logs.AddToLog(ms.ToString()); MaxBlack = Math.Max(MaxBlack, ms); } if (usingForm) { Window.BeginInvoke(new Action<Checker[,]>(Window.Update), new object[] { field }); Thread.Sleep(TimeOutOfMove); } } }