public Sequence Initialize(List<BTObject> taskSequence) { this.TaskSequence = taskSequence; this.TaskSequence = this.TaskSequence.OrderByDescending( x => x.Priority ).ToList(); this.currentTask = this.TaskSequence[0]; return this; }
public Selector Initialize(List<BTObject> taskSelectors) { this.TaskSelectors = taskSelectors; this.TaskSelectors = this.TaskSelectors.OrderByDescending( x => x.Priority ).ToList(); this.currentTask = this.TaskSelectors[0]; return this; }
static public BehaviourState ActionHasAppeared(MonoBehaviour mb) { BTObject btObject = ( BTObject )mb; btObject.count = 0; Debug.Log("has appeared"); return(BehaviourState.succeeded); }
public Sequence Initialize(List<BTObject> taskSequence) { if (taskSequence == null) throw new System.ArgumentNullException("taskSequence", "Cannot supply null taskSequence to Sequence class"); this.TaskSequence = taskSequence; this.TaskSequence = TaskSequence.OrderByDescending( x => x.Priority ).ToList(); this.currentTask = this.TaskSequence[0]; return this; }
public Selector Initialize(List<BTObject> taskSelectors) { if (taskSelectors == null) throw new System.ArgumentNullException("taskSelectors", "Cannot supply taskSelectors as null to Selector Initialize"); this.TaskSelectors = taskSelectors; this.TaskSelectors = TaskSelectors.OrderByDescending( x => x.Priority ).ToList(); this.currentTask = this.TaskSelectors[0]; return this; }
public void Awake() { btTree = new BehaviourTree(); baseNodeData = btTree.buildTree(btTreeData, typeof(BTObject)); btObjectList = new BTObject[count]; for (int i = 0; i < count; ++i) { GameObject go = ( GameObject )Instantiate(testObject, Vector3.zero, Quaternion.identity); btObjectList[i] = go.GetComponent <BTObject>(); btObjectList[i].init(btTree, baseNodeData); } }
public override void StartObject() { if (this.TaskSequence == null || this.TaskSequence.Count <= 0) { Debug.LogWarning("Sequence has no Task Sequence list set"); this.CurrentState = TaskState.TASK_CANCELLED; } else { if (this.CurrentState == TaskState.TASK_WAITING) { this.CurrentState = TaskState.TASK_RUNNING; this.currentTask = this.TaskSequence[0]; this.currentTask.StartObject(); if (this.Counter > 1 && !this.Looping) this.Looping = true; } } }
static public BehaviourState ActionIsReadyToGo(MonoBehaviour mb) { BTObject btObject = ( BTObject )mb; if (btObject.count < 100) { if (btObject.count == 0) { Debug.Log("is waiting"); } ++btObject.count; return(BehaviourState.running); } Debug.Log("is ready to go"); return(BehaviourState.succeeded); }
public void SetId(BTObject btObject) { this.id = btObject.id; }
public void SetObjectId(BTObject btObject) { btObject.id = this.id; }
private void Update() { if (this.CurrentState == TaskState.TASK_RUNNING) { if (this.currentTask.CurrentState == TaskState.TASK_DONE) { this.currentTask = getNextTask(); if (this.currentTask == null) { this.CurrentState = TaskState.TASK_DONE; } else { this.currentTask.StartObject(); } } else if (this.currentTask.CurrentState == Task.TaskState.TASK_ABORTED || this.currentTask.CurrentState == Task.TaskState.TASK_CANCELLED) { this.CurrentState = this.currentTask.CurrentState; } } else if (this.CurrentState != TaskState.TASK_WAITING) { if (!this.bDoneRunning) { if (this.Looping) { if (this.Counter <= 1 || this.counterCount < this.Counter) { this.counterCount++; this.CurrentState = TaskState.TASK_WAITING; foreach (BTObject task in this.TaskSequence) { task.bDoneRunning = false; task.CurrentState = TaskState.TASK_WAITING; } } else { this.Looping = false; this.bDoneRunning = true; } } else this.bDoneRunning = true; } } }
public override void StartObject() { if (this.TaskSelectors == null || this.TaskSelectors.Count <= 0) { Debug.LogWarning("Selector has no Task Selector list set"); this.CurrentState = TaskState.TASK_CANCELLED; } else { if (this.CurrentState == TaskState.TASK_WAITING) { this.CurrentState = TaskState.TASK_RUNNING; this.currentTask = this.TaskSelectors[0]; this.currentTask.StartObject(); if (this.Counter > 1 && !this.Looping) this.Looping = true; if (BTName == "BTObject") BTName = "Selector"; if (bPaused) bPaused = false; } } }