Example #1
0
 void UpdateState(float es_)
 {
     if (transitioning)
     {
         transitionTimer.Update(es_);
         if (transitionTimer.Complete())
         {
             if (transitionIN)
             {
                 transitionIN = false;
                 transitionTimer.Reset();
                 switchedState = true;
             }
             else
             {
                 transitioning = false;
                 transitionIN  = true;
             }
         }
     }
     if (switchedState)
     {
         currentState    = nextState;
         currentSubState = nextSubState;
         switchedState   = false;
         if (shouldReset)
         {
             shouldReset = false;
             CreateNewGame();
         }
         StateChangeSwitch();
     }
 } //set the next state and substate to the current one at the start of the update
Example #2
0
        void ToggleState(GameState newState_, GameSubState newSubState_)
        {
            nextState    = newState_;
            nextSubState = newSubState_;

            if (nextSubState != GameSubState.Pause && !(currentSubState == GameSubState.Pause && nextState == GameState.Game && !shouldReset))
            {
                SetTransition();
            }
            else
            {
                switchedState = true;
            }
        } //set new nextstate and data based on old and new state
Example #3
0
        protected override void Initialize()
        {
            base.Initialize();
            currentState    = GameState.Menu;
            currentSubState = GameSubState.Main;

            CreateInputProfile();
            CreateScenes();

            transitionTimer = new MonoGame.FZT.Assets.Timer(2f);
            villagerTick    = new MonoGame.FZT.Assets.Timer(10f);
            gameTick        = new MonoGame.FZT.Assets.Timer(GameData.GameTick);

            PhysicsManager.CreateWorld();
            PhysicsManager.SetUnitRatio(64);
            PhysicsManager.SetupDebugview(GraphicsDevice, Content);

            cursor = new CursorManager();

            rng = new Random();

            fdrawer = new FontDrawer();
            List <TextureDrawer> font = new List <TextureDrawer>();
            string    junk            = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\".,;:?!'\"][-+/\\^&é0123456789";
            Texture2D tex             = Content.Load <Texture2D>("Placeholder/font2");

            for (int i = 0; i < junk.Length; i++)
            {
                font.Add(new TextureDrawer(tex, new TextureFrame(new Rectangle(8 * i, 0, 8, 10), new Point(0, 0)), null, junk[i].ToString(), null, null));
            }
            fdrawer.fonts.Add(new DrawerCollection(font, "font"));
            tooltipText       = "";
            changeTooltipText = true;
            tooltipPos        = new Vector2(33, 2);

            currentUI  = mainUI;
            currentBG  = mainMenuBG;
            cloudSpeed = 3;
            cloudTimer = 0;
        }