Exemplo n.º 1
0
 public static void Invoke(System.Action Func, Hourglass hourglassTrigger)
 {
     if (hourglassTrigger.Expired)
         Func();
     else
         invocations.Add(new Invocation(Func, hourglassTrigger));
 }
Exemplo n.º 2
0
 public void ActionDelayed(float delay)
 {
     if ((settingsFlags & EventActionSettingFlags.ActionOnlyOnce) == 0 || !actioned)
     {
         Hourglass newHoruglass = new Hourglass(delay, Hourglass.CountdownType.ScaledTime);
         newHoruglass.Paused = !isActiveAndEnabled;
         delayedActionTimes.Add(newHoruglass);
     }
 }
Exemplo n.º 3
0
        private void ReinitialiseTimers()
        {
            hourglasses.Clear();
            repeatHourglasses.Clear();

            for (int i = 0; i < times.Length; ++i)
            {
                Hourglass newHourglass = new Hourglass(times[i], Hourglass.CountdownType.ScaledTime);
                newHourglass.Paused = !isActiveAndEnabled;
                hourglasses.Add(newHourglass);
            }
            for (int i = 0; i < repeatTimes.Length; ++i)
            {
                Hourglass newHourglass;
                newHourglass = new Hourglass(0, Hourglass.CountdownType.ScaledTime);
                if (!preWarmedRepeat)
                    Hourglass.Change(newHourglass, repeatTimes[i], Hourglass.ChangeType.WillExpireAt);
                newHourglass.Paused = !isActiveAndEnabled;
                repeatHourglasses.Add(newHourglass);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Applies a change to the passed instance, as per the method of change.
 /// </summary>
 /// <param name="target"></param>
 /// <param name="value"></param>
 /// <param name="changeType"></param>
 public static void Change(Hourglass target, float value, ChangeType changeType)
 {
     if (!target.paused)
     {
         if (changeType == ChangeType.AddTime)
             target.expiryTime += value;
         else if (changeType == ChangeType.CantExpireBefore)
             target.expiryTime = Mathf.Max(target.expiryTime, value);
         else if (changeType == ChangeType.MustExpireBefore)
             target.expiryTime = Mathf.Min(target.expiryTime, value);
         else if (changeType == ChangeType.WillExpireAt)
             target.expiryTime = value;
     }
     else
     {
         if (changeType == ChangeType.AddTime)
             target.timeRemaining += value;
         else if (changeType == ChangeType.CantExpireWithin)
             target.timeRemaining = Mathf.Max(target.timeRemaining, value);
         else if (changeType == ChangeType.MustExpireWithin)
             target.timeRemaining = Mathf.Min(target.timeRemaining, value);
         else if (changeType == ChangeType.WillExpireIn)
             target.timeRemaining = value;
     }
 }
Exemplo n.º 5
0
 public Invocation(System.Action methodToInvoke, Hourglass hourglassTrigger)
 {
     this.methodToInvoke = methodToInvoke;
     this.hourglassTrigger = hourglassTrigger;
 }