Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class EnemyHealth : MonoBehaviour
- {
- public float health = 100f;
- private void Start()
- {
- health = GetComponent<BaseStats>().GetStat(Stat.Health);
- }
- public void TakeDamage(GameObject instigator, float Edamage)
- {
- Debug.Log(gameObject.name + "Took Damage" + Edamage);
- health = Mathf.Max(health - Edamage, 0);
- print(health);
- if (health <= 0)
- {
- GetComponent<Animator>().SetTrigger("Die");
- AwardEXP(instigator);
- }
- }
- private void AwardEXP(GameObject instagator)
- {
- XP exp = instagator.GetComponent<XP>();
- if (exp == null) return;
- instagator.GetComponent<XP>().GainExp(GetComponent<BaseStats>().GetStat(Stat.ExpReward));
- }
- public float GetPercentage()
- {
- return 100 * (health / GetComponent<BaseStats>().GetStat(Stat.Health));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement