public override BTResult OnTick(BTBlackBoard blackBoard) { int count = m_lstChild.Count; for (int i = 0; i < count; i++) { if (m_lstResults[i] == BTResult.Running) { BTResult childResult = m_lstChild[i].OnTick(blackBoard); if (childResult != BTResult.Running) { m_lstResults[i] = childResult; m_iCount++; } } } if (m_iCount == count) { for (int i = 0; i < count; i++) { //只要有一个成功了,那么返回成功 if (m_lstResults[i] == BTResult.Success) { return(BTResult.Success); } } return(BTResult.Failure); } return(BTResult.Running); }
protected override BTResult OnCompositeTick(BTBlackBoard blackBoard) { int curIndex = m_iSelectedIndex; int totalCount = m_lstChild.Count; if (curIndex < totalCount) { var child = m_lstChild[curIndex]; BTResult childResult = this.OnRunningChildTick(child, blackBoard); if (childResult == BTResult.Failure) { return(BTResult.Failure); } else if (childResult == BTResult.Success) { m_iSelectedIndex++; } } if (m_iSelectedIndex < totalCount) { return(BTResult.Running); } else { return(BTResult.Success); } }
public virtual BTResult OnEnter(BTBlackBoard blackBoard) { if (m_cChild == null) { return(BTResult.Success); } return(m_cChild.OnTick(blackBoard)); }
sealed public override BTResult OnTick(BTBlackBoard blackBoard) { if (m_cChild != null) { return(m_cChild.OnTick(blackBoard)); } return(BTResult.Success); }
public override bool Evaluate(BTBlackBoard blackBoard) { if (m_cChild == null) { return(true); } return(!m_cChild.Evaluate(blackBoard)); }
public override void Clear() { if (m_eActionResult == BTActionResult.Running) { OnExit(m_cBlackBoard); m_cBlackBoard = null; } m_eActionResult = BTActionResult.Ready; }
sealed public override BTResult OnTick(BTBlackBoard blackBoard) { if (m_cRunningChild != null) { return(OnRunningChildTick(m_cRunningChild, blackBoard)); } else { return(OnCompositeTick(blackBoard)); } }
public override bool Evaluate(BTBlackBoard blackBoard) { bool result = true; int count = m_lstChild.Count; for (int i = 0; i < count; i++) { result = result || (m_lstChild[i] as BTCondition).Evaluate(blackBoard); } return(result); }
sealed public override BTResult OnTick(BTBlackBoard blackBoard) { if (Evaluate(blackBoard)) { return(BTResult.Success); } else { return(BTResult.Failure); } }
public override bool Evaluate(BTBlackBoard blackBoard) { bool result = true; int count = m_lstCondition.Count; for (int i = 0; i < count; i++) { result = result && m_lstCondition[i].Evaluate(blackBoard); } return(result); }
//如果子对象在running状态中,那么,下一帧直接执行 protected BTResult OnRunningChildTick(BTNode child, BTBlackBoard blackBoard) { BTResult result = child.OnTick(blackBoard); if (result == BTResult.Running) { m_cRunningChild = child; } else { m_cRunningChild = null; } return(result); }
public override BTResult OnTick(BTBlackBoard blackBoard) { int count = m_lstChild.Count; for (int i = 0; i < count; i++) { BTResult childResult = m_lstChild[i].OnTick(blackBoard); if (childResult != BTResult.Running) { return(childResult); } } return(BTResult.Running); }
sealed public override BTResult OnTick(BTBlackBoard blackBoard) { if (m_eActionResult == BTActionResult.Ready) { OnEnter(blackBoard); m_eActionResult = BTActionResult.Running; } m_eActionResult = OnRun(blackBoard); if (m_eActionResult == BTActionResult.Ready) { OnExit(blackBoard); } if (m_eActionResult == BTActionResult.Running) { return(BTResult.Running); } return(BTResult.Success); }
public override BTResult OnTick(BTBlackBoard blackBoard) { FP deltaTime = blackBoard.deltaTime; if (m_bIsEnd) { m_bIsEnd = false; m_sTime = 0; m_nCount = 0; } int count = m_lstChild.Count; for (int i = 0; i < count; i++) { if (m_lstResults[i] == BTResult.Running) { BTNode child = m_lstChild[i]; IBTTimeLineNode timeLineNode = child as IBTTimeLineNode; if (timeLineNode.time <= m_sTime) { BTResult result = child.OnTick(blackBoard); if (result != BTResult.Running) { m_lstResults[i] = result; m_nCount++; } } } } m_sTime += deltaTime; if (m_nCount == count) { m_bIsEnd = true; return(BTResult.Success); } return(BTResult.Running); }
protected override BTResult OnCompositeTick(BTBlackBoard blackBoard) { int curIndex = m_iSelectedIndex; int selectedCount = 0; int totalCount = m_lstChild.Count; while (selectedCount < totalCount) { curIndex = curIndex % totalCount; var child = m_lstChild[curIndex]; BTResult childResult = this.OnRunningChildTick(child, blackBoard); if (childResult == BTResult.Failure) { curIndex++; selectedCount++; } else { m_iSelectedIndex = curIndex; return(childResult); } } return(BTResult.Failure); }
public virtual void OnEnter(BTBlackBoard blackBoard) { }
public virtual BTResult Decorate(BTBlackBoard bloackBoard, BTResult result) { return(result); }
//可重写 protected virtual BTResult OnCompositeTick(BTBlackBoard blackBoard) { return(base.OnTick(blackBoard)); }
sealed public override BTResult OnTick(BTBlackBoard blackBoard) { BTResult result = OnEnter(blackBoard); return(Decorate(blackBoard, result)); }
public virtual void OnExit(BTBlackBoard blackBoard) { }
public virtual bool Evaluate(BTBlackBoard blackBoard) { return(true); }
public override bool Evaluate(BTBlackBoard blackBoard) { return(!m_cChild.Evaluate(blackBoard)); }
public virtual BTActionResult OnRun(BTBlackBoard blackBoard) { return(BTActionResult.Running); }
public virtual BTResult OnTick(BTBlackBoard blackBoard) { return(BTResult.Success); }
public virtual BTResult OnEnter(BTBlackBoard blackBoard) { return(m_cChild.OnTick(blackBoard)); }