Ejemplo n.º 1
0
 private void OkButton_Click(object sender, EventArgs e)
 {
     if (NameTextBox.Text == "")
     {
         MessageBox.Show("Please enter in a name");
     }
     //this will probably never run because either one has to always be checked, but just leaving it to be safe
     else if (EasyRadioButton.Checked == false && HardRadioButton.Checked == false)
     {
         MessageBox.Show("Please select a difficulty");
     }
     else
     {
         string diff;
         if (EasyRadioButton.Checked == true)
         {
             diff = "easy";
         }
         else
         {
             diff = "hard";
         }
         GameSaveState  playergame = new GameSaveState(NameTextBox.Text, diff);
         MainGameWindow window     = new MainGameWindow();
         window.Gamestate = playergame;
         window.Show();
         this.Close();
     }
 }
Ejemplo n.º 2
0
 private void LoadButton_Click(object sender, RoutedEventArgs e)
 {
     if (selectedSave == null)
     {
         MessageBox.Show("Please choose a file");
     }
     else//deserialize
     {
         BinaryFormatter bin = new BinaryFormatter();
         using (Stream fstream = File.OpenRead(selectedSave))
         {
             GameSaveState  loadedGame = (GameSaveState)bin.Deserialize(fstream);
             MainGameWindow newWindow  = new MainGameWindow();
             newWindow.Gamestate = loadedGame;
             newWindow.Show();
         }
     }
     this.Close();
 }