public void StartGame(bool firstTime = false) { if (firstTime) { playButton.Hide(); this.BackgroundImage = Properties.Resources.background2; soundButton.Location = new Point(1012, 0); soundButton.Show(); this.Update(); this.BackColor = SystemColors.Control; gameManager = new BattleshipGame(); this.player = gameManager.GetPlayer(); this.computer = gameManager.GetComputer(); DrawBoard(); } else { placedShips.Clear(); placedShipsBoxes.Clear(); computerTurnsCount = 0; computersTurnsCountLabel.Text = computerTurnsCount.ToString(); computersTurnsCountLabel.Hide(); playerTurnsCount = 0; playersTurnsCountLabel.Text = playerTurnsCount.ToString(); playersTurnsCountLabel.Hide(); possibleToPlaceShip = false; debugModeToolStripMenuItem.Enabled = false; backwardButton.Enabled = true; gameStarted = false; foreach (GraphicSquare gs in computerGraphicBoard) { gs.Clickable = false; } gameManager.Reset(); foreach (GraphicSquare temp in computerGraphicBoard) { temp.Reset(); } foreach (GraphicSquare temp in playerGraphicBoard) { temp.Reset(); } for (int i = 0; i < shipsBoxes.Length; i++) { shipsBoxes[i].Reset(); shipsBoxes[i].Enabled = true; } startButton.Enabled = true; } }
public void StartGame(int seed) { if (seed < 0) { Random r = new Random(); seed = r.Next(); } Game = new BattleshipGame(seed, GetDifficulty()); Game.BindControls(UITrackerBoard, UIPrimaryBoard); SeedLabel.Text = string.Format("Seed: {0}", Convert.ToString(seed, 16).ToUpper()); }
public static void StartGame(int numPlayers) { BattleshipGame game = new BattleshipGame(numPlayers); game.PlaceShipsInitial(); while (game.Player1IsAlive && game.Player2IsAlive) { game.Player1Turn(); game.Player2Turn(); } }
public Player(BattleshipGame bsg, PlayerType type) // for ComputerAI class { this.gameManager = bsg; this.Type = type; board = new Square[GameSettings.Default.BoardSize, GameSettings.Default.BoardSize]; for (int i = 0; i < GameSettings.Default.BoardSize; i++) { for (int j = 0; j < GameSettings.Default.BoardSize; j++) { board[i, j] = new Square(i, j); } } shipsIndex = 0; }
public Player(BattleshipGame bsg) { this.gameManager = bsg; this.Type = PlayerType.Player; board = new Square[GameSettings.Default.BoardSize, GameSettings.Default.BoardSize]; for (int i = 0; i < GameSettings.Default.BoardSize; i++) { for (int j = 0; j < GameSettings.Default.BoardSize; j++) { board[i, j] = new Square(i, j); } } shipsIndex = 0; shipsDestroyedCount = 0; }
public ComputerAI(BattleshipGame bsg) : base(bsg, PlayerType.Computer) { lastResult = Result.None; direction = Direction.Unknown; PlaceShips(); }