예제 #1
0
        public void OnHurt(Damager p_damager, Damageable p_damageable)
        {
            if (!PlayerInput.Instance.HaveControl)
            {
                return;
            }

            UpdateFacing(p_damageable.GetDamageDirection().x > 0.0f);
            p_damageable.EnableInvulnerability();

            m_animator.SetTrigger(m_hashHurtPara);

            if (p_damageable.CurrentHealth > 0 && p_damager.ForceRespawn)
            {
                m_animator.SetTrigger(m_hashForcedRespawn);
            }

            m_animator.SetBool(m_hashGroundedPara, false);
            // Play Audio Hurt

            if (p_damager.ForceRespawn && p_damageable.CurrentHealth > 0)
            {
                StartCoroutine(DieRespawnCoroutine(false, true));
            }
        }
예제 #2
0
 private void CheckDeath(Damager p_damager)
 {
     if (m_currentHealth <= 0)
     {
         OnDie?.Invoke(p_damager, this);
         m_resetHealthOnSceneReload = true;
         EnableInvulnerability();
         if (DisableOnDeath)
         {
             gameObject.SetActive(false);
         }
     }
 }
예제 #3
0
        public void TakeDamage(Damager p_damager, bool p_ignoreInvulnerability = false)
        {
            if (m_invulnerable && !p_ignoreInvulnerability || m_currentHealth <= 0)
            {
                return;
            }

            if (!m_invulnerable)
            {
                m_currentHealth -= p_damager.DamageValue;
                OnHealthSet?.Invoke(this);
            }

            m_damageDirection = transform.position + (Vector3)CenterOffset - p_damager.transform.position;

            OnTakeDamage?.Invoke(p_damager, this);

            CheckDeath(p_damager);
        }