Ejemplo n.º 1
0
 private void Awake()
 {
     _stateMachine   = new StateMachine();
     _loading_State  = new Loading_State();
     _inMenu_State   = new InMenu_State();
     _playing_State  = new Playing_State();
     _quit_State     = new Quit_State();
     _burger_State   = new UIGameBurger_State();
     _levelEnd_State = new UILevelEnd_State();
     _levels_State   = new UILevels_State();
     _screenFader    = FindObjectOfType <ScreenFader>();
 }
Ejemplo n.º 2
0
    void Awake()
    {
        //first, reference all of the state scripts
        setupState   = GetComponent <Setup_State> ();
        playingState = GetComponent <Playing_State> ();
        pauseState   = GetComponent <Pause_State> ();
        endState     = GetComponent <End_State> ();

        //get prepping
        currentState = Game_State.Setup_State;

        //basic stats
        playerEnergy = 5;
        playerHealth = 5;

        //ready to go
        ChangeState();
    }
        public Window_Return_Info Update(GameTime gameTime, KeyPress keyPress)
        {
            Window_Return_Info window_Return_Info;
            window_Return_Info.windowTransition = false;
            window_Return_Info.newState = Game_Window_State.Game_Mode_State;

            if (reload == true)
            {
                Reload();
            }

            if (change_level_bool == true)
            {
                playing_State = Playing_State.fade_out_state;
                change_level_bool = false;
            }

            // Change Game_States between Game and Pause States
            if (keyPress.key_Esc == 1)
            {
                if (is_paused == true && playing_State == Playing_State.pause_state) { playing_State = Playing_State.game_state; is_paused = false; }
                else if (is_paused == false && playing_State == Playing_State.game_state) { playing_State = Playing_State.pause_state; is_paused = true; }
            }

            // Display Dev_Info
            if (keyPress.key_T == 1)
            {
                if (dev_display == true) { dev_display = false; }
                else if (dev_display == false) { dev_display = true; }
            }

            CameraStroll();

            switch (playing_State)
            {
                case Playing_State.fade_in_state:

                    FadeDelay -= gameTime.ElapsedGameTime.TotalSeconds;

                    if (FadeDelay <= 0)
                    {
                        FadeDelay = fade_Delay;
                        fade_AlphaValue += fadeIncrement;

                        if (fade_AlphaValue >= 1)
                        {
                            fade_AlphaValue = MathHelper.Clamp(fade_AlphaValue, 0, 1);
                            playing_State = Playing_State.game_state;
                        }
                    }
                    break;

                case Playing_State.game_state:
                    player.Update(gameTime, keyPress, halt_movement);

                    for (int i = 0; i < gameObjectsStore.elementStore.Count(); i++)
                    {
                        gameObjectsStore.elementStore[i].Update( this, gameTime, keyPress, player.BoundingRectangle, player.Position);
                    }

                    Exits_Map_Based();
                    break;

                case Playing_State.fade_out_state:

                    player.animation_To_Idle();
                    FadeDelay -= gameTime.ElapsedGameTime.TotalSeconds;

                    if (FadeDelay <= 0)
                    {
                        FadeDelay = fade_Delay;
                        fade_AlphaValue -= fadeIncrement;

                        if (fade_AlphaValue <= 0)
                        {
                            if (next_Window_State_Bool == true)
                            {
                                window_Return_Info.windowTransition = true;
                                window_Return_Info.newState = Game_Window_State.Splash_Screen_State;
                                Dismiss();
                                fade_AlphaValue = 0;
                            }
                            else
                            {
                                fade_AlphaValue = MathHelper.Clamp(fade_AlphaValue, 0, 1);
                                playing_State = Playing_State.loading_state;
                            }
                        }
                    }

                    break;
                case Playing_State.loading_state:
                    Refresh();
                    playing_State = Playing_State.fade_in_state;
                    break;

                case Playing_State.pause_state:
                    Pause_Update(keyPress);
                    break;
            }

            return window_Return_Info;
        }
        public void Reload()
        {
            Pause_Reload();
            screen_Background = content.Load<Texture2D>("Fades/White");
            dev_Base = content.Load<Texture2D>("Dev/Dev_Base");
            screen_Fade = content.Load<Texture2D>("Fades/Black");
            Dev_Font = content.Load<SpriteFont>("Fonts/Dev_Font");
            loading_Font = content.Load<SpriteFont>("Fonts/Loading_Font");

            fade_AlphaValue = 0f;
            FadeDelay = 0;

            Building_Restart();
            playing_State = Playing_State.fade_in_state;
            is_paused = false;

            next_Window_State_Bool = false;
            reload = false;
        }