示例#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
    public override bool GetHitSFX(EAttackResult attackResult, EHitNotificationType hitNotifType, ref EAttackSFXType hitSFXType)
    {
        bool baseResult = base.GetHitSFX(attackResult, hitNotifType, ref hitSFXType);

        if (!baseResult)
        {
            switch (attackResult)
            {
            case EAttackResult.Hit:
                switch (m_Config.m_HitStrength)
                {
                case EHitStrength.Weak:
                    hitSFXType = (hitNotifType == EHitNotificationType.Counter) ? EAttackSFXType.Counter_Hit_Light : EAttackSFXType.Hit_Light;
                    break;

                case EHitStrength.Strong:
                    hitSFXType = (hitNotifType == EHitNotificationType.Counter) ? EAttackSFXType.Counter_Hit_Heavy : EAttackSFXType.Hit_Heavy;
                    break;
                }
                return(true);
            }
        }

        return(baseResult);
    }
示例#3
0
    public virtual void GetHitFX(EAttackResult attackResult, EHitNotificationType hitNotifType, ref List <EHitFXType> hitFXList)
    {
        switch (attackResult)
        {
        case EAttackResult.Hit:
            if (hitNotifType == EHitNotificationType.Counter)
            {
                hitFXList.Add(EHitFXType.Counter);
                return;
            }

            if (m_Attack.m_AnimationAttackName >= EAnimationAttackName.Special01)
            {
                hitFXList.Add(EHitFXType.SpecialHit);
                return;
            }
            break;

        case EAttackResult.Blocked:
            hitFXList.Add(EHitFXType.Block);
            return;

        case EAttackResult.Parried:
            hitFXList.Add(EHitFXType.Parry);
            return;
        }
    }
示例#4
0
    private void OnDamageTaken(PlayerBaseAttackLogic attackLogic, uint damage, EAttackResult attackResult, EHitNotificationType hitNotificationType)
    {
        Profiler.BeginSample("PlayerHealthComponent.OnDamageTaken");

#if DEBUG_DISPLAY || UNITY_EDITOR
        KakutoDebug.Log("Player : " + gameObject.name + " HP : " + m_HP + " damage taken : " + damage + " attack " + attackResult.ToString());
#endif
        ChronicleManager.AddChronicle(gameObject, EChronicleCategory.Health, "On damage taken : " + damage + ", current HP : " + m_HP);

        DamageTakenEventParameters damageTakenInfo = new DamageTakenEventParameters(gameObject, attackLogic, attackResult, m_StunInfoSC.IsHitStunned(), damage, (float)m_HP / (float)m_HealthConfig.m_MaxHP, hitNotificationType);
        Utils.GetPlayerEventManager(gameObject).TriggerEvent(EPlayerEvent.DamageTaken, damageTakenInfo);

        if (!IsDead() && attackLogic.CanPlayDamageTakenAnim())
        {
            PlayDamageTakenAnim(attackLogic, attackResult);
        }

        TriggerEffects(attackLogic, damage, attackResult, hitNotificationType);

        if (damage > 0 && m_InfoComponent.GetPlayerSettings().m_DisplayDamageTaken)
        {
            DisplayDamageTakenUI(damage);
        }

        if (IsDead())
        {
            OnDeath(attackLogic);
        }
        Profiler.EndSample();
    }
示例#5
0
    public virtual bool GetHitSFX(EAttackResult attackResult, EHitNotificationType hitNotifType, ref EAttackSFXType hitSFXType)
    {
        switch (attackResult)
        {
        case EAttackResult.Hit:
            if (IsHitKO())
            {
                hitSFXType = EAttackSFXType.Hit_KO;
                return(true);
            }

            if (m_Attack.m_AnimationAttackName >= EAnimationAttackName.Special01)
            {
                hitSFXType = EAttackSFXType.Hit_Special;
                return(true);
            }
            break;

        case EAttackResult.Blocked:
            hitSFXType = EAttackSFXType.Blocked_Hit;
            return(true);

        case EAttackResult.Parried:
            hitSFXType = EAttackSFXType.Parry_Hit;
            return(true);
        }

        return(false);
    }
示例#6
0
 public override void GetHitFX(EAttackResult attackResult, EHitNotificationType hitNotifType, ref List <EHitFXType> hitFXList)
 {
     base.GetHitFX(attackResult, hitNotifType, ref hitFXList);
     if (hitFXList.Count == 0)
     {
         hitFXList.Add(EHitFXType.HeavyHit);
     }
 }
示例#7
0
 public DamageTakenEventParameters(GameObject victim, PlayerBaseAttackLogic attackLogic, EAttackResult attackResult, bool isAlreadyHitStunned, uint damage, float healthRatio, EHitNotificationType hitNotif)
 {
     m_Victim              = victim;
     m_AttackLogic         = attackLogic;
     m_AttackResult        = attackResult;
     m_DamageTaken         = damage;
     m_HealthRatio         = healthRatio;
     m_IsAlreadyHitStunned = isAlreadyHitStunned;
     m_HitNotificationType = hitNotif;
 }
示例#8
0
    private void ApplyDamage(PlayerBaseAttackLogic attackLogic, uint damage, EAttackResult attackResult, EHitNotificationType hitNotificationType)
    {
        if (damage >= m_HP)
        {
            m_HP = (uint)(m_InfoComponent.GetPlayerSettings().m_IsInvincible ? 1 : 0);
        }
        else
        {
            m_HP -= damage;
        }

        OnDamageTaken(attackLogic, damage, attackResult, hitNotificationType);
    }
    public override EHitNotificationType GetHitNotificationType(EAttackResult attackResult, bool isInBlockingStance, bool isCrouching, bool isFacingRight, PlayerAttackComponent victimAttackComponent)
    {
        EHitNotificationType hitType = base.GetHitNotificationType(attackResult, isInBlockingStance, isCrouching, isFacingRight, victimAttackComponent);

        if (hitType == EHitNotificationType.None)
        {
            if (IsHitTakenInGuardCrush(isInBlockingStance, isCrouching))
            {
                hitType = EHitNotificationType.GuardCrush;
            }
        }

        return(hitType);
    }
    public override void GetHitFX(EAttackResult attackResult, EHitNotificationType hitNotifType, ref List <EHitFXType> hitFXList)
    {
        switch (attackResult)
        {
        case EAttackResult.Hit:
            if (hitNotifType == EHitNotificationType.GuardCrush)
            {
                hitFXList.Add(EHitFXType.GuardCrush);
            }
            break;
        }

        base.GetHitFX(attackResult, hitNotifType, ref hitFXList);
    }
示例#11
0
    public override float GetPushBackForce(EAttackResult attackResult)
    {
        switch (attackResult)
        {
        case EAttackResult.Hit:
            return(m_Config.m_HitPushBack);

        case EAttackResult.Blocked:
            return(m_Config.m_BlockPushBack);

        case EAttackResult.Parried:
        default:
            return(0f);
        }
    }
示例#12
0
    public override float GetStunDuration(EAttackResult attackResult)
    {
        switch (attackResult)
        {
        case EAttackResult.Hit:
            return(m_Config.HitStun);

        case EAttackResult.Blocked:
            return(m_Config.BlockStun);

        case EAttackResult.Parried:
        default:
            return(0f);
        }
    }
示例#13
0
    public override bool GetHitSFX(EAttackResult attackResult, EHitNotificationType hitNotifType, ref EAttackSFXType hitSFXType)
    {
        bool baseResult = base.GetHitSFX(attackResult, hitNotifType, ref hitSFXType);

        if (!baseResult)
        {
            switch (attackResult)
            {
            case EAttackResult.Hit:
                hitSFXType = EAttackSFXType.Hit_Heavy;
                return(true);
            }
        }

        return(baseResult);
    }
    public override bool GetHitSFX(EAttackResult attackResult, EHitNotificationType hitNotifType, ref EAttackSFXType hitSFXType)
    {
        switch (attackResult)
        {
        case EAttackResult.Hit:
            if (hitNotifType == EHitNotificationType.Counter)
            {
                hitSFXType = EAttackSFXType.Counter_Hit_Heavy;
                return(true);
            }
            else if (hitNotifType == EHitNotificationType.GuardCrush)
            {
                hitSFXType = EAttackSFXType.GuardCrush_Hit;
                return(true);
            }
            break;
        }

        return(base.GetHitSFX(attackResult, hitNotifType, ref hitSFXType));
    }
示例#15
0
    private void PlayDamageTakenAnim(PlayerBaseAttackLogic attackLogic, EAttackResult attackResult)
    {
        switch (attackResult)
        {
        case EAttackResult.Hit:
            PlayHitAnimation(attackLogic);
            break;

        case EAttackResult.Blocked:
            PlayBlockAnimation(attackLogic);
            break;

        case EAttackResult.Parried:
            PlayParriedAnimation(attackLogic);
            break;

        default:
            break;
        }
    }
示例#16
0
    public override void GetHitFX(EAttackResult attackResult, EHitNotificationType hitNotifType, ref List <EHitFXType> hitFXList)
    {
        base.GetHitFX(attackResult, hitNotifType, ref hitFXList);
        if (hitFXList.Count == 0)
        {
            switch (attackResult)
            {
            case EAttackResult.Hit:
                switch (m_Config.m_HitStrength)
                {
                case EHitStrength.Weak:
                    hitFXList.Add(EHitFXType.LightHit);
                    return;

                case EHitStrength.Strong:
                    hitFXList.Add(EHitFXType.HeavyHit);
                    return;
                }
                break;
            }
        }
    }
示例#17
0
    private void PlayHitSFX(PlayerBaseAttackLogic attackLogic, EAttackResult attackResult, EHitNotificationType hitNotificationType)
    {
        EAttackSFXType attackSFXType = EAttackSFXType.Hit_Light;

        bool validHitSFXFound = IsDead() || attackLogic.GetHitSFX(attackResult, hitNotificationType, ref attackSFXType);

        if (IsDead())
        {
            attackSFXType = EAttackSFXType.Final_Hit;
        }

        if (validHitSFXFound)
        {
            // Play attack SFX on the instigator of the hit in order to cancel whiff sfx
            m_AudioManager.PlayHitSFX(m_InfoComponent.GetPlayerIndex(), attackSFXType, attackLogic is PlayerProjectileAttackLogic);
        }
        else
        {
            KakutoDebug.LogError("No SFX found for attack " + attackLogic.GetAnimationAttackName() + " taken in " + attackResult);
            ChronicleManager.AddChronicle(gameObject, EChronicleCategory.Health, "No SFX found for attack " + attackLogic.GetAnimationAttackName() + " taken in " + attackResult);
        }
    }
示例#18
0
    public override uint GetHitDamage(EAttackResult attackResult)
    {
        float damage = 0f;

        switch (attackResult)
        {
        case EAttackResult.Hit:
            damage = m_Config.m_Damage;
            break;

        case EAttackResult.Blocked:
            damage = m_Config.m_CheapDamage;
            break;

        case EAttackResult.Parried:
        default:
            damage = 0f;
            break;
        }

        return((uint)Mathf.Max(damage * GetDamageRatio(), 1f));
    }
示例#19
0
    private void GetHitInfo(PlayerBaseAttackLogic attackLogic, out uint hitDamage, out EAttackResult attackResult, out EHitNotificationType hitNotificationType)
    {
        Profiler.BeginSample("PlayerHealthComponent.GetHitInfo");
        hitNotificationType = EHitNotificationType.None;

        if (CanParryAttack(attackLogic))
        {
            attackResult = EAttackResult.Parried;
            hitDamage    = 0;
        }
        else if (CanBlockAttack(attackLogic))
        {
            attackResult = EAttackResult.Blocked;
            hitDamage    = attackLogic.GetHitDamage(attackResult);
        }
        else
        {
            attackResult        = EAttackResult.Hit;
            hitDamage           = attackLogic.GetHitDamage(attackResult);
            hitNotificationType = attackLogic.GetHitNotificationType(attackResult, IsInBlockingStance(), m_MovementComponent.IsCrouching(), m_MovementComponent.IsFacingRight(), m_AttackComponent);
        }
        Profiler.EndSample();
    }
示例#20
0
    public override float GetAttackerPushBackForce(EAttackResult attackResult, bool enemyIsInACorner)
    {
        GetAttackerPushbackInfo(attackResult, out bool applyPushBack, out EAttackerPushBackCondition pushBackCondition, out float pushBackForce);
        if (applyPushBack)
        {
            switch (pushBackCondition)
            {
            case EAttackerPushBackCondition.Always:
                return(pushBackForce);

            case EAttackerPushBackCondition.OnlyIfEnemyIsInACorner:
                if (enemyIsInACorner)
                {
                    return(pushBackForce);
                }
                break;

            default:
                return(0f);
            }
        }

        return(0f);
    }
示例#21
0
    public override EHitNotificationType GetHitNotificationType(EAttackResult attackResult, bool isInBlockingStance, bool isCrouching, bool isFacingRight, PlayerAttackComponent victimAttackComponent)
    {
        EHitNotificationType hitType = base.GetHitNotificationType(attackResult, isInBlockingStance, isCrouching, isFacingRight, victimAttackComponent);

        if (hitType == EHitNotificationType.None)
        {
            EAttackType attackType = m_Config.m_AttackType;
            switch (attackType)
            {
            case EAttackType.Low:
                hitType = EHitNotificationType.Low;
                break;

            case EAttackType.Overhead:
                if (!GetAttack().m_NeededStanceList.Contains(EPlayerStance.Jump))
                {
                    hitType = EHitNotificationType.Overhead;
                }
                break;
            }
        }

        return(hitType);
    }
示例#22
0
    private void GetAttackerPushbackInfo(EAttackResult attackResult, out bool applyPushBack, out EAttackerPushBackCondition pushBackCondition, out float pushBackForce)
    {
        switch (attackResult)
        {
        case EAttackResult.Hit:
            applyPushBack     = m_Config.m_ApplyAttackerHitPushBack;
            pushBackCondition = m_Config.m_AttackerHitPushBackCondition;
            pushBackForce     = m_Config.m_AttackerHitPushBack;
            break;

        case EAttackResult.Blocked:
            applyPushBack     = m_Config.m_ApplyAttackerBlockPushBack;
            pushBackCondition = m_Config.m_AttackerBlockPushBackCondition;
            pushBackForce     = m_Config.m_AttackerBlockPushBack;
            break;

        case EAttackResult.Parried:
        default:
            applyPushBack     = false;
            pushBackCondition = EAttackerPushBackCondition.Always;
            pushBackForce     = 0f;
            break;
        }
    }
示例#23
0
    public virtual EHitNotificationType GetHitNotificationType(EAttackResult attackResult, bool isInBlockingStance, bool isCrouching, bool isFacingRight, PlayerAttackComponent victimAttackComponent)
    {
        if (victimAttackComponent.GetCurrentAttackLogic() != null)
        {
            EAttackState victimAttackState = victimAttackComponent.CurrentAttackState;
            if (victimAttackState == EAttackState.Startup || victimAttackState == EAttackState.Active)
            {
                return(EHitNotificationType.Counter);
            }
        }

        if (m_Attack.m_NeededStanceList.Contains(EPlayerStance.Jump) && m_MovementComponent.IsJumping())
        {
            if (m_CurrentCrossupCoroutine != null)
            {
                m_AttackComponent.StopCoroutine(m_CurrentCrossupCoroutine);
            }

            m_CurrentCrossupCoroutine = ValidateCrossup_Coroutine(victimAttackComponent.transform);
            m_AttackComponent.StartCoroutine(m_CurrentCrossupCoroutine);
        }

        return(EHitNotificationType.None);
    }
示例#24
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();
    }
示例#25
0
 public Blockable(float blockChance, EAttackResult blockMethod)
 {
     BlockChance = blockChance;
     BlockMethod = blockMethod;
 }
示例#26
0
 public virtual float GetStunDuration(EAttackResult attackResult)
 {
     return(0.0f);
 }
示例#27
0
 public virtual float GetPushBackForce(EAttackResult attackResult)
 {
     return(0.0f);
 }
示例#28
0
 public virtual float GetAttackerPushBackForce(EAttackResult attackResult, bool enemyIsInACorner)
 {
     return(0.0f);
 }
示例#29
0
 public override uint GetHitDamage(EAttackResult attackResult)
 {
     return((uint)Mathf.Max(m_Config.m_Damage * GetDamageRatio(), 1f));
 }
示例#30
0
 public virtual uint GetHitDamage(EAttackResult attackResult)
 {
     return(0);
 }