void OnTriggerStay2D(Collider2D other) { EnemyDamageCollider collider = other.GetComponent <EnemyDamageCollider>(); if (collider != null) { damage(collider.damage, collider.type, collider.knockback); } }
void OnTriggerEnter2D(Collider2D other) { EnemyDamageCollider collider = other.GetComponent <EnemyDamageCollider>(); if (collider != null) { damage(collider.damage, collider.type, collider.knockback); } // TODO: For other powerups, you will check their AbstractPowerup Class // and find out what effects it has from there. // Eg; Check effect state (health, attack, defence, etc) and level (1, 10, 100) and raise the player's // state by that level. If you want to lower, then either create a boolean "raise" or a "PowerDown" object. if (other.tag == "PowerUp") { string itemName = other.gameObject.name.Replace("(Clone)", ""); Debug.Log("Found Item: " + itemName); if (itemName == "ChickenTendies") { Debug.Log(other); playerHealth += 20; base.playSound(AbstractClass.sfx.omnom, false); Destroy(other.gameObject); } else if (itemName == "ChargePart") { Debug.Log(other); _chargeBar.chargePercentage += 20; base.playSound(AbstractClass.sfx.omnom, false); Destroy(other.gameObject); } else if (itemName == "ChargeFull") { Debug.Log(other); _chargeBar.chargePercentage += 100; base.playSound(AbstractClass.sfx.omnom, false); Destroy(other.gameObject); } } }