Example #1
0
 /// <summary>
 /// Executes the behavior tree
 /// </summary>
 /// <param name="ai">AI component</param>
 public void ExecuteBT(MoonAI ai)
 {
     if (BTResult == TaskResult.None | BTResult == TaskResult.Running)
     {
         Profiler.BeginSample("MoonBehavior: Execute BehaviorTree (" + ai.name + ")");
         BTResult = Root.Execute(ai);
         Profiler.EndSample();
     }
 }
Example #2
0
 /// <summary>
 /// Task Priority
 /// </summary>
 public float GetPriority(MoonAI ai)
 {
     if (!PriorityLoaded)
     {
         m_priority     = _Priority.GetValue <float>(ai.Memory);
         PriorityLoaded = true;
     }
     return(m_priority);
 }
Example #3
0
        public TaskResult Execute(MoonAI ai)
        {
            if (!Inizialized)
            {
                OnEnter(ai);
                _Started = true;
            }

            LastResult = OnExecute(ai);


            if (LastResult == TaskResult.Success || LastResult == TaskResult.Failure)
            {
                OnExit(ai);
                _Started = false;
            }
            else
            {
                LastResult = TaskResult.Running;
            }

            return(LastResult);
        }
Example #4
0
 /// <summary>
 /// Called when tasks returns Success or Failure
 /// </summary>
 /// <param name="ai">AI Agent</param>
 public virtual void OnExit(MoonAI ai)
 {
 }
Example #5
0
 /// <summary>
 /// Called when enters the task
 /// </summary>
 /// <param name="ai">AI agent</param>
 public virtual void OnEnter(MoonAI ai)
 {
 }
Example #6
0
 /// <summary>
 /// Execution of the task and it's result
 /// </summary>
 /// <returns>Task result</returns>
 public abstract TaskResult OnExecute(MoonAI ai);