Update() private method

private Update ( ) : void
return void
コード例 #1
0
ファイル: Octonaut.cs プロジェクト: Alby1998/Octonaut
        ///<summary>/////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////
        ///</summary>//////////////////////////////////////////////////////////////////////////

        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }


            //set death Ex becouse of Null Error
            // LazerBeams.eDeath = deathEX;



            if (Keyboard.GetState().IsKeyDown(Keys.F4) && flag == false)
            {
                if (graphics.IsFullScreen == false && flag == false)
                {
                    graphics.IsFullScreen = true;
                    flag = true;
                    graphics.HardwareModeSwitch = false;
                    graphics.ApplyChanges();
                }

                if (graphics.IsFullScreen == true && flag == false)
                {
                    graphics.IsFullScreen = false;
                    flag = true;


                    Window.IsBorderless = false;
                    graphics.ApplyChanges();
                }
            }

            if (Keyboard.GetState().IsKeyUp(Keys.F4))
            {
                flag = false;
            }


            ///////////////////////////////////////////////////////////////
            //--------------------SET PANIC MODE------------------------//
            /////////////////////////////////////////////////////////////

            if (Global.panic == false && Global.shield <= 0)
            {
                Global.shield = 0;
                Global.panic  = true;
            }

            if (Global.shield > 0)
            {
                Global.panic = false;
            }



            ///////////////////////////////////////////////////////////////
            //----------------------SET LV SCORE BOUNDS-----------------//
            /////////////////////////////////////////////////////////////
            if (Global.lvScore >= 999999)
            {
                Global.lvScore = 999999;
            }

            if (Global.lvScore <= 0)
            {
                Global.lvScore = 0;
            }


            if (Global.lvBegin == true)
            {
            }



            ///////////////////////////////////////////////////////////////
            //-----------------------Game States------------------------//
            /////////////////////////////////////////////////////////////

            switch (gameState)
            {
            case GameState.titleScreen:      //TITLE SCREEN STATE

                if (Global.LV > 0)
                {
                    gameState = GameState.play;
                }

                ts.Update(gameTime);

                //////////////////////////////////////////////////////////
                //------------RESET VALUES FOR NEXT RUN OF GAME--------//
                ////////////////////////////////////////////////////////
                player.destRect = new Rectangle(64, 200, 80, 80);
                player.position = new Vector2(64, 200);

                Global.grandScore = 0;

                player.gmPos      = new Vector2(1024, 256);
                player.gmTimer    = 2000;
                Global.invincible = false;
                Global.panic      = false;
                Global.GameOver   = false;
                Global.Death      = false;
                Global.shield     = 1000;
                Global.lvScore    = 0;

                EnemySpawn.timer = 0;
                if (Global.LV == 1)
                {
                    Global.lives = 3;
                }

                EnemyManager.Clear();

                //////////////////////////////////////////////////////


                break;

            case GameState.play:      //PLAYING THE GAME STATE

                if (Global.LV == 0)
                {
                    gameState = GameState.titleScreen;
                }

                //--!!!!!!!--READ ME--!!!!!!!--//
                //  RedRay.UpdateEnemies(gameTime, octonaut); //For some reason This enemy still spawns in other LVs but invisible (The player can collide and take damage with invisible enemies)//

                if (Global.gamePause == false)
                {
                    LazerBeams.UpdateManagerLaser(gameTime, explosion);                                              // we can fix this when we set up the wave class, so don't worry about it.//
                    bd.Update(gameTime);

                    if (Global.LV != 4)
                    {
                        octonaut.Update(gameTime);
                    }



                    UI.Update(gameTime);
                }

                gamePause.Update(gameTime);

                break;
            }

            transition.Update(gameTime);
            lvend.Update(gameTime);

            debug.Update(gameTime);



            base.Update(gameTime);
        }