private void CheckImpact(NpcInfo npc)
 {
     DashFireSpatial.ISpatialSystem spatialSys = npc.SpatialSystem;
     if (null != spatialSys)
     {
         bool existNpcInAttackRange   = false;
         ScriptRuntime.Vector3 srcPos = npc.GetMovementStateInfo().GetPosition3D();
         spatialSys.VisitObjectInCircle(srcPos, npc.GetActualProperty().AttackRange, (float distSqr, ISpaceObject obj) => {
             if (obj.GetObjType() == SpatialObjType.kNPC && (int)obj.GetID() != npc.GetId())
             {
                 NpcInfo npcObj = obj.RealObject as NpcInfo;
                 if (null != npcObj && npcObj.NpcType != (int)NpcTypeEnum.PvpTower)
                 {
                     existNpcInAttackRange = true;
                     return(false);
                 }
             }
             return(true);
         });
         if (existNpcInAttackRange)
         {
             ImpactInfo impactInfo = npc.GetSkillStateInfo().GetImpactInfoById(c_ImpactForTower);
             if (null == impactInfo)
             {
                 ServerNpcImpact(npc, c_ImpactForTower, npc);
             }
         }
     }
 }
        public void Tick(DashFireSpatial.ISpatialSystem spatial_system, long deltaTime)
        {
            UpdateStatus(spatial_system);
            switch (m_Status)
            {
            case SearchLightStatus.kPatrol:
                Vector3 target_pos = GetCurTargetPos();
                CheckPathChange(null, target_pos, PatrolSpeed);
                m_CurPos = Move(m_CurPos, target_pos, PatrolSpeed, deltaTime);
                break;

            case SearchLightStatus.kFollow:
            case SearchLightStatus.kExFollow:
                CheckPathChange(m_CurFollowObj, new Vector3(), FollowSpeed);
                Follow(deltaTime);
                break;

            case SearchLightStatus.kReturn:
                CheckPathChange(null, m_BeginFollowPos, FollowSpeed);
                Back(deltaTime);
                break;
            }
            if (m_IsTriggered)
            {
                CreateNpc();
            }
        }
Beispiel #3
0
        public static CharacterInfo GetInterestestTargetHelper(CharacterInfo srcObj, CharacterRelation relation, AiTargetType type)
        {
            CharacterInfo interestestTarget = null;

            DashFireSpatial.ISpatialSystem spatialSys = srcObj.SpatialSystem;
            if (null != spatialSys)
            {
                ScriptRuntime.Vector3 srcPos = srcObj.GetMovementStateInfo().GetPosition3D();
                float minPowDist             = 999999;
                spatialSys.VisitObjectInCircle(srcPos, srcObj.ViewRange, (float distSqr, ISpaceObject obj) => {
                    GetInterestestTarget(srcObj, relation, type, distSqr, obj, ref minPowDist, ref interestestTarget);
                });
            }
            return(interestestTarget);
        }
Beispiel #4
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);
        }
        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;
            }
        }