Exemplo n.º 1
0
 private void FrmGame_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         if (GameData.lifes <= 3 && GameData.lifes >= 0 && GameData.points > 0 && e.CloseReason == CloseReason.UserClosing)
         {
             throw new GameClosedInProcess("Have 1+ Points");
         }
     }
     catch (GameClosedInProcess)
     {
         dtptimerForMovements.Stop();
         if (MessageBox.Show($"¿Desea guardar sus puntos actuales? Actualemente tienes: {GameData.points} puntos",
                             "Consulta",
                             MessageBoxButtons.YesNo,
                             MessageBoxIcon.Question) == DialogResult.Yes)
         {
             ControllersGame.Update(user);
             Application.Exit();
         }
         else
         {
             Application.Exit();
         }
     }
 }
Exemplo n.º 2
0
        //When the game is over to win or lose
        private void EndGame()
        {
            ControllersGame.Update(user);//Update points
            Form temp = this.FindForm();

            temp.Controls.Clear();
            if (MessageBox.Show("¿Desea jugar otra partida?",
                                "Consulta",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == DialogResult.Yes)
            {
                //Reload Data al newForm
                GameData.InitializeGame();
                //Application.Restart();
                LoadTiles();
                LoadPlayer();
                LoadPanel();
                temp.Close();
                FrmGame newGame = new FrmGame(user);
                newGame.Show();
            }
            else
            {
                //Restart App!
                Application.Restart();
            }
        }