Пример #1
0
 public void Movement(object sender, EventArgs e)
 {
     pacman.MakeStep(pole);
     Inky.RandomMove(pole);
     Blinky.RandomMove(pole);
     Clyde.RandomMove(pole);
     Pinky.RandomMove(pole);
     if ((pacman.x == Inky.x) && (pacman.y == Inky.y))
     {
         timer.Enabled = false;
         string            msg   = "You were eaten by Inky! Better luck next time.";
         string            capt  = "Loss!";
         MessageBoxButtons butts = MessageBoxButtons.OK;
         DialogResult      res;
         res = MessageBox.Show(msg, capt, butts);
         if (res == DialogResult.OK)
         {
             Close();
         }
     }
     else if ((pacman.x == Blinky.x) && (pacman.y == Blinky.y))
     {
         timer.Enabled = false;
         string            msg   = "You were eaten by Blinky! Better luck next time.";
         string            capt  = "Loss!";
         MessageBoxButtons butts = MessageBoxButtons.OK;
         DialogResult      res;
         res = MessageBox.Show(msg, capt, butts);
         if (res == DialogResult.OK)
         {
             Close();
         }
     }
     else if ((pacman.x == Clyde.x) && (pacman.y == Clyde.y))
     {
         timer.Enabled = false;
         string            msg   = "You were eaten by Clyde! Better luck next time.";
         string            capt  = "Loss!";
         MessageBoxButtons butts = MessageBoxButtons.OK;
         DialogResult      res;
         res = MessageBox.Show(msg, capt, butts);
         if (res == DialogResult.OK)
         {
             Close();
         }
     }
     else if ((pacman.x == Pinky.x) && (pacman.y == Pinky.y))
     {
         timer.Enabled = false;
         string            msg   = "You were eaten by Pinky! Better luck next time.";
         string            capt  = "Loss!";
         MessageBoxButtons butts = MessageBoxButtons.OK;
         DialogResult      res;
         res = MessageBox.Show(msg, capt, butts);
         if (res == DialogResult.OK)
         {
             Close();
         }
     }
     if (points == 279)
     {
         timer.Enabled = false;
         string            msg   = "You ate all the food and dodged the ghosts!";
         string            capt  = "Victory!";
         MessageBoxButtons butts = MessageBoxButtons.OK;
         DialogResult      res;
         res = MessageBox.Show(msg, capt, butts);
         if (res == DialogResult.OK)
         {
             Close();
         }
     }
 }