Ejemplo n.º 1
0
        // pacman and ghost timers starts

        private void pacmanTimer_Tick(object sender, EventArgs e)
        {
            //performs action based on the cell pacman interacts with
            switch (pacman.Move(cells))
            {
            case MovingPacman.MoveResult.None:
                break;

            case MovingPacman.MoveResult.Pill:
                score += 10;
                ScoreInfoEventArgs currentScore = new ScoreInfoEventArgs(score);
                OnScoreChanged(currentScore);
                eat.Play();
                break;

            case MovingPacman.MoveResult.PowerPellet:
                score += 50;
                powerup.Play();
                break;

            default:
                break;
            }
            mapPictureBox.Invalidate();
        }
Ejemplo n.º 2
0
 protected virtual void OnScoreChanged(ScoreInfoEventArgs e)
 {   //if the score changes it converts the interger number of pellets to a string and print it through a textbox
     if (ScoreChanged != null)
     {
         ScoreChanged(this, e);
     }
     this.ScoreBox.Text = e.score.ToString();
     if (this.ScoreBox.Text == "2200")
     {
         WinDisplay winner = new WinDisplay();
         winner.Show();                              //Shows the winner display when points have been reached
     }
 }