static void LockManager(int key, TIME_PRIORITY priority)
 {
     _key           = key;
     keyIsActive    = true;
     keyPriority    = priority;
     savedTimeScale = Time.timeScale;
 }
 static void SetTimeScaleInternal(float scale, int key, TIME_PRIORITY priority)
 {
     if (timeScaleRoutine != null)
     {
         instance.StopCoroutine(timeScaleRoutine);
     }
     timeScaleRoutine = instance.StartCoroutine(SetTimeScaleInternalRoutine(scale, key, priority));
 }
 /// <summary> Set a temporary time scale that expires after a set time. </summary>
 /// <param name="scale">The scale you wish to set</param>
 /// <param name="key">They key that this scale is tied to.</param>
 /// <param name="priority">The priority of the scale.</param>
 /// <param name="numFrames">The amount of frames the time scale should affect.</param>
 public static bool SetTimedTimeScale(float scale, int numFrames, int key, TIME_PRIORITY priority)
 {
     if (SetTimeScale(scale, key, priority))
     {
         timerMode = 1;
         scaleTimerF.Activate(numFrames);
         return(true);
     }
     return(false);
 }
 /// <summary> Set a temporary time scale that expires after a set time. </summary>
 /// <param name="scale">The scale you wish to set</param>
 /// <param name="key">They key that this scale is tied to.</param>
 /// <param name="priority">The priority of the scale.</param>
 /// <param name="time">the duration of the scale in seconds.</param>
 public static bool SetTimedTimeScale(float scale, float time, int key, TIME_PRIORITY priority)
 {
     if (SetTimeScale(scale, key, priority))
     {
         timerMode = 0;
         scaleTimerT.Activate(time);
         return(true);
     }
     return(false);
 }
 static IEnumerator SetTimeScaleInternalRoutine(float scale, int key, TIME_PRIORITY priority)
 {
     while (timeStopped)
     {
         yield return(null);
     }
     LockManager(key, priority);
     Time.timeScale      = scale;
     Time.fixedDeltaTime = defaultFixedTimeStep * scale;
 }
 /// <summary> Set the time scale. </summary>
 /// <param name="scale">The scale you wish to set</param>
 /// <param name="key">They key that this scale is tied to.</param>
 /// <param name="priority">The priority of the scale.</param>
 public static bool SetTimeScale(float scale, int key, TIME_PRIORITY priority)
 {
     if (!CanOverrideScale(key, ref priority))
     {
         return(false);
     }
     UnlockManager();
     SetTimeScaleInternal(scale, key, priority);
     return(true);
 }
 static bool CanOverrideScale(int key, ref TIME_PRIORITY priority)
 {
     if (priority == TIME_PRIORITY.NEVER)
     {
         priority = TIME_PRIORITY.LOW;
     }
     // If priority is not always, or the priority is lower than current
     if (priority != TIME_PRIORITY.ALWAYS && priority <= keyPriority)
     {
         // If there is an active key and the passed key is not the same
         if (keyIsActive && _key != key)
         {
             return(false);                // Than we cannot override
         }
     }
     return(true);        // Otherwise we can
 }
 /// <summary> Set a temporary time scale that expires after a set time. </summary>
 /// <param name="scale">The scale you wish to set</param>
 /// <param name="key">They key that this scale is tied to.</param>
 /// <param name="priority">The priority of the scale.</param>
 /// <param name="numFrames">The amount of frames the time scale should affect.</param>
 public static bool SetTimedTimeScale(float scale, int numFrames, string key, TIME_PRIORITY priority)
 {
     return(SetTimedTimeScale(scale, numFrames, key.GetHashCode(), priority));
 }
 /// <summary> Set a temporary time scale that expires after a set time. </summary>
 /// <param name="scale">The scale you wish to set</param>
 /// <param name="key">They key that this scale is tied to.</param>
 /// <param name="priority">The priority of the scale.</param>
 /// <param name="time">the duration of the scale in seconds.</param>
 public static bool SetTimedTimeScale(float scale, float time, string key, TIME_PRIORITY priority)
 {
     return(SetTimedTimeScale(scale, time, key.GetHashCode(), priority));
 }
示例#10
0
 static void SetGameSpecificTimeScale(float scale, int key, TIME_PRIORITY priority)
 {
     defaultTimeScale = scale;
     SetTimeScale(defaultTimeScale, key, priority);
 }
示例#11
0
 static void SetGameSpecificTimeScale(float scale, string key, TIME_PRIORITY priority)
 {
     SetGameSpecificTimeScale(scale, key.GetHashCode(), priority);
 }