//public void AddChildren(BehaviorTree.Node a){ // Children.Add (a); // Debug.Log (Children.Count); //} public override BehaviorTree.Result Process() { image.color = new Color(1, 1, 0, image.color.a); if (currentLeafIndex == Children.Count) { currentLeafIndex = 0; image.color = new Color(0, 1, 0, image.color.a); return(BehaviorTree.Result.SUCCESS); } BehaviorTree.Result status = this.Children [currentLeafIndex].Process(); if (status == BehaviorTree.Result.SUCCESS) { currentLeafIndex += 1; } if (status == BehaviorTree.Result.FAILURE) { image.color = new Color(1, 0, 0, image.color.a); return(BehaviorTree.Result.FAILURE); } return(status); }
public override BehaviorTree.Result Process() { image.color = new Color(1, 1, 0, image.color.a); if (currentLeafIndex == Children.Count) { image.color = new Color(1, 0, 0, image.color.a); return(BehaviorTree.Result.FAILURE); } BehaviorTree.Result status = this.Children [currentLeafIndex].Process(); if (status == BehaviorTree.Result.FAILURE) { currentLeafIndex += 1; //Debug.Log (currentLeafIndex); } if (status == BehaviorTree.Result.SUCCESS) { if (currentLeafIndex != 0) { currentLeafIndex = 0; foreach (Sequence child in Children) { child.GetImage().color = new Color(0, 0, 1, child.GetImage().color.a); //child.Children [0].image.color = new Color (0, 0, 1, child.Children [0].image.color.a); //child.Children[1].image.color = new Color (0, 0, 1, child.Children [1].image.color.a); //Debug.Log ("asd"); } //Debug.Log (currentLeafIndex); } else { currentLeafIndex = 0; image.color = new Color(0, 1, 0, image.color.a); return(BehaviorTree.Result.SUCCESS); } } return(BehaviorTree.Result.RUNNING); }