Example #1
0
    internal override List <ISkillTarget> GetTargetlistInScope(EffScope scope, int targetMask, ISkillTarget target)
    {
        //if (target == null) return null;

        List <ISkillTarget> targetList  = new List <ISkillTarget>();
        Vector3             scopeCenter = transform.position;

        if (scope.m_centerType == -1)
        {
            scopeCenter = transform.position;
        }

        if (scope.m_centerType == -2)
        {
            scopeCenter = center;
        }

        Collider[] colliders = Physics.OverlapSphere(scopeCenter, scope.m_radius + radius, 0);
        // Edit by zhouxun
        // we need check the parent gameobject also.

        foreach (Collider c in colliders)
        {
            if (c.isTrigger || c.gameObject == this.gameObject)
            {
                continue;
            }

            if (GameConfig.IsMultiMode)
            {
                SkillRunner obj = VCUtils.GetComponentOrOnParent <SkillRunner>(c.gameObject);
                if (null == obj)
                {
                    continue;
                }

                int targetHarm = AiUtil.GetHarm(obj.gameObject);
                if (AiHarmData.GetHarmValue(harm, targetHarm) == 0)
                {
                    continue;
                }
            }
            else
            {
                int targetHarm = AiUtil.GetHarm(c.gameObject);
                if (AiHarmData.GetHarmValue(harm, targetHarm) == 0)
                {
                    continue;
                }
            }

            float cosAngle = AiMath.Dot(transform, c.transform);
            float angle    = Mathf.Acos(cosAngle) * Mathf.Rad2Deg;

            if (angle > scope.m_degEnd || angle < scope.m_degStart)
            {
                continue;
            }

            SkillRunner runner = VCUtils.GetComponentOrOnParent <SkillRunner>(c.gameObject);
            if (runner != null && (runner != this) && !targetList.Contains(runner))
            {
                targetList.Add(runner);
            }
        }
        return(targetList);
    }
Example #2
0
    internal override List <ISkillTarget> GetTargetlistInScope(EffScope scope, int targetMask, ISkillTarget target)
    {
        List <ISkillTarget> targetList = new List <ISkillTarget>();

        if (emitRunner == null)
        {
            return(targetList);
        }

        Collider[]       cs         = Physics.OverlapSphere(transform.position, scope.m_radius);
        List <Transform> transforms = new List <Transform>();

        foreach (Collider item in cs)
        {
            if (item.isTrigger)
            {
                continue;
            }

            if (!transforms.Contains(item.transform) &&
                !item.gameObject.Equals(this.gameObject) &&
                !item.gameObject.Equals(emitRunner.gameObject))
            {
                transforms.Add(item.transform);
            }

            Transform           root     = item.transform;
            CreationSkillRunner creation = VCUtils.GetComponentOrOnParent <CreationSkillRunner>(root.gameObject);
            if (creation != null)
            {
                if (!transforms.Contains(creation.transform))
                {
                    transforms.Add(creation.transform);
                }
            }
        }

        foreach (Transform tr in transforms)
        {
            if (tr == null || emitTransform == null)
            {
                continue;
            }

            float cosAngle = AiMath.Dot(emitTransform, tr);
            float angle    = Mathf.Acos(cosAngle) * Mathf.Rad2Deg;

            int emitHarm = AiUtil.GetHarm(emitRunner.gameObject);

            if (GameConfig.IsMultiMode)
            {
                SkillRunner obj = tr.GetComponent <SkillRunner>();
                if (null == obj)
                {
                    continue;
                }

                int targetHarm = AiUtil.GetHarm(obj.gameObject);

                if (AiHarmData.GetHarmValue(emitHarm, targetHarm) == 0)
                {
                    continue;
                }
            }
            else
            {
                int targetHarm = AiUtil.GetHarm(tr.gameObject);

                if (AiHarmData.GetHarmValue(emitHarm, targetHarm) == 0)
                {
                    continue;
                }
            }

            Ray   rayStart = new Ray(transform.position, tr.position - transform.position);
            float distance = Vector3.Distance(transform.position, tr.position);

            if (Physics.Raycast(rayStart, distance,
                                AiUtil.groundedLayer | AiUtil.obstructLayer))
            {
                continue;
            }

            if (angle > scope.m_degEnd || angle < scope.m_degStart)
            {
                continue;
            }

            SkillRunner runner = tr.GetComponent <SkillRunner>();

            if (runner == null)
            {
                runner = VCUtils.GetComponentOrOnParent <SkillRunner>(tr.gameObject);
            }

            if (runner != null && !targetList.Contains(runner))
            {
                targetList.Add(runner);
            }
        }

        return(targetList);
    }