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);
    }
Exemplo n.º 2
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            bool isCrit = Random.Range(0, 100) < 30;

            PopupDamage.Create(mousePosition.position, 300, isCrit);
        }
    }
Exemplo n.º 3
0
    // 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");
    }