public GameScreen(GameEngine ge, Board p1, Board p2) { InitializeComponent(); this.DoubleBuffered = true; this.MouseMove += new System.Windows.Forms.MouseEventHandler(Form_MouseMove); this.MouseClick += new System.Windows.Forms.MouseEventHandler(Form_MouseClick); this.ge = ge; this.p1 = p1; this.p2 = p2; boardSize = p1.getSize(); shipListOne = p1.getShipList(); shipListTwo = p2.getShipList(); turn = ge.getTurn(); phase = ge.getPhase(); Console.WriteLine("Turn: " + turn + " Phase: " + phase); }
static void Main() { Storage xmlStorage = new Storage(); Form splashScreen = new SplashScreen(); splashScreen.Show(); Thread.Sleep(1000); splashScreen.Close(); Menu menu = new Menu(xmlStorage.previousGame()); menu.ShowDialog(); string menuChoice = menu.buttonEvent; if (menuChoice != "EXIT") { GameEngine GE; if (menuChoice == "PLAYER_VS_PLAYER") { xmlStorage.clearData(); xmlStorage.setPvP("Yes"); Board p1 = new Board(true, "Player1", xmlStorage); //Player 1 is human Board p2 = new Board(true, "Player2", xmlStorage); //PLayer 2 is human GE = new GameEngine(p1, p2, xmlStorage); GameScreen gameScreen = new GameScreen(GE, p1, p2); gameScreen.ShowDialog(); } else if (menuChoice == "PLAYER_VS_PC") { xmlStorage.clearData(); xmlStorage.setPvP("No"); Board p1 = new Board(true, "Player1", xmlStorage); //Player 1 is human Board p2 = new Board(false, "Player2", xmlStorage); //PLayer 2 is PC GE = new GameEngine(p1, p2, xmlStorage); GameScreen gameScreen = new GameScreen(GE, p1, p2); gameScreen.ShowDialog(); } else if (menuChoice == "LOAD_SAVED_GAME") { //Load from xmlStorage Board p1 = new Board("Player1", xmlStorage); Board p2 = new Board("Player2", xmlStorage); GE = new GameEngine(p1, p2, xmlStorage); GE.setTurn(xmlStorage.getTurn()); GE.setPhase(xmlStorage.getPhase()); GameScreen gameScreen = new GameScreen(GE, p1, p2); gameScreen.ShowDialog(); } } }