Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 private void UpdateBTTreeRuntimePack()
 {
     if (m_btTreeRuntimePack == null)
     {
         m_btTreeRuntimePack = new BTTreeRuntimePack(m_gameObject, m_btTreeName);
     }
     else
     {
         m_btTreeRuntimePack.BTTreeName = m_btTreeName;
     }
 }
Exemplo n.º 4
0
        public override bool OnRunning(BTTreeRuntimePack _runtimePack)
        {
            CatController controller = _runtimePack.GameObject.GetComponent(
                typeof(CatController)) as CatController;

            if (controller != null)
            {
                controller.m_wantKill = true;
            }
            return(true);
        }
Exemplo n.º 5
0
 /**
  * @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();
 }
Exemplo n.º 6
0
        /**
         * @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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 /**
  * @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;
 }
Exemplo n.º 9
0
        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);
            }
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        protected override bool JudgeCondition(BTTreeRuntimePack _btTree)
        {
            string mode = _btTree.GetFromBlackboard("Mode", "") as string;

            return(mode == m_mode);
        }
Exemplo n.º 12
0
 public override bool OnRunning(BTTreeRuntimePack _runtimePack)
 {
     _runtimePack.AddToBlackboard("Mode", m_mode);
     return(false);
 }
Exemplo n.º 13
0
 private void InitializeForm()
 {
     m_selectedNode         = null;
     m_observingRuntimePack = null;
     m_blackboardMap        = null;
 }
Exemplo n.º 14
0
 /**
  * @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);
 }
Exemplo n.º 15
0
 /**
  * @brief open BTTree and observe RuntimePack
  **/
 public void ObserveLiveBTTree(BTTreeRuntimePack _runtimePack)
 {
     InitializeAll();
     BindRuntimePack(_runtimePack);
     btTreeViewer.SetBTTreeAndObservingRuntimePack(_runtimePack);
 }
Exemplo n.º 16
0
 /**
  * @brief set the runtime pack to blackboard
  **/
 private void BindRuntimePack(BTTreeRuntimePack _runtimePack)
 {
     m_observingRuntimePack = _runtimePack;
     blackboard.Rows.Clear();
     m_blackboardMap = new Dictionary <string, int>();
 }