Exemplo n.º 1
0
    public virtual bool EvaluateConditions(PlayerBaseAttackLogic currentAttackLogic)
    {
        bool conditionIsValid = true;

        PlayerAttack attack = GetAttack();

        if (m_MovementComponent != null)
        {
            conditionIsValid &= (attack.m_NeededStanceList.Contains(m_MovementComponent.GetCurrentStance()));
        }

        if (attack.m_HasCondition)
        {
            if (attack.m_SuperGaugeAmountNeeded > 0f)
            {
                PlayerSuperGaugeSubComponent superGaugeSC = m_AttackComponent.GetSuperGaugeSubComponent();
                if (superGaugeSC != null)
                {
                    conditionIsValid &= superGaugeSC.GetCurrentGaugeValue() >= attack.m_SuperGaugeAmountNeeded;
                }
            }

            if (attack.m_HasAttackRequirement)
            {
                conditionIsValid &= (currentAttackLogic != null && currentAttackLogic.GetAttack().m_AnimationAttackName == attack.m_AttackRequired);
            }

            if (attack.m_HasMovementRequirement)
            {
                conditionIsValid &= attack.m_MovementRequiredList.Contains(m_MovementComponent.GetMovingDirection());
            }
        }

        return(conditionIsValid);
    }
Exemplo n.º 2
0
    private bool CanReceiveHit(PlayerBaseAttackLogic playerBaseAttackLogic)
    {
        if (IsDead())
        {
            return(false);
        }

        if (m_StunInfoSC.IsStunned() && m_MovementComponent.IsJumping())
        {
            if (playerBaseAttackLogic.GetAttack().m_CanJuggleLaunch ||
                (m_StunInfoSC.IsInJuggleState() && playerBaseAttackLogic.GetAttack().m_CanJuggleHit))
            {
                return(true);
            }

            return(false);
        }

        return(true);
    }
Exemplo n.º 3
0
    private void TriggerEffects(PlayerBaseAttackLogic attackLogic, uint damage, EAttackResult attackResult, EHitNotificationType hitNotificationType)
    {
        Profiler.BeginSample("PlayerHealthComponent.TriggerEffects");
        PlayerAttack attack = attackLogic.GetAttack();
        bool         isDead = IsDead();

        // No stun neither pushback when an attack is parried
        if (attackResult != EAttackResult.Parried)
        {
            if (attackLogic.CanStunOnDamage())
            {
                m_StunInfoSC.StartStun(attackLogic, attackResult);
            }

            // If stun duration is not anim driven, we can set the duration and apply a pushback
            if (!m_StunInfoSC.IsStunDurationAnimDriven())
            {
                if (attackLogic.CanStunOnDamage())
                {
                    float stunDuration = attackLogic.GetStunDuration(attackResult);
                    if (stunDuration > 0f)
                    {
                        m_StunInfoSC.SetStunDuration(attackLogic, stunDuration);
                    }
                }

                if (attackLogic.CanPushBack())
                {
                    float pushBackForce = attackLogic.GetPushBackForce(attackResult);
                    if (pushBackForce > 0.0f && m_MovementComponent)
                    {
                        if (isDead)
                        {
                            pushBackForce *= AttackConfig.Instance.m_OnDeathPushbackMultiplier;
                        }
                        m_MovementComponent.PushBack(pushBackForce);
                    }
                }
            }
        }

        PlayerSuperGaugeSubComponent superGaugeSC = m_AttackComponent.GetSuperGaugeSubComponent();

        if (superGaugeSC != null)
        {
            superGaugeSC.IncreaseGaugeValue(AttackConfig.Instance.m_DefenderSuperGaugeBonus);
        }

        if (attackResult == EAttackResult.Hit)
        {
            m_StunInfoSC.IncreaseGaugeValue(attackLogic.GetStunGaugeHitAmount());
        }

        TimeScaleParams timeScaleParams = null;

        if (isDead)
        {
            timeScaleParams = AttackConfig.Instance.m_OnDeathTimeScaleParams;
        }
        else if (attack.m_UseTimeScaleEffect)
        {
            timeScaleParams = attack.m_TimeScaleParams;
        }

        if (timeScaleParams != null)
        {
            ChronicleManager.AddChronicle(gameObject, EChronicleCategory.Health, "StartTimeScale - Amount: " + timeScaleParams.m_TimeScaleAmount + " Duration: " + timeScaleParams.m_TimeScaleDuration);
            m_TimeScaleManager.StartTimeScale(timeScaleParams);
            if (timeScaleParams.m_TimeScaleAmount == 0f)
            {
                TriggerHitStopShake(timeScaleParams.m_TimeScaleDuration);
            }
        }

        if (!attackLogic.GetLastHitPoint(out Vector3 hitPoint))
        {
            hitPoint = attackLogic.GetOwner().transform.position;
        }

        if (attackResult != EAttackResult.Blocked)
        {
            if (attack.m_UseCameraShakeEffect || isDead)
            {
                Vector3           hitDirection        = (transform.position - attackLogic.GetOwner().transform.position).normalized;
                CameraShakeParams camShakeParamsToUse = isDead ? AttackConfig.Instance.m_OnDeathCamShakeParams : attack.m_CameraShakeParams;
                CameraShakeManager.GenerateImpulseAt(camShakeParamsToUse, hitPoint, hitDirection);
            }
        }

        TriggerHitFX(attackLogic, hitPoint, attackResult, hitNotificationType);
        PlayHitSFX(attackLogic, attackResult, hitNotificationType);

        Profiler.EndSample();
    }
Exemplo n.º 4
0
    void OnHit(BaseEventParameters baseParams)
    {
        Profiler.BeginSample("PlayerHealthComponent.OnHit");

        HitEventParameters    hitParams      = (HitEventParameters)baseParams;
        PlayerBaseAttackLogic hitAttackLogic = hitParams.m_AttackLogic;

        if (CanReceiveHit(hitAttackLogic))
        {
#if UNITY_EDITOR || DEBUG_DISPLAY
            if (m_DEBUG_BreakOnHit)
            {
                Debug.Break();
            }
#endif

            GetHitInfo(hitAttackLogic, out uint hitDamage, out EAttackResult attackResult, out EHitNotificationType hitNotificationType);
            ChronicleManager.AddChronicle(gameObject, EChronicleCategory.Health, "On hit by : " + hitAttackLogic.GetAttack().m_Name + ", damage : " + hitDamage + ", result : " + attackResult + ", hitNotif : " + hitNotificationType);

            ApplyDamage(hitAttackLogic, hitDamage, attackResult, hitNotificationType);
        }

        Profiler.EndSample();
    }
Exemplo n.º 5
0
    void OnGrabbed(BaseEventParameters baseParams)
    {
        if (IsDead())
        {
            return;
        }

#if UNITY_EDITOR || DEBUG_DISPLAY
        if (m_DEBUG_BreakOnGrabbed)
        {
            Debug.Break();
        }
#endif
        GrabbedEventParameters grabbedParams   = (GrabbedEventParameters)baseParams;
        PlayerBaseAttackLogic  grabAttackLogic = grabbedParams.m_AttackLogic;

        ChronicleManager.AddChronicle(gameObject, EChronicleCategory.Health, "On grabbed by : " + grabAttackLogic.GetAttack().m_Name);
        m_StunInfoSC.StartStun(grabAttackLogic, EAttackResult.Hit);
        PlayHitAnimation(grabAttackLogic);
        m_AudioManager.PlayHitSFX(m_InfoComponent.GetPlayerIndex(), EAttackSFXType.Hit_Throw, false);
    }