Example #1
0
        public EBTStatus SelectNearestRoute()
        {
            if (Singleton <BattleLogic> .GetInstance() == null || BattleLogic.instance.mapLogic == null)
            {
                return(EBTStatus.BT_FAILURE);
            }
            CUtilList <WaypointsHolder> waypointsList = BattleLogic.instance.mapLogic.GetWaypointsList(m_wrapper.actor.pCharMeta.ActorCamp);

            if (waypointsList == null || waypointsList.Count == 0)
            {
                return(EBTStatus.BT_FAILURE);
            }
            long            num             = long.MaxValue;
            WaypointsHolder waypointsHolder = null;

            for (int i = 0; i < waypointsList.Count; i++)
            {
                VecInt3 vInt = new VecInt3(waypointsList[i].startPoint.transform.position);
                long    sqrMagnitudeLong2D = (m_wrapper.actorLocation - vInt).sqrMagnitudeLong2D;
                if (sqrMagnitudeLong2D < num)
                {
                    waypointsHolder = waypointsList[i];
                    num             = sqrMagnitudeLong2D;
                }
            }
            if (waypointsHolder == null)
            {
                return(EBTStatus.BT_FAILURE);
            }
            m_wrapper.m_curWaypointsHolder        = waypointsHolder;
            m_wrapper.m_curWaypointTarget         = m_wrapper.m_curWaypointsHolder.startPoint;
            m_wrapper.m_curWaypointTargetPosition = new VecInt3(m_wrapper.m_curWaypointTarget.transform.position);
            return(EBTStatus.BT_SUCCESS);
        }
Example #2
0
        public bool SelectRoute()
        {
            if (m_wrapper == null)
            {
                DebugHelper.Assert(false, "m_wrapper为空");
                return(false);
            }
            if (BattleLogic.instance.mapLogic == null)
            {
                /*DebugHelper.Assert(false, "BattleLogic.GetInstance().mapLogic为空, GameState:{0}", new object[]
                 * {
                 *  GameFSM.instance.currentStateName
                 * });*/
                return(false);
            }
            CUtilList <WaypointsHolder> waypointsList = BattleLogic.instance.mapLogic.GetWaypointsList(m_wrapper.actor.pCharMeta.ActorCamp);

            if (waypointsList == null || waypointsList.Count == 0)
            {
                return(false);
            }
            int num = UnityEngine.Random.Range(0, 10000);//(int)FrameRandom.Random(10000u);

            num %= waypointsList.Count;
            if (waypointsList[num] == null)
            {
                DebugHelper.Assert(false, "routeList[index]为空");
                return(false);
            }
            m_wrapper.m_curWaypointsHolder        = waypointsList[num];
            m_wrapper.m_curWaypointTarget         = m_wrapper.m_curWaypointsHolder.startPoint;
            m_wrapper.m_curWaypointTargetPosition = new VecInt3(m_wrapper.m_curWaypointTarget.transform.position);
            return(true);
        }
Example #3
0
        public EBTStatus SelectRouteBySelfCampIndex()
        {
            ICharDataBase actorDataProvider           = CharDataCenter.instance.GetCharDataProvider(CharDataDb.ServerDataDb);
            CUtilList <WaypointsHolder> waypointsList = BattleLogic.instance.mapLogic.GetWaypointsList(m_wrapper.actor.pCharMeta.ActorCamp);

            if (!DebugRobot.instance.OnePath)
            {
                CharServerData CharServerData = default(CharServerData);
                actorDataProvider.GetCharServerData(ref m_wrapper.actor.pCharMeta, ref CharServerData);
                int num = CharServerData.TheExtraInfo.BornPointIndex;

                if (waypointsList == null || waypointsList.Count == 0)
                {
                    return(EBTStatus.BT_INVALID);
                }
                if (num < 0)
                {
                    return(EBTStatus.BT_INVALID);
                }
                for (int i = 0; i < waypointsList.Count; i++)
                {
                    if (!(waypointsList[i] == null))
                    {
                        if (waypointsList[i].m_index == num)
                        {
                            m_wrapper.m_curWaypointsHolder        = waypointsList[i];
                            m_wrapper.m_curWaypointTarget         = m_wrapper.m_curWaypointsHolder.startPoint;
                            m_wrapper.m_curWaypointTargetPosition = new VecInt3(m_wrapper.m_curWaypointTarget.transform.position);
                            return(EBTStatus.BT_SUCCESS);
                        }
                    }
                }
                num %= waypointsList.Count;
                m_wrapper.m_curWaypointsHolder        = waypointsList[num];
                m_wrapper.m_curWaypointTarget         = m_wrapper.m_curWaypointsHolder.startPoint;
                m_wrapper.m_curWaypointTargetPosition = new VecInt3(m_wrapper.m_curWaypointTarget.transform.position);
                return(EBTStatus.BT_SUCCESS);
            }
            else
            {
                m_wrapper.m_curWaypointsHolder        = waypointsList[0];
                m_wrapper.m_curWaypointTarget         = m_wrapper.m_curWaypointsHolder.startPoint;
                m_wrapper.m_curWaypointTargetPosition = new VecInt3(m_wrapper.m_curWaypointTarget.transform.position);
                return(EBTStatus.BT_SUCCESS);
            }
        }