// Selector wants only the first task that succeeds // try all tasks in order // stop and return true on the first task that succeeds // return false if all tasks fail public override void run() { //Debug.Log("selector running child task #" + currentTaskIndex); currentTask = children[currentTaskIndex]; EventBus.StartListening(currentTask.TaskFinished, OnChildTaskFinished); currentTask.run(); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.G)) { if (!executingBehavior) { myCurrentTask = getCurrentTask(); executingBehavior = true; myCurrentTask.run(); } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.G)) { if (!executingBehavior) { executingBehavior = true; myCurrentTask = BuildTask_GetTreasue(); EventBus.StartListening(myCurrentTask.TaskFinished, OnTaskFinished); myCurrentTask.run(); } } }