/// <summary> /// Loop and see what we can damage based on CharacterType. /// </summary> public void DamageCharacterTypeLoop(Transform original, Character_Manager otherChar, CharacterType[] damageTheseTypes, float damage, float joltAmount) { // Loop through all the Character Types this GameObject collides with to see if we are allowed to damage them. for (int i = 0; i < damageTheseTypes.Length; i++) { // IF the colliding objects characterType matches one of the types that can take damage OR the selection // is an ALL choice. if (otherChar.characterType == damageTheseTypes [i] || damageTheseTypes[i] == CharacterType.All) { // Check for Immunity. Immunity_Time _ITS = otherChar.characterEntity.GetComponentInParent <Immunity_Time> (); // IF the colliding object has the Immunity_Time script, // ELSE just damage the target. if (_ITS != null) { // IF we are Vulnerable. if (_ITS.GetVulnerability()) { // We passed the prerequisites to do damage... Yay! otherChar.TakeDamage(damage, original, joltAmount); // IF the Character dies while taking damage. if (otherChar.GetComponentInChildren <Character_Stats> ().CurrentHealth <= 0f) { // We just leave as there is no need to alter the Change Vulnerability. return; } // Since there is a Immunity_Time script on the colliding object we need to make sure we set the // vulnerability of the colliding gameobject to false; _ITS.ChangeVulnerability(false); } } else { // We passed the prerequisites to do damage... Yay!. otherChar.TakeDamage(damage, original, joltAmount); } // Found 1 so we return. return; } } }