public override ResultType Execute() { ResultType resultType = ResultType.Fail; for (int i = 0; i < nodeChildList.Count; ++i) { NodeBase nodeBase = nodeChildList[i]; nodeBase.Preposition(); resultType = nodeBase.Execute(); nodeBase.Postposition(resultType); if (resultType == ResultType.Running) { _runningNode |= (1 << i); } if (resultType == _desiredResult) { return(ResultType.Success); } } NodeNotify.NotifyExecute(EntityId, NodeId, ResultType.Running, Time.realtimeSinceStartup); return(ResultType.Running); }
public override ResultType Execute() { ++_executeCount; ResultType resultType = ResultType.Fail; for (int i = 0; i < nodeChildList.Count; ++i) { NodeBase nodeBase = nodeChildList[i]; nodeBase.Preposition(); resultType = nodeBase.Execute(); nodeBase.Postposition(resultType); if (resultType == ResultType.Running) { _runningNode |= (1 << i); } } if (_repeatCount == -1 || _executeCount < _repeatCount) { resultType = ResultType.Running; } else { resultType = ResultType.Success; } NodeNotify.NotifyExecute(EntityId, NodeId, resultType, Time.realtimeSinceStartup); return(resultType); }
public void Execute() { if (null != _rootNode) { _rootNode.Preposition(); ResultType resultType = _rootNode.Execute(); _rootNode.Postposition(resultType); } }
public override ResultType Execute() { ResultType resultType = ResultType.Fail; int successCount = 0; int failCount = 0; for (int i = 0; i < nodeChildList.Count; ++i) { NodeBase nodeBase = nodeChildList[i]; nodeBase.Preposition(); resultType = nodeBase.Execute(); nodeBase.Postposition(resultType); if (resultType == ResultType.Fail) { ++failCount; continue; } if (resultType == ResultType.Success) { ++successCount; continue; } if (resultType == ResultType.Running) { _runningNode |= (1 << i); continue; } } if (successCount >= nodeChildList.Count) { resultType = ResultType.Success; } else if (failCount >= nodeChildList.Count) { resultType = ResultType.Fail; } else { resultType = ResultType.Running; } NodeNotify.NotifyExecute(EntityId, NodeId, (int)resultType, Time.realtimeSinceStartup); return(resultType); }
public override ResultType Execute() { _randomCount = 0; int index = -1; if (lastRunningNode != null) { index = lastRunningNode.NodeIndex; } lastRunningNode = null; ResultType resultType = ResultType.Fail; for (int i = 0; i < nodeChildList.Count; ++i) { if (index < 0) { index = GetRandom(); } NodeBase nodeBase = nodeChildList[index]; index = -1; nodeBase.Preposition(); resultType = nodeBase.Execute(); nodeBase.Postposition(resultType); if (resultType == ResultType.Fail) { break; } if (resultType == ResultType.Success) { continue; } if (resultType == ResultType.Running) { lastRunningNode = nodeBase; break; } } NodeNotify.NotifyExecute(EntityId, NodeId, resultType, Time.realtimeSinceStartup); return(resultType); }
private ResultType ExecuteNode(NodeBase nodeBase) { ResultType resultType = ResultType.Fail; if (null != nodeBase) { nodeBase.Preposition(); resultType = nodeBase.Execute(); nodeBase.Postposition(resultType); } if (resultType == ResultType.Running) { lastRunningNode = nodeBase; } NodeNotify.NotifyExecute(EntityId, NodeId, resultType, Time.realtimeSinceStartup); return(resultType); }
protected ResultType ExecuteNode(NodeBase nodeBase, bool isFirstNode) { ResultType resultType = ResultType.Fail; if (null != nodeBase) { nodeBase.Preposition(); resultType = nodeBase.Execute(); nodeBase.Postposition(resultType); } if (!isFirstNode && resultType == ResultType.Running) { lastRunningNode = nodeBase; } NodeNotify.NotifyExecute(EntityId, NodeId, (int)resultType, Time.realtimeSinceStartup); return(resultType); }
public override ResultType Execute() { ResultType resultType = ResultType.Fail; if (nodeChildList.Count <= 0) { return(ResultType.Fail); } NodeBase nodeBase = nodeChildList[0]; nodeBase.Preposition(); resultType = nodeBase.Execute(); nodeBase.Postposition(resultType); if (resultType == ResultType.Running) { lastRunningNode = nodeBase; } NodeNotify.NotifyExecute(EntityId, NodeId, (int)resultType, Time.realtimeSinceStartup); return(resultType); }