Example #1
0
    public void DoHit()
    {
        if (DoDebug)
        {
            Debug.Log("Do hit");
        }
        lastPlayedAnimation++;
        if (animationHashes != null && lastPlayedAnimation >= animationHashes.Length)
        {
            lastPlayedAnimation = 0;
        }

        if (anim != null && animationHashes != null && animationHashes.Length > 0)
        {
            anim.PlayIfHas(animationHashes[lastPlayedAnimation]);
        }

        if (ShakeOnDamage && ShakeObj)
        {
            ShakeObj.ShakeAndBackTo(Vector3.one);
        }
        if (ShowDamageNumber && lastHitDamage > 0)
        {
            DamageNumber.SpawnDamageNumber(lastHitDamage, transform.Above(damageNumberSpot), false);
        }
        OnHit.Invoke();
    }