protected override bool JudgeCondition(BTTreeRuntimePack _runTimePack) { Vector3 currentPosition = _runTimePack.GameObject.AbsPosition; Vector3 distinationPosition = currentPosition; GuardBTPack btpack = _runTimePack.GameObject.GetComponent(typeof(GuardBTPack)) as GuardBTPack; if (btpack == null) { return(false); } if (m_isGuardMode) { GameObject distinationGameObject = btpack.GameObject.Scene._gameObjectList .GetOneGameObjectByName(btpack.GuardPointGameObjectName); if (distinationPosition != null) { distinationPosition = distinationGameObject.AbsPosition; } } else { Vector3 hotspot = _runTimePack.GetFromBlackboard(m_hotspotName, "") as CatVector3; if (hotspot != null) { distinationPosition = hotspot; } } Vector3 delta = distinationPosition - currentPosition; _runTimePack.AddToBlackboard(m_outputDestinationNmae, new CatVector3(distinationPosition)); _runTimePack.AddToBlackboard(m_outputDeltaName, new CatVector3(delta)); return(delta.X * delta.X > btpack.ArriveDistance * btpack.ArriveDistance); }
public override bool OnRunning(BTTreeRuntimePack _runtimePack) { CatInteger suspect = _runtimePack.GetFromBlackboard(m_suspectName, new CatInteger(0)) as CatInteger; suspect.SetValue(suspect + m_increament); _runtimePack.AddToBlackboard(m_suspectName, suspect); return(true); }
private void UpdateBTTreeRuntimePack() { if (m_btTreeRuntimePack == null) { m_btTreeRuntimePack = new BTTreeRuntimePack(m_gameObject, m_btTreeName); } else { m_btTreeRuntimePack.BTTreeName = m_btTreeName; } }
public override bool OnRunning(BTTreeRuntimePack _runtimePack) { CatController controller = _runtimePack.GameObject.GetComponent( typeof(CatController)) as CatController; if (controller != null) { controller.m_wantKill = true; } return(true); }
/** * @brief set BTTree * Warning: if it is observing a runtimepack, this action will stop * the observation **/ public void SetBTTree(BTTree _btree) { if (IsObservingRuntimePack()) { m_observingRuntimePack = null; } m_btTree = _btree; CreateChart(); AutoLayoutChart(); Refresh(); }
/** * @brief BTConditionNode, judge if the hunter spot anything. **/ protected override bool JudgeCondition(BTTreeRuntimePack _runTimePack) { Hunter hunter = _runTimePack.GameObject.GetComponent(typeof(Hunter)) as Hunter; if (hunter != null) { return(hunter.SpotAny()); } return(false); }
public override bool OnRunning(BTTreeRuntimePack _runtimePack) { Hunter hunter = _runtimePack.GameObject.GetComponent(typeof(Hunter)) as Hunter; if (hunter != null) { Vector2 hotspot = hunter.LastSpot.GetPointInWorld(); _runtimePack.AddToBlackboard(m_hotspotName, new CatVector3(hotspot.X, hotspot.Y, 0.0f)); } return(false); }
/** * @brief set BTTreeRuntimePack and start observing the tree **/ public void SetBTTreeAndObservingRuntimePack(BTTreeRuntimePack _runtimePack) { if (!IsObservingRuntimePack() || m_observingRuntimePack.BTTree != m_btTree) { if (_runtimePack == null) { SetBTTree(null); } else { SetBTTree(_runtimePack.BTTree); } } m_observingRuntimePack = _runtimePack; }
protected override bool JudgeCondition(BTTreeRuntimePack _runtimePack) { CatInteger suspect = _runtimePack.GetFromBlackboard(m_suspectName, new CatInteger(0)) as CatInteger; if (m_isOver) { GuardBTPack btpack = _runtimePack.GameObject.GetComponent(typeof(GuardBTPack)) as GuardBTPack; if (btpack != null) { return(suspect > btpack.SuspectThreshold); } return(false); } else { return(suspect <= 0); } }
public override bool OnRunning(BTTreeRuntimePack _runtimePack) { CatController controller = _runtimePack.GameObject.GetComponent(typeof(CatController)) as CatController; if (controller == null) { return(false); } CatVector3 delta = _runtimePack.GetFromBlackboard(m_deltaName) as CatVector3; if (delta != null) { if (delta.X > 0.0) { controller.m_wantRight = true; } else { controller.m_wantLeft = true; } } return(true); }
protected override bool JudgeCondition(BTTreeRuntimePack _btTree) { string mode = _btTree.GetFromBlackboard("Mode", "") as string; return(mode == m_mode); }
public override bool OnRunning(BTTreeRuntimePack _runtimePack) { _runtimePack.AddToBlackboard("Mode", m_mode); return(false); }
private void InitializeForm() { m_selectedNode = null; m_observingRuntimePack = null; m_blackboardMap = null; }
/** * @brief if the given runtimePack is being observed. * Note that if _runtimePack == null and no runtimePack is observing, * the result is true * */ public bool IsObservingThisRuntimePack(BTTreeRuntimePack _runtimePack) { return(m_observingRuntimePack == _runtimePack); }
/** * @brief open BTTree and observe RuntimePack **/ public void ObserveLiveBTTree(BTTreeRuntimePack _runtimePack) { InitializeAll(); BindRuntimePack(_runtimePack); btTreeViewer.SetBTTreeAndObservingRuntimePack(_runtimePack); }
/** * @brief set the runtime pack to blackboard **/ private void BindRuntimePack(BTTreeRuntimePack _runtimePack) { m_observingRuntimePack = _runtimePack; blackboard.Rows.Clear(); m_blackboardMap = new Dictionary <string, int>(); }