Esempio n. 1
0
        public override void Update(GameTime gameTime, bool covered)
        {
            if (lives > 0)
            {
                if (Input.WasKeyPressed(Keys.Escape))
                {
                    //Quit to menu
                    ScreenManager.AddScreen(new MainMenu());
                    ScreenManager.RemoveScreen(this);
                }

                if (Input.WasKeyPressed(Keys.L))
                {
                    lives--;
                }

                if (Input.WasKeyPressed(Keys.V))
                {
                    if (Globals.Instance.light)
                    {
                        Globals.Instance.light = false;
                    }
                    else
                    {
                        Globals.Instance.light = true;
                    }
                }
                float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

                if (Input.WasKeyPressedGame(Keys.Right))
                {
                    FloorBackgroundL.Update(elapsed * 300);
                    CloudBackgroundL.Update(elapsed * 75);
                    BackgroundL.Update(elapsed * 150);

                    FloorBackgroundD.Update(elapsed * 300);
                    CloudBackgroundD.Update(elapsed * 75);
                    BackgroundD.Update(elapsed * 150);

                    pitposition -= 3;
                    textMod     -= 3;
                }

                else if (Input.WasKeyPressedGame(Keys.Left))
                {
                    FloorBackgroundL.Update(elapsed * -300);
                    CloudBackgroundL.Update(elapsed * -75);
                    BackgroundL.Update(elapsed * -150);

                    FloorBackgroundD.Update(elapsed * -300);
                    CloudBackgroundD.Update(elapsed * -75);
                    BackgroundD.Update(elapsed * -150);

                    pitposition += 3;
                    textMod     += 3;
                }

                foreach (Platform p in LplatformList)
                {
                    if (player.CollidesWith(p))
                    {
                        player.collidesWithObstacle(p, gameTime);
                    }
                }

                if (player.CollidesWithPortal(portal))
                {
                    ScreenManager.AddScreen(new LevelComplete());
                    ScreenManager.RemoveScreen(this);
                }

                foreach (Platform p in DplatformList)
                {
                    if (player.CollidesWith(p))
                    {
                        player.collidesWithObstacle(p, gameTime);
                    }
                }

                if (player.CollidesWith(portal))
                {
                    ScreenManager.AddScreen(new Level1());
                    ScreenManager.RemoveScreen(this);
                }

                foreach (Platform p in DplatformList)
                {
                    p.Update(CloudBackgroundL);
                }

                foreach (Platform p in LplatformList)
                {
                    p.Update(CloudBackgroundL);
                }

                player.Update(gameTime);
                enemy.Update(gameTime, CloudBackgroundL);
                portal.Update(gameTime, CloudBackgroundL);

                base.Update(gameTime, covered);
            }

            else if (lives <= 0)
            {
                ScreenManager.AddScreen(new GameOver());
                ScreenManager.RemoveScreen(this);
            }
        }