コード例 #1
0
ファイル: SelfDestruct.cs プロジェクト: msukkari/CatDefense
    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
ファイル: DamageAoE.cs プロジェクト: msukkari/CatDefense
    // 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);
            }
        }
    }