/// <summary> /// 环形判定 /// 简单进行半径与敌人比对即可 /// </summary> /// <returns></returns> public static bool RingCollideCheck(SRing sRing, SSphere pTarget, Vector3 vDir) { Vector2 sRingPos = new Vector2(sRing.pos.x, sRing.pos.z); Vector2 sTargetPos = new Vector2(pTarget.pos.x, pTarget.pos.z); vDir.Normalize(); //Vector2 vAimDir = new Vector2(vDir.x, vDir.z); //Vector2 vOpAimDir = new Vector2(-vDir.z, vDir.x); Vector2 vOffest = sTargetPos - sRingPos; if (vOffest.sqrMagnitude >= (sRing.r_max + pTarget.r) * (sRing.r_max + pTarget.r)) { return(false); } if (vOffest.sqrMagnitude <= (sRing.r_min - pTarget.r) * (sRing.r_min - pTarget.r)) { return(false); } return(true); }
public override List <Avatar> GetTargetList(DRSkillData pSkillData, Avatar pCaster, GTargetInfo sTarInfo, HashSet <int> vExcludeList) { List <Avatar> vTargetList = new List <Avatar>(); if (pSkillData == null || !pCaster) { return(vTargetList); } Avatar pTarget = GameEntry.Entity.GetGameEntity(sTarInfo.m_nTargetID) as Avatar; if (!pTarget) { pTarget = pCaster; } int cnt = GetTargetCount(pSkillData /*, vExcludeList*/); int filter = pSkillData.MSV_AreaFilter; float rMin = pSkillData.MSV_AreaParam1; float rMax = pSkillData.MSV_AreaParam2; float dis = pSkillData.MSV_AreaParam3; List <UnityGameFramework.Runtime.Entity> pList = new List <UnityGameFramework.Runtime.Entity>(); GameEntry.Entity.GetAllLoadedEntities(pList); if (pList == null || pList.Count == 0) { return(vTargetList); } Vector3 pos = /*pSkillData.IsAreaUseTarPos() ? sTarInfo.m_vTarPos :*/ sTarInfo.m_vSrcPos; Vector3 dir = sTarInfo.m_vAimDir; SRing sRing = new SRing(pos, rMax, rMin); foreach (var item in pList) { Avatar actor = item.Logic as Avatar; if (actor == null || actor == pCaster) { continue; } SSphere sTarSphere = new SSphere(actor.GetPos(), actor.ModelRadius); if (GCollider.RingCollideCheck(sRing, sTarSphere, dir)) { TryAddTarget(pSkillData, pCaster, actor, vExcludeList); if (vTargetList.Count >= cnt) { if (filter > 0) { UpdateAreaFilter(filter, cnt, vTargetList); } else { return(vTargetList); } } break; } } return(vTargetList); }