示例#1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        foreach (GameObject go in alreadyHit)
        {
            if (go == other.gameObject)
            {
                return;
            }
        }

        bool isTarget = false;

        foreach (string tag in other.gameObject.tags())
        {
            foreach (string target in targetTags)
            {
                if (tag.Equals(target))
                {
                    isTarget = true;
                }
            }
        }

        if (isTarget)
        {
            Body   body   = other.gameObject.GetComponent <Body>();
            Attack attack = other.gameObject.GetComponent <Attack>();
            if (body != null)
            {
                foreach (Affecter eff in effects)
                {
                    body.AddAffecter(eff.GetAffecterClone(eff));
                }
                alreadyHit.Add(other.gameObject);
            }
            else if (attack != null)
            {
                attack.genitor.SetCurrAct(new Recovery("Recovery", 15, attack.genitor));
                Destroy(attack.gameObject);
            }
        }
    }