/// <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;
         }
     }
 }
Beispiel #2
0
        private void CollideDamage(GameObject coll)
        {
            // Grab the Character_Manager Component from the colliding object.
            Character_Manager otherChar = coll.GetComponentInParent <Character_Manager> ();

            // IF there is NOT a Character_Manager component.
            if (otherChar == null)
            {
                // We return because we only care about damaging a gameobject that has the Character_Manager Component.
                return;
            }
            // IF the Character_Managers characterEntity is NOT the same as the GameObject we are colliding with.
            if (!otherChar.characterEntity.Equals(coll.gameObject))
            {
                // We leave as we are damaging something that isn't a piece of the Entity.
                // Example would be 2 people clashing swords, Yes both swords are part of the Entity and
                // children of that entity BUT it ISN'T the Entity so we do not care.
                return;
            }

            // Since we have a Character_Manager lets get the Character_Stats script.
            Character_Stats charStats = otherChar.GetComponentInChildren <Character_Stats> ();

            // IF there is not a script to hold the stats of this Character.
            if (charStats == null)
            {
                // Then there is nothing we can damage we are attacking a Character but this character is statless so its like a town friendly NPC.
                return;
            }

            // 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 = coll.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!
                            DamageCharacter(otherChar);
                            // IF the player dies while taking damage.
                            if (charStats.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!.
                        DamageCharacter(otherChar);
                    }
                    // Found 1 so we return.
                    return;
                }
            }
        }
Beispiel #3
0
        private void CollideDamage(GameObject coll)
        {
            // IF we are colliding with another gameobject that does damage.
            if (coll.GetComponent <Damage_OnCollision>() != null)
            {
                return;
            }
            // Grab the Character Component from the colliding object.
            Character otherChar = coll.GetComponentInParent <Character> ();

            // IF there is not a Character component.
            if (otherChar == null)
            {
                // We return because we only care about damaging a gameobject that has the Character Component.
                return;
            }
            // Since we have a character lets get the stats script.
            Character_Stats charStats = otherChar.GetComponentInChildren <Character_Stats> ();

            // IF there is not a script to hold the stats of this Character.
            if (charStats == null)
            {
                // Then there is nothing we can damage we are attacking a Character but this character is statless so its like a town friendly NPC.
                return;
            }
            // 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 if the selection is an ALL choice.
                if (otherChar.characterType == DamageTheseTypes [i] || DamageTheseTypes[i] == CharacterType.All)
                {
                    // Check for Immunity.
                    Immunity_Time _ITS = coll.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!
                            DamageCharacter(otherChar);
                            // IF the player dies while taking damage.
                            if (charStats.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!.
                        DamageCharacter(otherChar);
                    }
                    // Found 1 so we return.
                    return;
                }
            }
        }