示例#1
0
    private void TriggerHitFX(PlayerBaseAttackLogic attackLogic, Vector3 hitPoint, EAttackResult attackResult, EHitNotificationType hitNotificationType)
    {
        Profiler.BeginSample("PlayerHealthComponent.TriggerHitFX");

        m_HitFXTypeList.Clear();
        attackLogic.GetHitFX(attackResult, hitNotificationType, ref m_HitFXTypeList);
        if (m_HitFXTypeList.Count > 0)
        {
            bool       flipHitFX;
            Collider2D lastHitCollider = attackLogic.GetLastHitCollider();
            if (lastHitCollider != null)
            {
                Transform hitOwner = lastHitCollider.transform.root;
                flipHitFX = hitOwner.position.x < transform.position.x;
            }
            else
            {
                flipHitFX = attackLogic.GetOwner().transform.position.x < transform.position.x;
            }

            int playerIndex = m_InfoComponent.GetPlayerIndex();
            for (int i = 0; i < m_HitFXTypeList.Count; i++)
            {
                m_FXManager.SpawnHitFX(playerIndex, m_HitFXTypeList[i], hitPoint, Quaternion.identity, flipHitFX);
            }
        }

        Profiler.EndSample();
    }
示例#2
0
    private bool IsGrabAttacker(PlayerBaseAttackLogic grabLogic)
    {
        bool       isGrabAttacker             = false;
        GameObject grabInstigator             = grabLogic.GetOwner();
        Animator   grabInstigatorAnim         = grabLogic.GetAnimator();
        float      currentGrabInstigatorFrame = Utils.GetCurrentAnimFrame(grabInstigatorAnim);
        float      currentGrabOwnerFrame      = Utils.GetCurrentAnimFrame(m_Anim);

        // If grab instigator has been triggered at exact same frame than owner
        if (currentGrabInstigatorFrame == currentGrabOwnerFrame)
        {
            isGrabAttacker = grabInstigator.CompareTag(Player.Player1);
            ChronicleManager.AddChronicle(gameObject, EChronicleCategory.Health, "Is " + grabInstigator.tag + " GrabAttacker | Grab attack has been triggered at same frame on both players. Player1 defined as attacker by default");
        }
        else
        {
            isGrabAttacker = currentGrabInstigatorFrame > currentGrabOwnerFrame;
            ChronicleManager.AddChronicle(gameObject, EChronicleCategory.Health, "Is " + grabInstigator.tag + " GrabAttacker | " + ((isGrabAttacker) ? grabInstigator.tag : gameObject.tag) + " is grab attacker");
        }
        return(isGrabAttacker);
    }
示例#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();
    }