Beispiel #1
0
        private void CheckForCollisionWithScores(Character pacman, List <GameObject> allScores)
        {
            GameObject obj = CollisionDispatcher.SeeForCollisionWithObjects(pacman, allScores);

            if (obj is Score)
            {
                pacman.TakeScore(obj as Score);
            }

            Score score = CollisionDispatcher.SeeForCollisionWithScores(pacman, this.map.GiveMeAllScores());

            if (score != null)
            {
                pacman.TakeScore(score);
            }
        }
Beispiel #2
0
        public void Run()
        {
            while (this.pacman.IsAlive && this.map.GiveMeAllScores().Count > 0)
            {
                this.renderer.EnqueueForRendering(this.map.GiveMeMap());
                this.renderer.EnqueueForRendering(this.allObjects);

                this._userInput.ProcessInput();

                ProceedAllOpponentsMoves();

                foreach (var obj in this.allMovableObjects)
                {
                    obj.SetIfCanMoveToWaitingDirection(this.map.GiveMeAllPaths());
                    obj.Update();
                    if (CollisionDispatcher.SeeForCollisionWithWalls(obj, this.map.GiveMeAllWalls()))
                    {
                        obj.MoveBack();
                    }
                    CheckPacmanCollisionWithOpponent(this.allMovableObjects);
                }

                this.renderer.RenderAll();
                RenderScore();

                CheckForCollisionWithScores(this.pacman, this.allObjects);

                RemoveAllDeadObjects();

                AddBonusScores();

                this.renderer.ClearQueue();
                Thread.Sleep(150);
            }

            ProceedIfPacmanIsDead();
            ProceedIfWin();
        }