Пример #1
0
        public virtual void Update(SAMTime gameTime)
        {
#if DEBUG
            UPSCounter.StartCycle(gameTime);
#endif
            var state = InputStateMan.GetNewState(MapOffsetX, MapOffsetY);

#if DEBUG
            if (_updateDebugSettings)
            {
                DebugSettings.Update(state);
            }
            GCMonitor.Update(gameTime, state);
#endif

            if (FloatMath.IsZero(GameSpeed))
            {
                // render these two always
                DebugDisp.Update(gameTime, state);
                GameHUD.Update(gameTime, state);
                return;
            }
            else if (FloatMath.IsOne(GameSpeed))
            {
                InternalUpdate(gameTime, state, gameTime);
            }
            else if (GameSpeed < 1f)
            {
                var internalTime = gameTime.Stretch(GameSpeed, 1);

                InternalUpdate(internalTime, state, gameTime);
            }
            else if (GameSpeed > 1f)
            {
                int runCount = (int)GameSpeed;

                var timeVirtual = gameTime.Stretch(GameSpeed / runCount, 1f / runCount);
                var timeReal    = gameTime.Stretch(1f / runCount, 1f / runCount);

                for (int i = 0; i < runCount; i++)
                {
                    InternalUpdate(timeVirtual, state, timeReal);
                }
            }
            else
            {
                // okay - dafuq
                throw new ArgumentException(nameof(GameSpeed) + " = " + GameSpeed, nameof(GameSpeed));
            }

#if DEBUG
            UPSCounter.EndCycle();
#endif
        }