The Time class provides a global interface for time measurement and control. It affects all time-dependent computations. Use the TimeMult Property to make your own computations time-dependent instead of frame-dependent. Otherwise, your game logic will depend on how many FPS the player's machine achieves and mit behave differently on very slow or fast machines.
Esempio n. 1
0
        internal static void EditorUpdate(IEnumerable <GameObject> updateObjects, bool simulateGame, bool forceFixedStep)
        {
            isUpdating = true;

            Time.FrameTick(forceFixedStep, simulateGame);

            if (simulateGame)
            {
                pluginManager.InvokeBeforeUpdate();

                UpdateUserInput();
                Scene.Current.Update();

                List <ICmpUpdatable> updatables = new List <ICmpUpdatable>();
                foreach (GameObject obj in updateObjects)
                {
                    if (obj.Scene == Scene.Current)
                    {
                        continue;
                    }

                    updatables.Clear();
                    obj.GetComponents(updatables);
                    for (int i = 0; i < updatables.Count; i++)
                    {
                        if (!(updatables[i] as Component).Active)
                        {
                            continue;
                        }
                        updatables[i].OnUpdate();
                    }
                }

                pluginManager.InvokeAfterUpdate();
            }
            else
            {
                Scene.Current.EditorUpdate();

                List <ICmpUpdatable> updatables = new List <ICmpUpdatable>();
                foreach (GameObject obj in updateObjects)
                {
                    updatables.Clear();
                    obj.GetComponents(updatables);
                    for (int i = 0; i < updatables.Count; i++)
                    {
                        if (!(updatables[i] as Component).Active)
                        {
                            continue;
                        }
                        updatables[i].OnUpdate();
                    }
                }
            }

            sound.Update();

            RunCleanup();

            isUpdating = false;

            if (terminateScheduled)
            {
                Terminate();
            }
        }