示例#1
0
        /// <summary>
        /// when this ActionTask completes the ActionTask passed into continueWith will be started. Note that the continueWith task should not
        /// be running so it should be created with one of the ActionTask.create variants (which don't start the task automatically).
        /// </summary>
        /// <returns>The with.</returns>
        /// <param name="actionTask">Action task.</param>
        public ActionTask continueWith(ActionTask actionTask)
        {
            if (actionTask.isRunning())
            {
                Debug.LogError("Attempted to continueWith an ActionTask that is already running. You can only continueWith tasks that have not started yet");
            }
            else
            {
                _continueWithTask = actionTask;
            }

            return(this);
        }
示例#2
0
        /// <summary>
        /// the current task will halt execution until the ActionTask passed into waitFor completes. Note that it must be an already running task!
        /// </summary>
        /// <returns>The for.</returns>
        /// <param name="actionTask">Action task.</param>
        public ActionTask waitFor(ActionTask actionTask)
        {
            if (!actionTask.isRunning())
            {
                Debug.LogError("Attempted to waitFor an ActionTask that is not running. You can only waitFor tasks that are already running.");
            }
            else
            {
                _waitForTask = actionTask;
            }

            return(this);
        }
示例#3
0
		/// <summary>
		/// the current task will halt execution until the ActionTask passed into waitFor completes. Note that it must be an already running task!
		/// </summary>
		/// <returns>The for.</returns>
		/// <param name="actionTask">Action task.</param>
		public ActionTask waitFor( ActionTask actionTask )
		{
			if( !actionTask.isRunning() )
				Debug.LogError( "Attempted to waitFor an ActionTask that is not running. You can only waitFor tasks that are already running." );
			else
				_waitForTask = actionTask;

			return this;
		}
示例#4
0
		/// <summary>
		/// when this ActionTask completes the ActionTask passed into continueWith will be started. Note that the continueWith task should not
		/// be running so it should be created with one of the ActionTask.create variants (which don't start the task automatically).
		/// </summary>
		/// <returns>The with.</returns>
		/// <param name="actionTask">Action task.</param>
		public ActionTask continueWith( ActionTask actionTask )
		{
			if( actionTask.isRunning() )
				Debug.LogError( "Attempted to continueWith an ActionTask that is already running. You can only continueWith tasks that have not started yet" );
			else
				_continueWithTask = actionTask;

			return this;
		}
示例#5
0
        public override bool tick()
        {
            // if we have a waitForTask we dont do anything until it completes
            if (_waitForTask != null)
            {
                if (_waitForTask.isRunning())
                {
                    return(false);
                }
                _waitForTask = null;
            }

            if (_isPaused)
            {
                return(false);
            }


            var deltaTime = _isTimeScaleIndependent ? Time.unscaledDeltaTime : Time.deltaTime;

            // handle our initial delay first
            if (_initialDelay > 0f)
            {
                _initialDelay -= deltaTime;

                // catch the overflow if we have any. if we end up less than 0 while decrementing our initial delay we make that our elapsedTime
                // so that the Action gets called and so that we keep time accurately.
                if (_initialDelay < 0f)
                {
                    _elapsedTime = -_initialDelay;
                    _action(this);

                    // if we repeat continue on. if not, then we end things here
                    if (_repeats)
                    {
                        return(false);
                    }
                    else
                    {
                        // all done. run the continueWith if we have one
                        if (_continueWithTask != null)
                        {
                            _continueWithTask.start();
                        }

                        // if stop was called on this ActionTask we need to be careful that we don't return true which will tell ZestKit
                        // to remove the task while it is iterating it's list of tweens causing bad things to happen.
                        if (_isCurrentlyManagedByZestKit)
                        {
                            _isCurrentlyManagedByZestKit = false;
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }


            // done with initial delay. now we either tick the Action every frame or use the repeatDelay to delay calls to the Action
            if (_repeatDelay > 0f)
            {
                if (_elapsedTime > _repeatDelay)
                {
                    _elapsedTime -= _repeatDelay;
                    _action(this);
                }
            }
            else
            {
                _action(this);
            }

            _unfilteredElapsedTime += deltaTime;
            _elapsedTime           += deltaTime;

            return(false);
        }