Merge pull request 'DEG-151-플레이어-공격-되다가-안되는-이슈-공격속도-강화를-위해-수정-필요' (!43) from DEG-151-플레이어-공격-되다가-안되는-이슈-공격속도-강화를-위해-수정-필요 into main
Reviewed-on: #43 Reviewed-by: Sehyeon <sehyeon1837@gmail.com> Reviewed-by: 99jamin <rhwk341@naver.com>
This commit is contained in:
commit
940d967b4f
BIN
Assets/JAY/Animation/CustomAttack01.anim
(Stored with Git LFS)
BIN
Assets/JAY/Animation/CustomAttack01.anim
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/JAY/Animation/CustomAttack02.anim
(Stored with Git LFS)
BIN
Assets/JAY/Animation/CustomAttack02.anim
(Stored with Git LFS)
Binary file not shown.
@ -9,16 +9,6 @@ public class AnimatorEventRelay : MonoBehaviour
|
|||||||
_playerController = GetComponentInParent<PlayerController>();
|
_playerController = GetComponentInParent<PlayerController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAttackComboTrue()
|
|
||||||
{
|
|
||||||
_playerController?.SetAttackComboTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetAttackComboFalse()
|
|
||||||
{
|
|
||||||
_playerController?.SetAttackComboFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PlayAttackEffect()
|
public void PlayAttackEffect()
|
||||||
{
|
{
|
||||||
_playerController?.PlayAttackEffect();
|
_playerController?.PlayAttackEffect();
|
||||||
|
@ -2,72 +2,79 @@
|
|||||||
|
|
||||||
public class PlayerActionAttack : IPlayerAction {
|
public class PlayerActionAttack : IPlayerAction {
|
||||||
private static readonly int ComboStep = Animator.StringToHash("ComboStep");
|
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;
|
||||||
private bool canReceiveCombo = false;
|
private bool canReceiveCombo = false;
|
||||||
|
private float comboTimer = 0f;
|
||||||
|
|
||||||
public int CurrentComboStep => comboStep;
|
[SerializeField] private float comboDuration = 0.7f;
|
||||||
|
private int maxComboStep = 4;
|
||||||
|
|
||||||
public bool IsActive { get; private set; }
|
public bool IsActive { get; private set; }
|
||||||
|
public int CurrentComboStep => comboStep;
|
||||||
|
|
||||||
public void StartAction(PlayerController player) {
|
public void StartAction(PlayerController player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
|
|
||||||
comboStep = 1;
|
comboStep = 1;
|
||||||
comboQueued = false;
|
comboQueued = false;
|
||||||
PlayComboAnimation(comboStep);
|
canReceiveCombo = true;
|
||||||
|
comboTimer = 0f;
|
||||||
|
|
||||||
player.SafeSetBool("Attack", true);
|
player.SafeSetBool("Attack", true);
|
||||||
|
PlayComboAnimation(comboStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateAction() {
|
public void UpdateAction() {
|
||||||
if (Input.GetKeyDown(KeyCode.X) && canReceiveCombo) {
|
comboTimer += Time.deltaTime;
|
||||||
|
|
||||||
|
if (canReceiveCombo && Input.GetKeyDown(KeyCode.X)) {
|
||||||
comboQueued = true;
|
comboQueued = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (comboTimer >= comboDuration) {
|
||||||
|
ProceedComboOrEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProceedComboOrEnd() {
|
||||||
|
canReceiveCombo = false;
|
||||||
|
|
||||||
|
if (comboQueued && comboStep < maxComboStep) {
|
||||||
|
comboStep++;
|
||||||
|
comboQueued = false;
|
||||||
|
comboTimer = 0f;
|
||||||
|
canReceiveCombo = true;
|
||||||
|
PlayComboAnimation(comboStep);
|
||||||
|
} else {
|
||||||
|
EndAction();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EndAction() {
|
public void EndAction() {
|
||||||
|
if (player == null) return;
|
||||||
|
|
||||||
player.SafeSetBool("Attack", false);
|
player.SafeSetBool("Attack", false);
|
||||||
IsActive = false;
|
IsActive = false;
|
||||||
player.OnActionEnded(this); // player 에서도 action 초기화
|
player.OnActionEnded(this);
|
||||||
player = null;
|
player = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnableCombo() {
|
private void PlayComboAnimation(int step) {
|
||||||
canReceiveCombo = true;
|
if (player?.PlayerAnimator == null) return;
|
||||||
}
|
|
||||||
|
|
||||||
public void DisableCombo() {
|
|
||||||
canReceiveCombo = false;
|
|
||||||
|
|
||||||
if (comboQueued && comboStep < 4) {
|
|
||||||
comboStep++;
|
|
||||||
PlayComboAnimation(comboStep);
|
|
||||||
comboQueued = false;
|
|
||||||
} else {
|
|
||||||
EndAction(); // 행동 종료
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PlayComboAnimation(int step)
|
|
||||||
{
|
|
||||||
if (player.PlayerAnimator == null) return;
|
|
||||||
|
|
||||||
// 안전하게 파라미터 체크
|
|
||||||
foreach (var param in player.PlayerAnimator.parameters)
|
|
||||||
{
|
|
||||||
if (param.nameHash == ComboStep && param.type == AnimatorControllerParameterType.Int)
|
|
||||||
{
|
|
||||||
player.PlayerAnimator.SetInteger(ComboStep, step);
|
player.PlayerAnimator.SetInteger(ComboStep, step);
|
||||||
break;
|
|
||||||
}
|
var weapon = player.GetComponentInChildren<WeaponController>();
|
||||||
|
weapon?.SetComboStep(step);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 무기에 콤보 단계 전달
|
public void OnComboInput() {
|
||||||
var weapon = player.GetComponentInChildren<WeaponController>();
|
if (canReceiveCombo) {
|
||||||
if (weapon != null)
|
comboQueued = true;
|
||||||
{
|
|
||||||
weapon.SetComboStep(step);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -292,26 +292,6 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
|||||||
weapon.SetActive(_isBattle);
|
weapon.SetActive(_isBattle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Animation Event에서 호출될 메서드
|
|
||||||
public void SetAttackComboTrue()
|
|
||||||
{
|
|
||||||
if (_weaponController.IsAttacking) return; // 이미 공격 중이면 실행 안함
|
|
||||||
|
|
||||||
if (_currentAction == _attackAction) {
|
|
||||||
_attackAction.EnableCombo();
|
|
||||||
_weaponController.AttackStart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetAttackComboFalse()
|
|
||||||
{
|
|
||||||
if (_currentAction == _attackAction) {
|
|
||||||
// 이벤트 중복 호출? 공격 종료 시 SetAttackComboFalse가 아니라 ~True로 끝나서 오류 발생. (공격 안하는 상태여도 공격으로 판정됨)
|
|
||||||
_attackAction.DisableCombo();
|
|
||||||
_weaponController.AttackEnd(); // IsAttacking = false로 변경
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PlayAttackEffect()
|
public void PlayAttackEffect()
|
||||||
{
|
{
|
||||||
if (_attackAction == null) return;
|
if (_attackAction == null) return;
|
||||||
@ -350,6 +330,10 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
|||||||
GameManager.Instance.PlayPlayerAttackSound();
|
GameManager.Instance.PlayPlayerAttackSound();
|
||||||
StartAttackAction();
|
StartAttackAction();
|
||||||
}
|
}
|
||||||
|
else if (_currentAction is PlayerActionAttack attackAction)
|
||||||
|
{
|
||||||
|
attackAction.OnComboInput();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user