Exemple #1
0
        /// <summary>
        /// Runs the intervene action if it needs to
        /// </summary>
        /// <returns>True if the intervene action was run</returns>
        private bool RunInterveneAction()
        {
            if (interveneAction != null)
            {
                interveneAction.Update(dataSet);

                if (interveneAction.preconditionsValid)
                {
                    state = STATE.ACTION;
                    interveneAction.Perform();
                    return(true);
                }
            }

            return(false);
        }
Exemple #2
0
        public virtual void FixedUpdate()
        {
            if (interveneAction != null)
            {
                interveneAction.Update(dataSet);

                if (interveneAction.preconditionsValid)
                {
                    state = STATE.ACTION;
                    interveneAction.Perform();
                    return;
                }
            }

            if (runningThread == THREADTYPE.NONE)
            {
                if (InternalRemoveActions() || InternalAddActions())
                {
                    StartUpdatingTrees();
                }
                else
                {
                    StartRunning();
                }
            }

            if (activeActions != null && activeActions.Count > 0)
            {
                activeActions[0].Run(Time.deltaTime);

                if (activeActions[0].target != null && Vector3.Distance(transform.position, activeActions[0].target.transform.position) < activeActions[0].requiredRange)
                {
                    state = STATE.ACTION;
                    activeActions[0].Perform();
                }
                else
                {
                    state = STATE.MOVING;
                    Move(activeActions[0]);
                }
            }
        }