Beispiel #1
0
 public Countdown(float countdownTime, IOnCountdownEnd listener, bool destroyWhenEnds, bool isScheduled)
 {
     this.countdownTime   = countdownTime;
     this.listener        = listener;
     this.destroyWhenEnds = destroyWhenEnds;
     this.isScheduled     = isScheduled;
     countdownStartTime   = Instance.time;
 }
Beispiel #2
0
            /// <summary>
            /// Should be used when just want to gets ID and doesn't want to start countdown at this moment
            /// </summary>
            /// <param name="countdown">Countdown time in seconds</param>
            /// <param name="listener">Listener to listen call back when countdown ends</param>
            /// <param name="removeWhenEnds">If <code><b>True</b></code> countdown will be removed when ends</param>
            /// <returns></returns>
            public static long Create(float countdown, IOnCountdownEnd listener = null, bool removeWhenEnds = false)
            {
                if (countdown < 0)
                {
                    throw new SystemException("Countdown time cannot be less than 0!");
                }
                long id = NextId();

                Instance.endedCountdowns.Add(id, new Countdown(countdown, listener, removeWhenEnds, false));
                return(id);
            }
Beispiel #3
0
            public static long StartSchedule(float interval, IOnCountdownEnd listener)
            {
                if (interval < 0)
                {
                    throw new Exception("Interval time cannot be less than 0!");
                }
                long id = NextId();

                Instance.notEndedCountdowns.Add(id, new Countdown(interval, listener, false, true));
                return(id);
            }
Beispiel #4
0
            /// <summary>
            /// Starts a new countdown with given time. If time is less than 0 then exception is thrown.
            /// It's important to take <b>id</b> as returned long value.
            /// </summary>
            /// <param name="countdown">Time to countdown</param>
            /// <param name="start">True, if should start immidetly</param>
            /// <param name="listener">Listener to listen call back when countdown ends</param>
            /// <param name="removeWhenEnds">If <code><b>True</b></code> countdown will be removed when ends</param>
            /// <returns>id of new countdown</returns>
            public static long Start(float countdown, IOnCountdownEnd listener = null, bool removeWhenEnds = false)
            {
                if (countdown < 0)
                {
                    throw new Exception("Time for countdown cannot be less than 0!");
                }
                long id = NextId();

                Instance.notEndedCountdowns.Add(id, new Countdown(countdown, listener, removeWhenEnds, false));
                return(id);
            }
Beispiel #5
0
 /// <summary>
 /// Should be used when just want to gets ID and doesn't want to start countdown at this moment
 /// </summary>
 /// <param name="listener">Listener to listen call back when countdown ends</param>
 /// <param name="removeWhenEnds">If <code><b>True</b></code> countdown will be removed when ends</param>
 /// <returns></returns>
 public static long Create(IOnCountdownEnd listener = null, bool removeWhenEnds = false)
 {
     return(Create(0, listener, removeWhenEnds));
 }