Пример #1
0
        protected override void Update(GameTime gameTime)
        {
            Time.Update(gameTime);
            InputManager.Update();

            currentScene.Update();
            background = (currentScene == scenes["Play"] ? Color.Black : Color.Black);

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (gameTime.ElapsedGameTime.TotalSeconds == 60)
            {
                Exit();
            }

            //if (InputManager.IsKeyDown(Keys.Up)) camera.Transform.Rotate(Vector3.Right, Time.ElapsedGameTime);
            //if (InputManager.IsKeyDown(Keys.Down)) camera.Transform.Rotate(Vector3.Left, Time.ElapsedGameTime);

            if (Inky.CheckCollision(pacman))
            {
                hits++;
            }
            if (Blinky.CheckCollision(pacman))
            {
                hits++;
            }
            if (Pinky.CheckCollision(pacman))
            {
                hits++;
            }
            if (Clyde.CheckCollision(pacman))
            {
                hits++;
            }
            if (Blue.CheckCollision(pacman))
            {
                hits++;
            }

            pacman.Update();
            Inky.Update();
            Blinky.Update();
            Pinky.Update();
            Clyde.Update();
            Blue.Update();
            powerUp.Update();

            Vector3 normal;

            if (pacman.Get <Collider>().Collides(powerUp.Get <Collider>(), out normal))
            {
                Console.WriteLine("HitBox");
                (powerUp.Get <Renderer>().ObjectModel.Meshes[0].Effects[0] as BasicEffect).DiffuseColor = Color.Red.ToVector3();
                pacmanHealth--;
            }
            else
            {
                Console.WriteLine("NotHitBox");
                (powerUp.Get <Renderer>().ObjectModel.Meshes[0].Effects[0] as BasicEffect).DiffuseColor = Color.Blue.ToVector3();
                pacmanHealth--;
            }

            base.Update(gameTime);
        }