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(); } } }
/// <summary> /// Konstruktor der Spieloberfläche /// </summary> public BattleshipsForm() { try { InitializeComponent(); // Spieler ist noch nicht bereit (Start des Spiels) playerReady2Play = false; opponendReady2Play = false; lanMenuItem = new ToolStripMenuItem("&Netzwerk"); spielBeitretenMenuItem = new ToolStripMenuItem("&Spiel beitreten"); spielHostenMenuItem = new ToolStripMenuItem("Spiel &hosten"); helpMenuItem = new ToolStripMenuItem("?"); infoMenuItem = new ToolStripMenuItem("&Info"); spielBeitretenMenuItem.Click += new EventHandler(spielBeitretenToolStripMenuItem_Click); spielHostenMenuItem.Click += new EventHandler(spielHostenToolStripMenuItem_Click); infoMenuItem.Click += new EventHandler(infoMenuItem_Click); panelStatus = new Panel(); panelStatus.Location = new Point(597, 47); panelStatus.Size = new System.Drawing.Size(197, 100); panelStatus.AutoScroll = true; panelStatus.BackColor = Color.Transparent; panelStatus.VerticalScroll.SmallChange = 50; panelStatus.HorizontalScroll.Enabled = true; lblStatus = new Label(); //lblStatus.Dock = DockStyle.Fill; lblStatus.TextAlign = ContentAlignment.TopLeft; lblStatus.AutoSize = true; lblStatus.Font = new System.Drawing.Font("Book Antiqua", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); panelStatus.Controls.Add(lblStatus); this.Controls.Add(panelStatus); lanMenuItem.DropDownItems.Add(spielHostenMenuItem); lanMenuItem.DropDownItems.Add(spielBeitretenMenuItem); helpMenuItem.DropDownItems.Add(infoMenuItem); menuStripMain.Items.Add(lanMenuItem); menuStripMain.Items.Add(helpMenuItem); soundPlayer = new SoundClass(); battlefieldPlayer = new BattlefieldPlayer(BATTLEFIELDPLAYER_X, BATTLEFIELDPLAYER_Y); battlefieldOpponent = new BattlefieldOpponent(BATTLEFIELDOPPONNENT_X, BATTLEFIELDOPPONNENT_Y); // Schlachtfelder der Hautpform Hinzufügen this.Controls.Add(battlefieldPlayer); this.Controls.Add(battlefieldOpponent); SplashScreen splash = new SplashScreen(); // Splashscreen anzeigen (langsam einblenden) splash.showForm(); // Splashscreen für 1sek. anzeigen Thread.Sleep(1000); // Splashscreen schließen splash.Close(); // Ressourcen freigeben splash.Dispose(); } catch (Exception ex) { MessageBox.Show(this, ex.Message + " " + ex.InnerException.ToString()); } }