コード例 #1
0
ファイル: SkillArea.cs プロジェクト: GeorgeLiuXin/XinWorld
        public override List <ActorObj> CalculationHit(SkillData skilldata, GTargetInfo targetInfo)
        {
            float rMin = skilldata.MSV_AreaParam1 / 10.0f;
            float rMax = skilldata.MSV_AreaParam2 / 10.0f;
            float dis  = skilldata.MSV_AreaParam3 / 10.0f;

            Vector3 pos = skilldata.IsAreaUseTarPos() ? targetInfo.m_vTarPos : targetInfo.m_vSrcPos;
            Vector3 dir = targetInfo.m_vAimDir;

            SRing sRing = new SRing(pos, rMax, rMin);

            List <ActorObj> pActorList = ActorMgr.GetAllActor();

            if (pActorList.Count <= 0)
            {
                return(null);
            }
            List <ActorObj> list = new List <ActorObj>();

            foreach (ActorObj actor in pActorList)
            {
                if (actor == m_pLocalPlayer)
                {
                    continue;
                }
                ActorObj obj = (ActorObj)actor;
                if (obj.CollisionCom == null)
                {
                    continue;
                }
                for (int i = 0; i < obj.CollisionCom.GetShapeCount(); i++)
                {
                    SShapeData shp = obj.CollisionCom.GetShape(i);
                    if (shp != null)
                    {
                        SSphere sTarSphere = new SSphere(shp.Pos, shp.r);
                        if (GCollider.RingCollideCheck(sRing, sTarSphere, dir))
                        {
                            list.Add(actor);
                            break;
                        }
                    }
                }
            }
            return(list);
        }
コード例 #2
0
ファイル: GCollider.cs プロジェクト: GeorgeLiuXin/XinWorld
        /// <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);
        }