Update() public method

public Update ( ) : void
return void
Esempio n. 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //check for input
            background.Update(gameTime);
            //get input
            float[] R = new float[9];
            SensorManager.GetRotationMatrix(R, null, Activity1.accelValues, Activity1.magnetoValues);
            float[] orientation = new float[9];
            SensorManager.GetOrientation(R, orientation);
            float roll = (float)Java.Lang.Math.ToDegrees(orientation[2]);

            touchCollection = TouchPanel.GetState();
            TouchLocation[] touches = new TouchLocation[touchCollection.Count];
            for (int i = 0; i < touchCollection.Count; i++)
            {
                touches[i] = new TouchLocation(touchCollection[i].Id, touchCollection[i].State, touchCollection[i].Position * Game1.screenSize / new Vector2(Window.ClientBounds.Width, Window.ClientBounds.Height));
            }

            switch (state)
            {
            case GameState.Start:
                startScreen.Update(touches, Window);
                break;

            case GameState.Playing:
                level.Update(gameTime, touches, roll);
                pauseScreen.Update(touches, Window);
                break;

            case GameState.End:
                endScreen.Update(touches, Window); break;
            }
        }
        public override void Update()
        {
            if (Level != null)
            {
                Level.Update();
            }

            ShowStatistics = Input.Tab.Down;
            if (Input.Esc.Clicked)
            {
                Paused = !Paused;
            }

            if (Paused)
            {
                PausePopUp.Update();
            }
            if (TeamNotSelected)
            {
                TeamSelectPopUp.Update();
            }

            if (!IsPlaying())
            {
                StopPlaying();
            }
        }
Esempio n. 3
0
 public override void Update()
 {
     if (!IsPaused)
     {
         AudioManager.Update();
         PhysicsManager.Update();
         UpdateManager.Update();
         PhysicsManager.CheckCollisions();
         TriggerManager.CheckTriggers();
         CameraManager.Update(); // si fa alla fine
         BackgroundManager.Update();
     }
     else
     {
         pause.Update();
     }
 }
Esempio n. 4
0
        protected override void Update(GameTime gameTime)
        {
            // TODO: Add your update logic here
            switch (gameState)
            {
            case GameState.Menu:
                mainMenu.Update(gameTime);
                background.Speed = 1;
                background.Update(gameTime);
                break;

            case GameState.MediumDifficulty:
                pause.PrevGameState = "Medium";
                foreach (var asteroid in asteroidList)
                {
                    if (player.BoundingBox.Bottom < asteroid.Position.Y)
                    {
                        asteroid.IsVisible = false;
                        player.IncreaseScore(10);
                    }
                }
                hud.Update(player.Score);
                background.Speed = 3;
                background.Update(gameTime);
                player.Update(gameTime);
                LoadAsteroids();
                UpdateAsteroids();

                KeyboardState keyboard = Keyboard.GetState();
                if (keyboard.IsKeyDown(Keys.Escape))
                {
                    gameState = GameState.Pause;
                }
                break;

            case GameState.EasyDifficulty:
                pause.PrevGameState = "Easy";
                asteroidCount       = 3;
                foreach (var asteroid in asteroidList)
                {
                    if (player.BoundingBox.Bottom < asteroid.Position.Y)
                    {
                        asteroid.IsVisible = false;
                        player.IncreaseScore(10);
                    }
                }
                hud.Update(player.Score);
                background.Speed = 3;
                background.Update(gameTime);
                player.Update(gameTime);
                LoadAsteroids();
                UpdateAsteroids();

                KeyboardState keyboardED = Keyboard.GetState();
                if (keyboardED.IsKeyDown(Keys.Escape))
                {
                    gameState = GameState.Pause;
                }
                break;

            case GameState.HardDifficulty:
                pause.PrevGameState = "Hard";
                asteroidCount       = 7;
                foreach (var asteroid in asteroidList)
                {
                    if (player.BoundingBox.Bottom < asteroid.Position.Y)
                    {
                        asteroid.IsVisible = false;
                        player.IncreaseScore(10);
                    }
                }
                hud.Update(player.Score);
                background.Speed = 3;
                background.Update(gameTime);
                player.Update(gameTime);
                LoadAsteroids();
                UpdateAsteroids();

                KeyboardState keyboardHD = Keyboard.GetState();
                if (keyboardHD.IsKeyDown(Keys.Escape))
                {
                    gameState = GameState.Pause;
                }
                break;

            case GameState.Info:
                KeyboardState keyboardInf = Keyboard.GetState();
                if (keyboardInf.IsKeyDown(Keys.Escape))
                {
                    gameState = GameState.Menu;
                }
                background.Speed = 0;
                break;

            case GameState.Exit:
                Exit();
                break;

            case GameState.GameOver:
                gameOver.Score = player.Score.ToString();
                keyboard       = Keyboard.GetState();
                if (keyboard.IsKeyDown(Keys.Escape))
                {
                    Reset();
                    gameState = GameState.Menu;
                }
                break;

            case GameState.ChooseDifficulty:
                chooseDifficulty.Update(gameTime);
                background.Speed = 1;
                background.Update(gameTime);
                break;

            case GameState.Pause:
                pause.Update(gameTime);
                background.Speed = 1;
                background.Update(gameTime);
                break;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            MouseState mouse = Mouse.GetState();
            //Mouse.WindowHandle = Window.Handle;
            Vector2 clickCoord  = new Vector2(mouse.X, mouse.Y) + new Vector2((Ecir.cameraMove.X) + 180, (Ecir.cameraMove.Y) + 451);
            Matrix  screenScale = camera.GetTransform();
            Point   mousePoint  = new Point((int)clickCoord.X, (int)clickCoord.Y);

            //Vector2 mousePos = new Vector2(mouse.X, mouse.Y);
            // Vector2 worldPosition = Vector2.Transform(mousePos, Matrix.Invert(screenScale));
            // Console.WriteLine("mouseX=" + worldPosition.X + "mouseY=" + worldPosition.Y);

            MenuPause.Mouse1(mousePoint);
            // Console.WriteLine("mouseX=" + clickCoord.X + "mouseY=" + clickCoord.Y);


            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            if (exit)
            {
                Exit();
            }
            if (pause)
            {
                this.IsMouseVisible = true;
            }
            else
            {
                this.IsMouseVisible = false;
            }

            MenuPause.Update();


            keyState = Keyboard.GetState();
            if (pause == false)
            {
                if (!ecir.EcirDestroy())
                {
                    ecir.EcirMove(2, 2);
                    ecir.TerrainColisions();
                    ecir.EcirLife();
                }
                hollowKnight.Update();
                ecir.UpdateTime(gameTime.ElapsedGameTime.TotalSeconds);
                stairs.Update();
                ogre.Update();
                ogre.UpdateTime(gameTime.ElapsedGameTime.TotalSeconds);
                terrain1.Update();
                skeleton.Update();
                skeleton.UpdateTime(gameTime.ElapsedGameTime.TotalSeconds, gameTime.ElapsedGameTime.Milliseconds);
                fireBall.Update();
                fireBall.CreateFireBall(graphics);
                fireBall.UpdateTime(gameTime.ElapsedGameTime.TotalSeconds);

                if (zombie != null)
                {
                    zombie.UpdateTimer(gameTime.ElapsedGameTime.TotalSeconds);
                    zombie.ZombieChageDirection();
                    zombie.ZombieMove();
                    zombie.ZombieLife();
                    zombie.ZombieColor();
                }
                hollowKnight.UpdateTime(gameTime.ElapsedGameTime.TotalSeconds);
                Console.WriteLine("Pause==" + pause);
                base.Update(gameTime);
            }

            if (keyState.IsKeyDown(Keys.P) && !keyStateOld.IsKeyDown(Keys.P))
            {
                pause = !pause;  //->pausar o jogo
            }
            keyStateOld = keyState;
            if (restart == true)
            {
                this.Initialize();//->reiniciar o jogo
                this.LoadContent();
                Zombie.zombieLife = 100;
                Ecir.life         = 100;
                Ecir.color        = Color.White;
                this.Draw(gameTime);
            }
            restart = false;
        }
Esempio n. 6
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            #region MenuUpdate
            switch (CurrentGameState)
            {
            case MenuState.GameState.NewGame:
                Level = options.Level;
                StartGame(Level, options.HealthPoint);
                options.HealthPoint = HealthPoint;
                MediaPlayer.Stop();
                CurrentGameState = MenuState.GameState.Playing;
                MediaPlayer.Play(GameTheme);
                if (CurrentGameState == MenuState.GameState.Playing)
                {
                    logic.Update(map, player, camera, gameTime);
                }
                break;

            case MenuState.GameState.Playing:
                CurrentGameState = logic.GameState(CurrentGameState);
                logic.Update(map, player, camera, gameTime);
                pauseSound = true;
                break;

            case MenuState.GameState.Options:
                CurrentGameState = options.Update();
                Level            = options.Level;
                HealthPoint      = options.HealthPoint;
                break;

            case MenuState.GameState.LevelComplete:
                CurrentGameState = levelComplete.Update(logic.Score);
                options.Level    = logic.Level;
                break;

            case MenuState.GameState.MainMenu:
                options.Level    = Level;
                pauseSound       = true;
                CurrentGameState = mainmenu.Update();
                break;

            case MenuState.GameState.GameOver:
                CurrentGameState = gameOver.Update(player.Health, player.HasDamaged);
                break;

            case MenuState.GameState.Pause:
                MediaPlayer.Pause();
                CurrentGameState = pause.Update();
                if (pauseSound)
                {
                    pause.PlaySound();
                    pauseSound = false;
                }
                break;

            case MenuState.GameState.Exit:
                Exit();
                break;

            default:
                break;
            }

            if (CurrentGameState == MenuState.GameState.GameOver && !gameOver.Over)
            {
                animationSprite.PlayAnimation(death);
            }
            else
            {
                animationSprite.PlayAnimation(null);
            }
            #endregion
            base.Update(gameTime);
        }
Esempio n. 7
0
        protected override void Update(GameTime gameTime)
        {
            if (exit)
            {
                Exit();
            }
            Newkey   = Keyboard.GetState();
            Newmouse = Mouse.GetState();

            if (Newkey.IsKeyDown(Keys.F1) && Prevkey.IsKeyUp(Keys.F1))
            {
                Godmode = !Godmode;
            }

            switch (CurrentGameState)
            {
            case Gamestates.Mainmenu:
                MainMenu.Update(Newmouse);
                break;

            case Gamestates.Playing:
                if (Newkey.IsKeyDown(Keys.Escape))
                {
                    CurrentGameState = Gamestates.Pause;
                }

                foreach (Spike k in Spikes)
                {
                    k.Update();
                }

                Character.Update(gameTime);
                foreach (Character k in Enemies)
                {
                    k.Update(gameTime);
                }

                foreach (Items k in Items)
                {
                    k.Update();
                }

                break;

            case Gamestates.Options:
                Options.Update(Newmouse);

                if (Options.Apply.IsClicked && Fullscreen != graphics.IsFullScreen)
                {
                    graphics.ToggleFullScreen();
                }

                break;

            case Gamestates.OptionsIg:
                Options.Update(Newmouse);
                if (Options.Apply.IsClicked && Fullscreen != graphics.IsFullScreen)
                {
                    graphics.ToggleFullScreen();
                }

                break;

            case Gamestates.Pause:
                Pause.Update(Newmouse);
                break;

            case Gamestates.Save:
                menu.Save.Update(Newmouse);
                break;

            case Gamestates.Load:
                menu.Save.Update(Newmouse);
                break;

            case Gamestates.GameOver:
                menu.Gameover.Update(Newmouse);
                break;

            case Gamestates.EndScreen:
                menu.EndScreen.Update(Newmouse);
                break;

            case Gamestates.EndSave:
                menu.Save.Update(Newmouse);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }


            Kamera.Update(Character);


            Prevkey   = Newkey;
            Prevmouse = Newmouse;
            base.Update(gameTime);
        }