DEG-111 [FIX] Actio 초기화, 관련 버그 수정

This commit is contained in:
Jay 2025-04-25 17:33:03 +09:00
parent fc8ec74970
commit 470d7a2932
3 changed files with 17 additions and 5 deletions

View File

@ -1,6 +1,8 @@
using UnityEngine; using UnityEngine;
public class PlayerActionAttack : IPlayerAction { public class PlayerActionAttack : IPlayerAction {
private static readonly int Attack = Animator.StringToHash("Attack");
private static readonly int ComboStep = Animator.StringToHash("ComboStep");
private PlayerController player; private PlayerController player;
private int comboStep = 1; private int comboStep = 1;
private bool comboQueued = false; private bool comboQueued = false;
@ -14,7 +16,7 @@ public class PlayerActionAttack : IPlayerAction {
comboStep = 1; comboStep = 1;
comboQueued = false; comboQueued = false;
PlayComboAnimation(comboStep); PlayComboAnimation(comboStep);
player.PlayerAnimator.SetBool("Attack", true); player.PlayerAnimator.SetBool(Attack, true);
} }
public void UpdateAction() { public void UpdateAction() {
@ -24,12 +26,14 @@ public class PlayerActionAttack : IPlayerAction {
} }
public void EndAction() { public void EndAction() {
player.PlayerAnimator.SetBool("Attack", false); player.PlayerAnimator.SetBool(Attack, false);
IsActive = false; IsActive = false;
player.OnActionEnded(this);
player = null; player = null;
} }
public void EnableCombo() { public void EnableCombo() {
if (comboStep > 4) return; // 마지막 공격일 땐 콤보 허용 X
canReceiveCombo = true; canReceiveCombo = true;
} }
@ -46,7 +50,7 @@ public class PlayerActionAttack : IPlayerAction {
} }
private void PlayComboAnimation(int step) { private void PlayComboAnimation(int step) {
player.PlayerAnimator.SetInteger("ComboStep", step); player.PlayerAnimator.SetInteger(ComboStep, step);
// 무기에 콤보 단계 전달 // 무기에 콤보 단계 전달
var weapon = player.GetComponentInChildren<WeaponController>(); var weapon = player.GetComponentInChildren<WeaponController>();

View File

@ -51,6 +51,7 @@ public class PlayerActionDash : IPlayerAction
public void EndAction() public void EndAction()
{ {
IsActive = false; IsActive = false;
player.OnActionEnded(this);
player = null; player = null;
} }
} }

View File

@ -167,7 +167,8 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
} }
// Animation Event에서 호출될 메서드 // Animation Event에서 호출될 메서드
public void SetAttackComboTrue() { public void SetAttackComboTrue()
{
if (_weaponController.IsAttacking) return; // 이미 공격 중이면 실행 안함 if (_weaponController.IsAttacking) return; // 이미 공격 중이면 실행 안함
if (_currentAction == _attackAction) { if (_currentAction == _attackAction) {
@ -176,13 +177,19 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
} }
} }
public void SetAttackComboFalse() { public void SetAttackComboFalse()
{
if (_currentAction == _attackAction) { if (_currentAction == _attackAction) {
_attackAction.DisableCombo(); _attackAction.DisableCombo();
_weaponController.AttackEnd(); _weaponController.AttackEnd();
} }
} }
public void OnActionEnded(IPlayerAction action)
{
if (_currentAction == action) _currentAction = null;
}
#endregion #endregion
#region #region