public static PopupDamage Create(Vector3 position, int damageAmount, bool isCrit) { Transform dmgPopupTransform = Instantiate(GameAssets.i.pfPopupDamage, position, Quaternion.identity); PopupDamage popupDamage = dmgPopupTransform.GetComponent <PopupDamage>(); popupDamage.Setup(damageAmount, isCrit); return(popupDamage); }
private void Update() { if (Input.GetMouseButtonDown(0)) { bool isCrit = Random.Range(0, 100) < 30; PopupDamage.Create(mousePosition.position, 300, isCrit); } }
// Callback function when player take damage public virtual void OnTakeDamage(IEntityDamageEvent e) { if (isDeath) { return; } var damage = e.GetDamage(ref isCrit); entityStat.TakeDamage(damage, OnDied); // Create pop up damage here PopupDamage.Create(transform.position, (int)damage, isCrit); }
public override void OnTakeDamage(IEntityDamageEvent e) { if (isIntangible) { return; } var damage = e.GetDamage(ref isCrit); entityStat.TakeDamage(damage, OnDied); // Create pop up damage here PopupDamage.Create(transform.position, (int)damage, isCrit); // Add animation hit here animator.SetTrigger("onHit"); }