public void InflictDamage(float damage) { _audio.clip = (damage < 80) ? _normDmg : _bigDmg; _audio.Play(); eText.gameObject.SetActive(true); BattlePlayer p = GameObject.FindWithTag("Player").GetComponent <BattlePlayer>(); StartCoroutine(p.ItemDelay()); eText.SetText(string.Format("Enemy took {0} damage!", damage)); GameObject dpObject = Instantiate(_dmgPopup, transform.position, Quaternion.identity); DamagePopup dp = dpObject.GetComponent <DamagePopup>(); dp.SetText(damage.ToString()); float shakeMag = (damage / 200f) * 2f; StartCoroutine(Shake(0.15f, shakeMag)); health -= damage; hpBar.SetVal(health); if (health <= 0) { battleSys.state = BattleState.PLAYER_WIN; StartCoroutine(Reward()); } }
public static DamagePopup Create(Vector3 position, string text, Color color) { DamagePopup damagePopup = Create(position, 0, false); damagePopup.SetText(text); damagePopup.SetTextColor(color); return(damagePopup); }
// Update is called once per frame public static void CreatingDamagePopupText(string text, Transform location) { DamagePopup instance = Instantiate(damagePopup); Vector2 positionDamagePopup = Camera.main.WorldToScreenPoint(location.position); positionDamagePopup.x += 25; instance.transform.SetParent(canvasDamage.transform, false); instance.transform.position = positionDamagePopup; instance.SetText(text); }
public void InflictDamage(float dmg) { dmg = isBlocking ? 0 : Mathf.Floor(dmg); if (dmg > 0) { _audio.clip = _hurt; _audio.Play(); } GameObject dpObject = Instantiate(_dmgPopup, transform.position, Quaternion.identity); DamagePopup dp = dpObject.GetComponent <DamagePopup>(); dp.SetText(dmg.ToString()); health -= dmg; hpBar.SetVal(health); SetDeathScreen(); }