Ejemplo n.º 1
0
    static DamageInfo[] CheckTag(Collider[] cols, UnitInfo causer, bool affectToCauser, float damage, Vector3 damagePoint, params string[] tags)
    {
        List <DamageInfo> damageInfoList = new List <DamageInfo>();

        if (cols != null && cols.Length > 0)
        {
            foreach (Collider tr in cols)
            {
                UnitInfo target = tr.attachedRigidbody.GetComponent <UnitInfo>();
                if (target == null)
                {
                    continue;
                }
                if (!affectToCauser && target == causer)
                {
                    continue;
                }
                foreach (string tag in tags)
                {
                    if (tr.tag == tag)
                    {
                        Vector3 point = tr.ClosestPointOnBounds(damagePoint);
                        if (causer.GiveDamage(target, damage, point))
                        {
                            DamageInfo dInfo;
                            dInfo.hitPoint = point;
                            dInfo.hitUnit  = target;
                            damageInfoList.Add(dInfo);
                        }
                    }
                }
            }
        }
        return(damageInfoList.ToArray());
    }