コード例 #1
0
    void OnTriggerExit(Collider other)
    {
        GameObject target;
        Retarget   retarget = other.GetComponent <Retarget>();

        if (retarget != null)
        {
            target = retarget.target;
        }
        else
        {
            target = other.gameObject;
        }

        this.targeting.Remove(target);
    }
コード例 #2
0
    void OnTriggerEnter(Collider other)
    {
        GameObject target;
        Retarget   retarget = other.GetComponent <Retarget>();

        if (retarget != null)
        {
            target = retarget.target;
        }
        else
        {
            target = other.gameObject;
        }

        targeting.Add(target);
        GameObject toAttack = targeting.findClosestUnit(this.transform.position);

        baseScript.TargetEnemy(toAttack);
    }
コード例 #3
0
    private void HitTarget()
    {
        if (!this.isActiveAndEnabled)
        {
            return;
        }

        if (Target != null)
        {
            Retarget   retarget     = Target.GetComponent <Retarget>();
            GameObject actualTarget = (retarget == null) ? Target : retarget.damageable;

            IDamageable targetScript = actualTarget.GetComponent <IDamageable>();
            if (targetScript == null)
            {
                targetScript = actualTarget.GetComponentInParent <IDamageable>();
            }

            targetScript.receiveDamage(this.Damage);
        }
        Destroy(this.gameObject);
    }