示例#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();
     }
 }
示例#2
0
        public void AddDisinfectant()
        {
            int x = Random.Next(Darkness.Width, Game.ActualFormWidth - Disinfectant.Width - Goal.Width);
            int y = Random.Next(70, Game.ActualFormHeight - Disinfectant.Height);

            Disinfectants.Add(new Disinfectant(x, y));
        }
示例#3
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();
     }
 }