Exemplo n.º 1
0
        public static CharacterInfo GetRandomTargetHelper(CharacterInfo srcObj, CharacterRelation relation, AiTargetType type)
        {
            CharacterInfo target = null;

            DashFireSpatial.ISpatialSystem spatialSys = srcObj.SpatialSystem;
            if (null != spatialSys)
            {
                List <DashFireSpatial.ISpaceObject> objs = spatialSys.GetObjectInCircle(srcObj.GetMovementStateInfo().GetPosition3D(), srcObj.ViewRange, (distSqr, obj) => IsWantedTargetForRandomTarget(srcObj, relation, type, obj));
                int index = Helper.Random.Next(objs.Count);
                if (index >= 0 && index < objs.Count)
                {
                    target = objs[index].RealObject as CharacterInfo;
                }
            }
            return(target);
        }
Exemplo n.º 2
0
        private void UpdateStatus(DashFireSpatial.ISpatialSystem spatial_system)
        {
            List <ISpaceObject> in_objs = spatial_system.GetObjectInCircle(m_CurPos, SearchRadius);

            switch (m_Status)
            {
            case SearchLightStatus.kPatrol:
            case SearchLightStatus.kReturn:
                ISpaceObject target = GetFirstUser(in_objs);
                if (target != null)
                {
                    BeginFollow(target);
                }
                break;

            case SearchLightStatus.kFollow:
                if (!IsContainObj(in_objs, m_CurFollowObj))
                {
                    ISpaceObject new_target = GetFirstUser(in_objs);
                    if (new_target != null)
                    {
                        BeginFollow(new_target);
                    }
                    else
                    {
                        BeginExFollow();
                    }
                }
                break;

            case SearchLightStatus.kExFollow:
                if (TimeUtility.GetServerMilliseconds() > m_ExFollowTime + ExFollowTimeMs)
                {
                    BeginReturn();
                }
                break;
            }
        }