void OnTriggerEnter2D(Collider2D otherCollider) { // Is this a shot? ShotScript shot = otherCollider.gameObject.GetComponent <ShotScript>(); if (shot != null && !immuneToShots) { // Avoid friendly fire if (shot.isEnemyShot != isEnemy) { Damage(shot.damage); shot.onImpact(gameObject.transform); } } else { //Is this the activator object? ActivatorScript activator = otherCollider.gameObject.GetComponent <ActivatorScript>(); if (activator != null && !manualActivation && !active) { if (activator.isActivator) { active = true; } } } }
void OnTriggerEnter2D(Collider2D otherCollider) { // Is this a shot? ShotScript shot = otherCollider.gameObject.GetComponent <ShotScript>(); if (shot != null && !immuneToDamage && !dead) { // Avoid friendly fire, apply ranged immunity if ((!(immuneToShots && !shot.isMelee)) && shot.team != team) { Damage(shot.damage); shot.onImpact(gameObject.transform); } } else { //Is this the activator object? ActivatorScript activator = otherCollider.gameObject.GetComponent <ActivatorScript>(); if (activator != null && !manualActivation && !active) { if (activator.isActivator) { active = true; } } } }
void OnTriggerEnter2D(Collider2D otherCollider) { // Is this a shot? ShotScript shot = otherCollider.gameObject.GetComponent <ShotScript>(); if (shot != null) { // Avoid friendly fire if (shot.isEnemyShot != isEnemy) { Damage(shot.damage); shot.onImpact(gameObject.transform); } } // Is this the activator object? ActivatorScript activator = otherCollider.gameObject.GetComponent <ActivatorScript>(); if (activator != null) { if (activator.isActivator && !manualActivation) { active = true; } else if (!manualActivation) // If it has an activator script but not isActivator, it's a deactivator { active = false; } } }