示例#1
0
    public override void Execute(HealthComponent t)
    {
        self_destruct = true;
        Collider2D[] hit = Physics2D.OverlapCircleAll((Vector2)this.transform.position, range);

        foreach (Collider2D c in hit)
        {
            HealthComponent h = c.gameObject.GetComponent <HealthComponent> ();
            if (h != null && UnitAIBehaviour.ObjectInMask(h.gameObject, layerTarget))
            {
                h.Damage(damage);
            }
        }

        HealthComponent self = this.GetComponent <HealthComponent> ();

        if (self != null)
        {
            self.Kill();
        }
        else
        {
            Destroy(this.gameObject);
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        Collider2D[] hit = Physics2D.OverlapCircleAll((Vector2)this.transform.position, range);

        foreach (Collider2D c in hit)
        {
            HealthComponent h = c.gameObject.GetComponent <HealthComponent>();
            if (h != null && UnitAIBehaviour.ObjectInMask(h.gameObject, targets))
            {
                h.Damage(damage * Time.deltaTime);
            }
        }
    }