public void TakeDamage(int amount, Vector3 hitPoint, string sourceDmg) { // If the enemy is dead... if (isDead) { // ... no need to take damage so exit the function. return; } //play hit sound audio.PlayOneShot(hitSound); // Reduce the current health by the amount of damage sustained. if (this.faction == Faction.Neutral) { currentHealth -= amount; } if (this.faction == Faction.Ally) { currentHealth -= dmgModAlly.modDmg(amount); } if (this.faction == Faction.Enemy) { currentHealth -= dmgModEnemy.modDmg(amount); } // If the current health is less than or equal to zero... if (currentHealth <= 0) { // ... the enemy is dead. Death(); //get player, extract frenzy suit, tell frenzy we got a kill if (sourceDmg.Equals("Player")) { tmpPlayerObj = GameObject.FindWithTag("Player"); playFz = tmpPlayerObj.GetComponent <Frenzy_suit>(); playFz.gotKill(); } } healthBarLength = 100 * (currentHealth / (float)startingHealth); }
public void TakeDamage (int amount, Vector3 hitPoint, string sourceDmg) { // If the enemy is dead... if (isDead) { // ... no need to take damage so exit the function. return; } //play hit sound audio.PlayOneShot(hitSound); // Reduce the current health by the amount of damage sustained. if (this.faction == Faction.Neutral) { currentHealth -= amount; } if (this.faction == Faction.Ally) { currentHealth -= dmgModAlly.modDmg(amount); } if (this.faction == Faction.Enemy) { currentHealth -= dmgModEnemy.modDmg(amount); } // If the current health is less than or equal to zero... if(currentHealth <= 0) { // ... the enemy is dead. Death (); //get player, extract frenzy suit, tell frenzy we got a kill if (sourceDmg.Equals("Player")){ tmpPlayerObj = GameObject.FindWithTag("Player"); playFz = tmpPlayerObj.GetComponent<Frenzy_suit>(); playFz.gotKill(); } } healthBarLength = 100 * (currentHealth / (float)startingHealth); }