Update() public method

public Update ( ) : void
return void
Example #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)
        {
            if (!IsReadyToUpdate)
            {
                return;
            }

            // Update the time since the last frame and the game's clock.
            TimeSinceLastFrame = gameTime.ElapsedGameTime.TotalMilliseconds;
            TimeRunning       += (long)gameTime.ElapsedGameTime.TotalMilliseconds;

            Drawable.ResetTotalDrawnCount();

            // Keep the window updated with the current resolution.
            WindowManager.Update();
            MouseManager.Update();
            KeyboardManager.Update();
            ScreenManager.Update(gameTime);
            AudioManager.Update(gameTime);

            // Update the global sprite container
            GlobalUserInterface.Update(gameTime);

            // Keep the RPC client up-to-date.
            DiscordManager.Client?.Invoke();
            LogManager.Update(gameTime);
            Logger.Update();

            base.Update(gameTime);
        }
Example #2
0
        /// <summary>
        /// Update the scene.
        /// </summary>
        public override void Update()
        {
            //Update wallpapers.
            Wallpapers.Update();

            //Update windows.
            WindowManager.Update();
        }
Example #3
0
        public void UpdateScene(GameTime gameTime, KeyboardState keyState, GamePadState gamePadState, MouseState mouseState)
        {
            _KeyboardManager.HandleKeys(gameTime, keyState);
            _WindowManager.HandleMouse(gameTime, _LastMouseState, mouseState);
            _WindowManager.Update(gameTime);

            // State handling
            var map = _LevelManager.CurrentMap;

            if (map != null)
            {
                map.Update(gameTime);

                if (_State == GameState.SceneUnloading)
                {
                    _Fade -= 8;
                    if (_Fade < 0)
                    {
                        _Fade  = 0;
                        _State = _AfterUnload;

                        if (_State == GameState.MainMenu)
                        {
                            _WindowManager.OpenWindow(_MainMenuWindow);
                        }
                        else if (_State == GameState.SceneLoading)
                        {
                            _LevelManager.NavigateTo(_NextMapName, out Point startLocation);
                            _NextMapName = null;
                        }
                    }
                }
                else if (_State == GameState.SceneLoading)
                {
                    _Fade += 8;
                    if (_Fade > 255)
                    {
                        _Fade  = 255;
                        _State = GameState.SceneIdle;
                    }
                }
                else if (_State == GameState.SceneIdle)
                {
                    var player = map.Player;
                    if (player != null && map.CheckTeleport(player.Location, out string newMapName))
                    {
                        player.ClearMovement();
                        _State       = GameState.SceneUnloading;
                        _AfterUnload = GameState.SceneLoading;
                        _NextMapName = newMapName;
                    }
                }
            }

            _LastGamePadState = gamePadState;
            _LastMouseState   = mouseState;
        }
Example #4
0
 public override void Update(GameTime gameTime)
 {
     manager.Update(gameTime);
     foreach (TempThing thing in testSquares)
     {
         thing.Update();
         if (thing.Clicked)
         {
             AddThingModWindow(thing);
         }
     }
 }
Example #5
0
        public static void RenderToolsMenu(this RenderComposer composer)
        {
            if (ToolsWindowManager == null)
            {
                ToolsWindowManager = new WindowManager();
            }

            composer.SetDepthTest(false);
            composer.SetUseViewMatrix(false);

            ToolsWindowManager.Update();

            ImGui.NewFrame();
            RenderToolsMenu(composer, ToolsWindowManager);
            ToolsWindowManager.Render(composer);
            composer.RenderUI();
        }
Example #6
0
        protected override void Update(GameTime gameTime)
        {
            if (Quit)
            {
                NetworkClient.Shutdown();
                Exit();
            }

            // TODO: Add your update logic here
            InputManager.Update();
            WindowManager.Update(gameTime);


            NetworkClient.CheckConnection(gameTime);

            base.Update(gameTime);
        }
Example #7
0
        protected override void Update(GameTime gameTime)
        {
            CurrentFrame++;
            Now = (float)gameTime.TotalGameTime.Ticks / 10000000f;
            DT  = (float)gameTime.ElapsedGameTime.Ticks / 10000000f;

            Input.Update(DT);
            Sound.Update(DT);

            if (State == GameState.Menu)
            {
                _mainMenu.Update(DT);
            }
            else if (State == GameState.Game)
            {
                Console.Update(DT);
                WindowManager.Update(DT);
                AreaChanger.Update(DT);
                GUI.Update(DT);
                PopupMessageManager.Update(DT);

                //Toggle options/exit
                if (/*!deathEffectManager->isActive() && */ !WindowManager.IsWindowOpen && SMH.Input.IsDown(Keys.Escape))
                {
                    SMH.WindowManager.OpenMiniMenu(MiniMenuMode.Exit);
                }

                if (!WindowManager.IsWindowOpen && !AreaChanger.IsChangingAreas)
                {
                    GameTime += DT;

                    Player.Update(DT);
                    Environment.Update(DT);
                    EnemyManager.Update(DT);
                    LootManager.Update(DT);
                    ProjectileManager.Update(DT);
                    NPCManager.Update(DT);
                }
            }
        }
Example #8
0
        public override void Update(GameTime gameTime)
        {
            mapManager.Update(gameTime);
            windowManager.Update(gameTime);

            if (mapManager.enterDoor)
            {
                Global.canMove       = false;
                doorTimer            = 30;
                mapManager.enterDoor = false;
                ScreenManager.LoadScreen(new MainGameScreen(Game), new FadeTransition(GraphicsDevice, Color.Black, 1.0f));
            }

            if (doorTimer > 0)
            {
                doorTimer--;
            }
            else
            {
                Global.canMove = true;
            }
        }
Example #9
0
 public override void Update(GameTime gameTime)
 {
     _windowManager.Update(gameTime);
 }
Example #10
0
 public override void Update(GameTime gameTime)
 {
     windows.Update(gameTime);
 }
Example #11
0
 void Update()
 {
     WM.Update();
 }
Example #12
0
        protected override bool RenderInternal(RenderComposer c)
        {
            c.SetUseViewMatrix(false);
            c.SetDepthTest(false);

            ImGui.NewFrame();
            ImGui.BeginMainMenuBar();
            GetImGuiMetrics();

            ImGuiIOPtr io = ImGui.GetIO();

            _captureMouse    = io.WantCaptureMouse;
            _captureKeyboard = io.WantCaptureKeyboard;
            _captureText     = io.WantTextInput;

            var fullScreenEditorOpen = false;

            if (Children != null)
            {
                for (var i = 0; i < Children.Count; i++)
                {
                    UIBaseWindow child = Children[i];
                    if (child.Size == c.CurrentTarget.Size)
                    {
                        // todo: maybe something more explicit, like a bool in ImGuiWindow?
                        fullScreenEditorOpen = true;
                    }
                }
            }
            InputTransparent = !_captureMouse && !_captureKeyboard && !fullScreenEditorOpen;

            if (ImGui.BeginMenu("Audio"))
            {
                if (ImGui.MenuItem("Audio Preview"))
                {
                    AddLegacyWindow(new AudioMixer());
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Art"))
            {
                if (ImGui.MenuItem("Animation Editor"))
                {
                    AddLegacyWindow(new AnimationEditor());
                }
                if (ImGui.MenuItem("Animation Editor New (WIP)"))
                {
                    AddChild(new Animation2DEditor());
                }
                if (ImGui.MenuItem("Rogue Alpha Remover"))
                {
                    AddLegacyWindow(new RogueAlphaRemoval());
                }
                if (ImGui.MenuItem("Palette Editor"))
                {
                    AddLegacyWindow(new PaletteEditor());
                }
                if (ImGui.MenuItem("Font Preview"))
                {
                    AddLegacyWindow(new FontPreview());
                }
                if (ImGui.MenuItem("PNG Exporter"))
                {
                    AddLegacyWindow(new PngExporter());
                }
                if (ImGui.MenuItem("3D Object Viewer"))
                {
                    AddChild(new Viewer3D());
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Gameplay"))
            {
                if (ImGui.MenuItem("Map Editor"))
                {
                    AddChild(new MapEditor());
                }
                if (ImGui.MenuItem("Tmx Viewer"))
                {
                    AddChild(new TmxViewer());
                }
#if DEBUG
                if (ImGui.MenuItem("Collision Viewer"))
                {
                    AddLegacyWindow(new CollisionViewer());
                }
#else
                ImGui.MenuItem("Collision Viewer [Requires DEBUG]");
#endif
                if (ImGui.MenuItem("UI Editor"))
                {
                    AddChild(new UIEditorWindow());
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Engine"))
            {
                if (ImGui.MenuItem("Performance Monitor"))
                {
                    AddChild(new PerformanceMonitor());
                }
                if (ImGui.MenuItem("Memory Viewer"))
                {
                    AddLegacyWindow(new MemoryViewer());
                }
#if DEBUG
                if (ImGui.MenuItem("Coroutine Viewer"))
                {
                    AddLegacyWindow(new CoroutineViewer());
                }
#else
                ImGui.MenuItem("Coroutine Viewer [Requires DEBUG]");
#endif
                if (ImGui.MenuItem("Gpu Texture Viewer"))
                {
                    AddLegacyWindow(new GpuTextureViewer());
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Game"))
            {
                if (ImGui.MenuItem("Open Folder"))
                {
                    Process.Start("explorer.exe", ".");
                }

                foreach (KeyValuePair <string, Action <UIBaseWindow> > tool in ToolsManager.CustomToolsFactory)
                {
                    if (ImGui.MenuItem(tool.Key))
                    {
                        tool.Value(this);
                    }
                }

                ImGui.EndMenu();
            }

            ImGui.EndMainMenuBar();

            LegacyWindowManager.Update();
            LegacyWindowManager.Render(c);
            if (Children == null)
            {
                AfterRenderChildren(c);
            }
            return(true);
        }
Example #13
0
 public void Update()
 {
     _menu.Update();
 }
Example #14
0
        protected override void Update(GameTime gameTime)
        {
            if (DoExit)
            {
                Exit();
            }

            if (!IsActive)
            {
                assets.Update(true);

                return;
            }

            if (input.keyboard.Down(Microsoft.Xna.Framework.Input.Keys.LeftControl) && input.keyboard.Pressed(Microsoft.Xna.Framework.Input.Keys.F))
            {
                windowManager.Fullscreen = !windowManager.Fullscreen;
            }

            if (input.keyboard.Pressed(Microsoft.Xna.Framework.Input.Keys.S))
            {
                StateSave();
            }

            if (input.keyboard.Pressed(Microsoft.Xna.Framework.Input.Keys.L))
            {
                StateLoad();
            }

            if (Scene != null)
            {
                if (world != null)
                {
                    drawSystem.OnUnload();

                    for (int i = 0; i < systems.Length; i++)
                    {
                        systems[i].OnUnload();
                    }
                }

                world?.Dispose();

                world = new World();

                drawSystem.Reset();

                for (int i = 0; i < systems.Length; i++)
                {
                    systems[i].Reset();
                }

                Scene.Load();

                Scene = null;

                drawSystem.OnLoad();

                for (int i = 0; i < systems.Length; i++)
                {
                    systems[i].OnLoad();
                }

                GC.Collect();
            }

            input.Update();

            for (int i = 0; i < systems.Length; i++)
            {
                systems[i].Update();
            }

            windowManager.Update();

            assets.Update();

            base.Update(gameTime);

            if (RemovedEntities.Count > 0)
            {
                for (int i = 0; i < RemovedEntities.Count; i++)
                {
                    RemovedEntities[i].Dispose();

                    RemovedEntities[i] = default;
                }
            }
        }
Example #15
0
 public override void Update(GameTime gameTime)
 {
     updateDrawValues();
     windows.Update(gameTime);
 }
Example #16
0
    public void Update(uint elapsed)
    {
        mElapsed += elapsed;
        if (mElapsed < UPDATE_INTERVAL)
        {
            return;
        }

        elapsed = mElapsed;

        mElapsed = 0;

        if (mEventSystem != null)
        {
            mEventSystem.Update();
        }
        if (mSceneManager != null)
        {
            mSceneManager.Update(elapsed);
        }
        if (mWindowManager != null)
        {
            mWindowManager.Update(elapsed);
        }
        if (mSoundManager != null)
        {
            mSoundManager.Update(elapsed);
        }
        if (mAnimationManager != null)
        {
            mAnimationManager.Update();
        }
        if (mInputSystem != null)
        {
            mInputSystem.Update();
        }
        if (mBossBloodUIManager != null)
        {
            mBossBloodUIManager.Update(elapsed);
        }

        if (mPromptManager != null)
        {
            mPromptManager.Update(elapsed);
        }
        if (mPopTipManager != null)
        {
            mPopTipManager.Update(elapsed);
        }
        if (mGuideManager != null)
        {
            mGuideManager.Update(elapsed);
        }

        if (mEggManager != null)
        {
            mEggManager.Update(elapsed);
        }

        if (mQuackUIManager != null)
        {
            mQuackUIManager.Update(elapsed);
        }

        if (mShopManager != null)
        {
            mShopManager.Update(elapsed);
        }

        if (mModuleManager != null)
        {
            mModuleManager.Update(elapsed);
        }

        if (mNextFlow != GAME_FLOW_ENUM.GAME_FLOW_INVAILD)
        {
            if (mCurFlow != null)
            {
                mCurFlow.Term();
                mCurFlow = null;
            }
            GAME_FLOW_ENUM curFlowEnum = mNextFlow;
            mNextFlow = GAME_FLOW_ENUM.GAME_FLOW_INVAILD;

            mCurFlow = createNextFlow(curFlowEnum);
        }

        if (mCurFlow != null)
        {
            FLOW_EXIT_CODE exitCode = mCurFlow.Update(elapsed);
            if (exitCode != FLOW_EXIT_CODE.FLOW_EXIT_CODE_NONE)
            {
                onFlowExit(mCurFlow, exitCode);
            }
        }
    }