Example #1
0
        /// <summary>
        /// Calls the given event after the given amount of time or frames have passed
        /// </summary>
        /// <param name="timedEvent">The action to do once the timer is complete</param>
        /// <param name="countType">The type of counter to create. Ex. Counting by frames, counting by scaled time, counting by unscaled time</param>
        /// <param name="duration">How long to wait before performing the action</param>
        /// <returns></returns>
        public TimedAction StartNewTimedAction(TimedEvent timedEvent, TimedActionCountType countType, float duration)
        {
            TimedAction action = new TimedAction {
                CountType = countType, Duration = duration, Event = timedEvent
            };

            switch (countType)
            {
            case TimedActionCountType.SCALEDTIME:
                action.TimeStarted = Time.time;
                break;

            case TimedActionCountType.UNSCALEDTIME:
                action.TimeStarted = Time.unscaledTime;
                break;

            case TimedActionCountType.FRAME:
                action.TimeStarted = Time.frameCount;
                break;
            }
            action.Enable();
            _timedActions.Add(action);
            return(action);
        }