예제 #1
0
 private void UpdateNodesOfType(UpdateTimeType p_type)
 {
     for (int i = 0; i < _listOfNodes.Count; i++)
     {
         if (_listOfNodes[i].updateMode == p_type)
         {
             if (_listOfNodes[i].ShouldNodeBeCleaned())
             {
                 _listOfNodes[i] = null;
                 _listOfNodes.RemoveAt(i);
                 i--;
                 continue;
             }
             _listOfNodes[i].UpdateNode();
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Constructor of TimerNode. Used internally by the Timer class to create the timer, do not use it.
        /// </summary>
        /// <remarks>
        /// Constructor of TimerNode. Used internally by the Timer class to create the timer, do not use it.
        /// </remarks>
        public TimerNode(float p_time, int p_framesToWait, bool p_useTimeScale, UpdateTimeType p_updateMode, bool p_useLoop, int p_id, Action p_callbackUser, Action p_actionUpdate, Action p_actionAnticipate)
        {
            //Initialize Data
            _id             = p_id;
            _timeToWait     = p_time;
            _framesToWait   = p_framesToWait;
            _updateMode     = p_updateMode;
            _usingLoop      = p_useLoop;
            currentTimeStep = 0f;
            _useTimeScale   = p_useTimeScale;

            _delegatedCallback = p_callbackUser;
            _onUpdate          = p_actionUpdate;
            _onAnticipate      = p_actionAnticipate;

            //StartPlaying
            ChangeState(NodeState.PLAYING);
        }
예제 #3
0
        /// <summary>
        /// Constructor of TweenNode. Used internally by the Tween class to create the tween, do not use it.
        /// </summary>
        /// <remarks>
        /// Constructor of TweenNode. Used internally by the Tween class to create the tween, do not use it. To create TweenNode use the Tween class.
        /// </remarks>
        public TweenNode(float p_startValue, float p_finalValue, float p_duration, TweenLoopType p_loopMode, UpdateTimeType p_updateMode, bool p_useTimeScale, int p_id, Action <float> p_callbackUser, Action p_callbackUpdate, Action p_callbackAnticipate)
        {
            //Initialize Data
            _id             = p_id;
            _startValue     = p_startValue;
            _endValue       = p_finalValue;
            _useTimeScale   = p_useTimeScale;
            _updateMode     = p_updateMode;
            _loopMode       = p_loopMode;
            _duration       = p_duration;
            currentTimeStep = 0f;

            //Initialize Info
            _delegatedCallback = p_callbackUser;
            _onUpdate          = p_callbackUpdate;
            _onAnticipate      = p_callbackAnticipate;

            //Initialize
            ChangeState(NodeState.PLAYING);
        }
예제 #4
0
 /// <summary>
 /// Function to be called from a TweenNode to add itself to this module dictionary.
 /// </summary>
 public void AddNode(TweenNode p_node, UpdateTimeType p_updateMode)
 {
     _listOfNodes.Add(p_node);
 }
예제 #5
0
        /// @cond
                #endif

        #region Timed Function
        /// <summary>
        /// Function to call an action after the passed seconds value.
        /// </summary>
        /// <remarks>
        /// Function to call an action after the passed seconds value.
        /// Changing the Vox.UpdateTimeType can make the timer only be called after every update has hapenned, for example, by changing it to Vox.UpdateTimeType.LATE_UPDATE.
        /// <code>
        ///
        /// Vox.TimerNode _debugTimerNode = null;
        ///
        /// _debugTimerNode = Vox.Timer.WaitSeconds(1, false, 0, true, UpdateTimeType.LATE_UPDATE, delegate()
        /// {
        ///     Debug.log(_player.transform.position); // Will debug player position after the player update which has the movement happended.
        /// });
        ///
        /// </code>
        ///
        /// </remarks>
        private static TimerNode TimedFunction(float p_secondsToWait, bool p_isLoop, int p_framesToWait, int p_numberOfLoopIterations, bool p_useScaleTime, UpdateTimeType p_updateMode, Action p_callback)
        {
            TimerNode __node = null;

            Action __actionUpdate = delegate
            {
                if (__node.currentState == NodeState.PLAYING)
                {
                    if (__node.frameCounter >= __node.framesToWait)
                    {
                        if (__node.useTimeScale)
                        {
                            __node.currentTimeStep += Time.deltaTime;
                        }
                        else
                        {
                            __node.currentTimeStep += Time.unscaledDeltaTime;
                        }

                        __node.currentTimeStep = Mathf.Min(__node.currentTimeStep, p_secondsToWait);

                        if (__node.currentTimeStep >= __node.timeToWait)
                        {
                            if (__node.usingLoop)
                            {
                                __node.loopIteration++;

                                if (p_callback != null)
                                {
                                    p_callback();
                                }

                                if (__node.loopIteration < p_numberOfLoopIterations || p_numberOfLoopIterations == 0)
                                {
                                    __node.currentTimeStep = 0;
                                }
                                else
                                {
                                    __node.SetNodeToBeCleaned();
                                }
                            }
                            else
                            {
                                if (p_callback != null)
                                {
                                    p_callback();
                                }

                                __node.SetNodeToBeCleaned();
                            }
                        }
                    }
                    else
                    {
                        __node.frameCounter++;
                    }
                }
            };

            Action __actionAnticipate = delegate
            {
                if (p_callback != null)
                {
                    p_callback();
                }

                __node.SetNodeToBeCleaned();
            };

            __node = new TimerNode(p_secondsToWait, p_framesToWait, p_useScaleTime, p_updateMode, p_isLoop, TimerModule.instance.GetNextNodeID(), p_callback, __actionUpdate, __actionAnticipate);

            TimerModule.instance.AddNode(__node);

            return(__node);
        }