예제 #1
0
 private void AwakeTaskAndChildren(BTTask task, int index)
 {
     task.__BTAwake(this, index);
     for (var i = 0; i < task.ChildTasks.Length; i++)
     {
         AwakeTaskAndChildren(task.ChildTasks[i], i);
     }
 }
예제 #2
0
        protected virtual void Update()
        {
#if UNITY_EDITOR
            transform.position    = Vector3.zero;
            transform.eulerAngles = Vector3.zero;
#endif
            if (ChildTasks.Length == 0)
            {
                return;
            }
            if (Time.time - _lastUpdateTime < _updateDelta)
            {
                return;
            }
            _lastUpdateTime = _updateDelta;
            if (!CurItem)
            {
                if (!_repeatAlways)
                {
                    if (!ShowGUI)
                    {
                        gameObject.SetActive(false);
                    }
                    return;
                }
                DoWithAllTask(task => task.__BTReset());
                CurItem = ChildTasks[0];
                CurItem.__BTStart();
            }
            while (true)
            {
                var state = CurItem.__BTUpdate();
                if (state == BTState.Running)
                {
                    break;
                }
                CurItem = CurItem.NextBt;
                if (!CurItem)
                {
                    break;
                }
                CurItem.__BTStart();
            }
        }
예제 #3
0
        protected virtual void Awake()
        {
            _childTasks = new BTTask[transform.childCount];
            if (ChildTasks.Length == 0)
            {
                return;
            }
            for (var i = 0; i < transform.childCount; i++)
            {
                ChildTasks[i] = transform.GetChild(i).GetComponent <BTTask>();
                AwakeTaskAndChildren(ChildTasks[i], i);
            }
            CurItem = ChildTasks[0];

#if !UNITY_EDITOR
            m_ShowGUI = false;
            DestroyGUIAll(transform);
#endif
        }