Beispiel #1
0
 void AIUpdate()
 {
     if (_tree.Tick() != BehaveResult.Running)
     {
         Debug.Log("Resetting tree!");
         _tree.Reset();
     }
 }
Beispiel #2
0
 BehaveResult AiUpdate()
 {
     return(m_tree.Tick());
     //try
     //{
     //    return m_tree.Tick();
     //}
     //catch (System.Exception ex)
     //{
     //    Debug.LogError("Ai Tick : { " + ex.Message + " }");
     //    return BehaveResult.Failure;
     //}
 }
Beispiel #3
0
        IEnumerator Runner()
        {
            WaitForSeconds wait = new WaitForSeconds(1 / m_Tree.Frequency);

            while (m_Tree != null)
            {
                if (CanRun())
                {
#if Profiler_Debug
                    m_ActiveAction = System.Enum.ToObject(m_Tree.LibraryActions, m_Tree.LastTickedAction).ToString();
#endif

#if Profiler_Debug
                    Profiler.BeginSample(m_ActiveAction);
#endif
                    try
                    {
                        m_LastTickResult = m_Tree.Tick(m_Agent, null);
                    }
                    catch (Exception e)
                    {
                        Debug.LogWarning("Tree Tick Error : " + e);
                    }

#if Profiler_Debug
                    Profiler.EndSample();
#endif

                    if (m_LastTickResult != BehaveResult.Running)
                    {
                        m_Tree.Reset();
                    }
                }

                yield return(wait);
            }
        }
        //---------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------

        #region Public Member Functions

        //---------------------------------------------------------------------------

        public IEnumerator Start()
        {
            m_Tree =
                BLOpenCogCharacterBehaviours.InstantiateTree
                    (TreeType.CharacterBehaviours_RobotExploreBehaviour
                    , this
                    )
            ;

            while (Application.isPlaying && m_Tree != null)
            {
                yield return(new WaitForSeconds(1.0f / m_Tree.Frequency));

                m_Tree.Tick();
            }
        }
Beispiel #5
0
 void AIUpdate()
 {
     m_Tree.Tick();
 }