diff --git a/Assets/JAY/Scripts/IPlayerAction/PlayerActionAttack.cs b/Assets/JAY/Scripts/IPlayerAction/PlayerActionAttack.cs index ab824561..225e1cc7 100644 --- a/Assets/JAY/Scripts/IPlayerAction/PlayerActionAttack.cs +++ b/Assets/JAY/Scripts/IPlayerAction/PlayerActionAttack.cs @@ -1,6 +1,8 @@ using UnityEngine; public class PlayerActionAttack : IPlayerAction { + private static readonly int Attack = Animator.StringToHash("Attack"); + private static readonly int ComboStep = Animator.StringToHash("ComboStep"); private PlayerController player; private int comboStep = 1; private bool comboQueued = false; @@ -14,7 +16,7 @@ public class PlayerActionAttack : IPlayerAction { comboStep = 1; comboQueued = false; PlayComboAnimation(comboStep); - player.PlayerAnimator.SetBool("Attack", true); + player.PlayerAnimator.SetBool(Attack, true); } public void UpdateAction() { @@ -24,12 +26,14 @@ public class PlayerActionAttack : IPlayerAction { } public void EndAction() { - player.PlayerAnimator.SetBool("Attack", false); + player.PlayerAnimator.SetBool(Attack, false); IsActive = false; + player.OnActionEnded(this); player = null; } public void EnableCombo() { + if (comboStep > 4) return; // 마지막 공격일 땐 콤보 허용 X canReceiveCombo = true; } @@ -46,7 +50,7 @@ public class PlayerActionAttack : IPlayerAction { } private void PlayComboAnimation(int step) { - player.PlayerAnimator.SetInteger("ComboStep", step); + player.PlayerAnimator.SetInteger(ComboStep, step); // 무기에 콤보 단계 전달 var weapon = player.GetComponentInChildren(); diff --git a/Assets/JAY/Scripts/IPlayerAction/PlayerActionDash.cs b/Assets/JAY/Scripts/IPlayerAction/PlayerActionDash.cs index e8336ea7..a0713ed5 100644 --- a/Assets/JAY/Scripts/IPlayerAction/PlayerActionDash.cs +++ b/Assets/JAY/Scripts/IPlayerAction/PlayerActionDash.cs @@ -51,6 +51,7 @@ public class PlayerActionDash : IPlayerAction public void EndAction() { IsActive = false; + player.OnActionEnded(this); player = null; } } diff --git a/Assets/JAY/Scripts/PlayerController.cs b/Assets/JAY/Scripts/PlayerController.cs index 2c841575..60153284 100644 --- a/Assets/JAY/Scripts/PlayerController.cs +++ b/Assets/JAY/Scripts/PlayerController.cs @@ -167,7 +167,8 @@ public class PlayerController : CharacterBase, IObserver } // Animation Event에서 호출될 메서드 - public void SetAttackComboTrue() { + public void SetAttackComboTrue() + { if (_weaponController.IsAttacking) return; // 이미 공격 중이면 실행 안함 if (_currentAction == _attackAction) { @@ -176,13 +177,19 @@ public class PlayerController : CharacterBase, IObserver } } - public void SetAttackComboFalse() { + public void SetAttackComboFalse() + { if (_currentAction == _attackAction) { _attackAction.DisableCombo(); _weaponController.AttackEnd(); } } + public void OnActionEnded(IPlayerAction action) + { + if (_currentAction == action) _currentAction = null; + } + #endregion #region 대시 관련