Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        public void Run()
        {
            RePaint();
            State  = GameState.GAMERUN;
            Runner = new Task(runGame);
            Runner.Start();
            wallRunner = new Task(runWalls);
            wallRunner.Start();
            Clock = new Task(runClock);
            Clock.Start();

            RedGhost.Run();
            BlueGhost.Run();
            YellowGhost.Run();
            PinkGhost.Run();
            Pacman.Run();
            State = GameState.GAMEWAIT;
            parentForm.playSound(Properties.Resources.Pacman_Opening_Song);
            SetGameRun(4000);
        }