Ejemplo n.º 1
0
 private void CheckDarknessCollisions()
 {
     for (int i = 0; i < Masks.Count; i++)
     {
         if (Darkness.CheckMask(Masks[i]))
         {
             Masks.Remove(Masks[i]);
         }
     }
     for (int i = 0; i < Disinfectants.Count; i++)
     {
         if (Darkness.CheckDisinfectant(Disinfectants[i]))
         {
             Disinfectants.Remove(Disinfectants[i]);
         }
     }
     for (int i = 0; i < SickPersons.Count; i++)
     {
         if (Darkness.CheckSickPerson(SickPersons[i]))
         {
             SickPersons.Remove(SickPersons[i]);
         }
     }
     if (Hero.CheckDarkness(Darkness))
     {
         IsEnabled = false;
         CustomMessageBox cmb = new CustomMessageBox();
         cmb.SetMessage("The darkness caught you. Game over!");
         cmb.SetRetryButton(true);
         cmb.Show();
     }
 }
Ejemplo n.º 2
0
 public void CheckHeroCollisions()
 {
     for (int i = 0; i < Masks.Count; i++)
     {
         if (Hero.CheckMask(Masks[i]))
         {
             Masks.Remove(Masks[i]);
         }
     }
     for (int i = 0; i < Disinfectants.Count; i++)
     {
         if (Hero.CheckDisinfectant(Disinfectants[i]))
         {
             Disinfectants.Remove(Disinfectants[i]);
             ++Points;
         }
     }
     if (!Hero.IsMasked)
     {
         for (int i = 0; i < SickPersons.Count; i++)
         {
             if (Hero.CheckSickPerson(SickPersons[i]))
             {
                 SickPersons.Remove(SickPersons[i]);
                 ChangeHearts();
             }
             if (Hero.Lives == 0)
             {
                 IsEnabled = false;
                 CustomMessageBox cmb = new CustomMessageBox();
                 cmb.SetMessage("You lost all your lives. Game over!");
                 cmb.SetRetryButton(true);
                 cmb.Show();
                 break;
             }
         }
     }
     if (Hero.CheckDarkness(Darkness))
     {
         IsEnabled = false;
         CustomMessageBox cmb = new CustomMessageBox();
         cmb.SetMessage("The darkness caught you. Game over!");
         cmb.SetRetryButton(true);
         cmb.Show();
     }
     if (Goal.IsEnabled && Hero.CheckGoal(Goal))
     {
         IsEnabled = false;
         ++Game.CurrentLevel;
         if (LevelNumber < 5)
         {
             CustomMessageBox cmb = new CustomMessageBox();
             cmb.SetMessage(string.Format("Level {0} finished. Good job!", LevelNumber.ToString()));
             cmb.SetRetryButton(false);
             cmb.Show();
         }
         else
         {
             CustomMessageBox cmb = new CustomMessageBox();
             cmb.SetMessage("Game finished. Congratulations!");
             cmb.SetRetryButton(false);
             cmb.Show();
         }
     }
     if (!Goal.IsEnabled && Points >= RequiredPoints)
     {
         Goal.Enable();
     }
 }