private void OnTriggerEnter2D(Collider2D collision) { if (collision.transform.root.GetComponent <EnemyObject>() && collision.transform.root.GetComponent <InfestDot>() == null) { InfestDot dotApp = collision.transform.root.gameObject.AddComponent <InfestDot>(); dotApp.DamagePerSecond = 12; dotApp.Duration = 8; dotApp.ExpireRadius = 2; } Destroy(gameObject); }
private void OnDestroy() { if (Duration > 0) { Collider2D[] area = Physics2D.OverlapCircleAll(transform.position, ExpireRadius); Ability.DebugDrawRadius(transform.position, ExpireRadius, Color.green, 1f); if (!PlagueDoctor.isActive) { foreach (Collider2D coll in area) { EnemyObject obj = coll.transform.root.GetComponent <EnemyObject>(); if (obj != null && obj.transform.root.GetComponent <InfestDot>() == null) { InfestDot refDot = obj.transform.root.gameObject.AddComponent <InfestDot>(); refDot.Duration = Duration; refDot.DamagePerSecond = DamagePerSecond; refDot.ExpireRadius = ExpireRadius; } } } else { foreach (Collider2D coll in area) { EnemyObject obj = coll.transform.root.GetComponent <EnemyObject>(); if (obj != null && obj.transform.root.GetComponent <InfestDot>() == null) { InfestDot refDot = obj.transform.root.gameObject.AddComponent <InfestDot>(); refDot.Duration = originalDuration; refDot.DamagePerSecond = DamagePerSecond * 1.1f; refDot.ExpireRadius = ExpireRadius; } } } } }