Exemple #1
0
        public void DamageReceiver(Unit_Status_DamageData damage)
        {
            Debug.Log($"'{name}' received '{damage.damagePoint}' damage");

            var staminaCostToParry = damage.damagePoint * 0.5f;
            var parryValue         = CombatHandler.ParryHandler.ParryTiming > damage.parryTiming &&
                                     CombatHandler.ParryHandler.ParryTiming <damage.damageTiming &&
                                                                             CombatHandler.Unit.Status.ST.CurrentStamina> staminaCostToParry;

            if (parryValue == true)
            {
                Debug.Log("Parry success");
                CombatHandler.Unit.Status.ST.Parry((int)staminaCostToParry);
                CombatHandler.UnitAnimator.Play("Sword1h_Parry_T");
            }
            else
            {
                Debug.Log("Parry failed");
                OnReceivedDamageEvent.Invoke(damage);
                OnPostReceivedDamageEvent.Invoke();

                if (CombatHandler.Unit.Status.IsDead == false)
                {
                    PlayHitAnimation(damage.hitsAnimation);
                }
            }

            CombatHandler.Unit.RotationHandler.RotateToward(damage.damageSenderPosition, 20.0f);
        }
Exemple #2
0
        public void Damage(Unit_Status_DamageData damageData)
        {
            if (CurrentHealth == 0)
            {
                Debug.Log($"'{information.name}' is already dead !!");
                return;
            }

            CurrentHealth = Mathf.Max(0, CurrentHealth - damageData.damagePoint);

            Debug.Log($"Damage Received : {damageData.damagePoint} | Remaining HP : {CurrentHealth}");

            if (CurrentHealth == 0)
            {
                Debug.Log("Dead!!");
            }

            OnCurrentHealthUpdated.Invoke(CurrentHealthRate);
        }