// Update is called once per frame void Update() { Collider2D[] colliders = Physics2D.OverlapBoxAll(new Vector2(gameObject.transform.position.x + collider.offset.x, gameObject.transform.position.y + collider.offset.y), new Vector2(collider.bounds.size.x * 2, collider.bounds.size.y * 2), 0, AffectedLayer); for (int i = 0; i < colliders.Length; i++) { AbstractAfectable af = colliders[i].GetComponent <AbstractAfectable>(); if (af != null) { af.OnPoison(); } } }
// Update is called once per frame void FixedUpdate() { Collider2D[] colliders = Physics2D.OverlapBoxAll(new Vector2(gameObject.transform.position.x + collider.offset.x, gameObject.transform.position.y + collider.offset.y), new Vector2(collider.bounds.size.x / 2, collider.bounds.size.y / 2), int.MaxValue); for (int i = 0; i < colliders.Length; i++) { GameObject collider = colliders[i].gameObject; AbstractAfectable af = (AbstractAfectable)colliders[i].GetComponent(typeof(AbstractAfectable)); if (af != null) { af.OnExplode(); } HealthPointsScript hps = (colliders[i].GetComponent(typeof(HealthPointsScript)) as HealthPointsScript); if (hps != null) { hps.GetHit(150); } } }