Beispiel #1
0
        private void checkForEnd()
        {
            if (dotList.Count == 0)
            {
                parentForm.playSound(Properties.Resources.Pacman_Intermission);
                State = GameState.GAMEOVER;
            }

            List <Point> mergedList = new List <Point>();

            mergedList = RedGhost.core().Union(BlueGhost.core()).Union(PinkGhost.core()).Union(YellowGhost.core()).ToList();

            List <Point> commonPoints = Pacman.core().Intersect(mergedList.Select(u => u)).ToList();


            if ((commonPoints.Count != 0 && !Bonus) || lives == 0)
            {
                lives--;
                parentForm.playSound(Properties.Resources.Pacman_Dies);

                State = GameState.GAMEPAUSE;
                //if (lives == 0)
                //{
                // State = GameState.GAMEOVER;
                //}
            }
            commonPoints.Clear();
            commonPoints = Pacman.core().Intersect(RedGhost.core().Select(u => u)).ToList();
            if (commonPoints.Count != 0 && Bonus)
            {
                parentForm.playSound(Properties.Resources.Pacman_Eating_Ghost);
                parentForm.setCollision(GhostColor.RED);
            }
            commonPoints.Clear();
            commonPoints = Pacman.core().Intersect(BlueGhost.core().Select(u => u)).ToList();
            if (commonPoints.Count != 0 && Bonus)
            {
                parentForm.playSound(Properties.Resources.Pacman_Eating_Ghost);
                parentForm.setCollision(GhostColor.BLUE);
            }
            commonPoints.Clear();
            commonPoints = Pacman.core().Intersect(YellowGhost.core().Select(u => u)).ToList();
            if (commonPoints.Count != 0 && Bonus)
            {
                parentForm.playSound(Properties.Resources.Pacman_Eating_Ghost);
                parentForm.setCollision(GhostColor.YELLOW);
            }
            commonPoints.Clear();
            commonPoints = Pacman.core().Intersect(PinkGhost.core().Select(u => u)).ToList();
            if (commonPoints.Count != 0 && Bonus)
            {
                parentForm.playSound(Properties.Resources.Pacman_Eating_Ghost);
                parentForm.setCollision(GhostColor.PINK);
            }
        }
Beispiel #2
0
        private void checkForLose()
        {
            List <Point> mergedList = new List <Point>();

            mergedList = RedGhost.core().Union(BlueGhost.core()).Union(PinkGhost.core()).Union(YellowGhost.core()).ToList();

            List <Point> commonPoints = Pacman.core().Intersect(mergedList.Select(u => u)).ToList();

            if (((commonPoints.Count != 0 && !Bonus)))
            {
                State = GameState.GAMEWAIT;
                parentForm.playSound(Properties.Resources.Pacman_Dies);
                AIFlagInit();
                AIClockCounter = 0;
                Bonus          = false;
                WaitSomeTime(1500);
                while (wait)
                {
                }
                wait = true;
                lives--;
                sendMsg();
                board.addPacmanToPanel(lives, pnlInfo);
                RedGhost.reset(stage);
                BlueGhost.reset(stage);
                PinkGhost.reset(stage);
                YellowGhost.reset(stage);
                if (lives <= 0)
                {
                    WaitSomeTime(1000);
                    while (wait)
                    {
                    }
                    wait = true;
                    if (score > HighScoreList.min() || HighScoreList.hsList.Count < 10)
                    {
                        parentForm.AddHighScore(score, coins, switchDifficulty());
                    }
                }
                else
                {
                    Pacman.reset(stage); SetGameRun(1500);
                }
            }
        }