public override void OnUpdate(float deltaTime) { CurTime += deltaTime; BaseDecoratorNode decoratorNode = Node as BaseDecoratorNode; decoratorNode.ChildNode.OnUpdate(deltaTime); if (decoratorNode.ChildNode.Status == NodeStatus.ERROR) { decoratorNode.Status = NodeStatus.ERROR; return; } if (Duration <= CurTime) { decoratorNode.Status = NodeStatus.SUCCESS; return; } if (decoratorNode.ChildNode.Status == NodeStatus.FAILED || decoratorNode.ChildNode.Status == NodeStatus.SUCCESS) { decoratorNode.ChildNode.OnReset(); } }
public override void OnUpdate(float deltaTime) { BaseDecoratorNode decoratorNode = Node as BaseDecoratorNode; decoratorNode.ChildNode.OnUpdate(deltaTime); if (decoratorNode.ChildNode.Status == NodeStatus.ERROR) { decoratorNode.Status = NodeStatus.ERROR; return; } if (decoratorNode.ChildNode.Status == NodeStatus.FAILED || decoratorNode.ChildNode.Status == NodeStatus.SUCCESS) { string baseFiled = (string)Node.NodeAgent.GetVarDicByKey(UntilKey); if (baseFiled == UntilValue) { decoratorNode.Status = decoratorNode.ChildNode.Status; } else { decoratorNode.ChildNode.OnReset(); } } }
public override void OnUpdate(float deltaTime) { BaseDecoratorNode decoratorNode = Node as BaseDecoratorNode; decoratorNode.ChildNode.OnUpdate(deltaTime); if (decoratorNode.ChildNode.Status == NodeStatus.ERROR) { decoratorNode.Status = NodeStatus.ERROR; return; } if (decoratorNode.ChildNode.Status == NodeStatus.FAILED || decoratorNode.ChildNode.Status == NodeStatus.SUCCESS) { CurTimes++; if (LoopTimes <= CurTimes && LoopTimes != -1) { decoratorNode.Status = NodeStatus.SUCCESS; } else { decoratorNode.ChildNode.OnReset(); } } }
public override void OnUpdate(float deltaTime) { BaseDecoratorNode decoratorNode = Node as BaseDecoratorNode; decoratorNode.ChildNode.OnUpdate(deltaTime); if (decoratorNode.ChildNode.Status == NodeStatus.ERROR) { decoratorNode.Status = NodeStatus.ERROR; return; } if (decoratorNode.ChildNode.Status == NodeStatus.FAILED || decoratorNode.ChildNode.Status == NodeStatus.SUCCESS) { Debug.Log(LogContent); decoratorNode.Status = NodeStatus.SUCCESS; } }
/// <summary> /// 通过类型获取节点 /// </summary> /// <param name="classType"></param> /// <returns></returns> public static BaseNode GetBaseNode(string classType) { BaseNode baseNode = null; NodeProxyInfo nodeProxyInfo = BehaviorTreeManager.Instance.GetRegistedNodeType(classType); if (nodeProxyInfo == null) { Debug.LogError($"错误!!行为树节点未注册 ClassType:{classType}"); return(null); } switch (nodeProxyInfo.behaviorNodeType) { case BehaviorNodeType.Action: baseNode = new BaseActionNode(); break; case BehaviorNodeType.Condition: baseNode = new BaseConditionNode(); break; case BehaviorNodeType.Composite: baseNode = new BaseCompositeNode(); break; case BehaviorNodeType.Decorator: baseNode = new BaseDecoratorNode(); break; default: Debug.LogError($"错误!!行为树节点类型错误 ClassType:{classType}"); break; } baseNode.NodeInfo = nodeProxyInfo; return(baseNode); }