DEG-143-대시 쿨타임 적용
This commit is contained in:
parent
bb8a9aea3f
commit
88839f28a5
@ -26,6 +26,7 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
|||||||
private WeaponController _weaponController;
|
private WeaponController _weaponController;
|
||||||
private float attackUpgradeLevel;
|
private float attackUpgradeLevel;
|
||||||
private float moveSpeedUpgradeLevel;
|
private float moveSpeedUpgradeLevel;
|
||||||
|
private float dashCooldownUpgradeLevel;
|
||||||
|
|
||||||
private IPlayerState _currentStateClass { get; set; }
|
private IPlayerState _currentStateClass { get; set; }
|
||||||
private IPlayerAction _currentAction;
|
private IPlayerAction _currentAction;
|
||||||
@ -51,6 +52,13 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
|||||||
public bool IsBattle => _isBattle;
|
public bool IsBattle => _isBattle;
|
||||||
public Transform DashEffectAnchor => dashEffectAnchor;
|
public Transform DashEffectAnchor => dashEffectAnchor;
|
||||||
|
|
||||||
|
// 대시 쿨타임 관련
|
||||||
|
[SerializeField] private float dashCooldownDuration = 1.5f;
|
||||||
|
private float dashCooldownTimer = 0f;
|
||||||
|
public bool IsDashOnCooldown => dashCooldownTimer > 0f;
|
||||||
|
public float DashCooldownRatio => dashCooldownTimer / dashCooldownDuration;
|
||||||
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
if (Joystick == null)
|
if (Joystick == null)
|
||||||
@ -77,9 +85,11 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
|||||||
//강화 적용
|
//강화 적용
|
||||||
attackUpgradeLevel = 1 + (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.AttackPower)/2;
|
attackUpgradeLevel = 1 + (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.AttackPower)/2;
|
||||||
moveSpeedUpgradeLevel = 1 + (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.MoveSpeed)/2;
|
moveSpeedUpgradeLevel = 1 + (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.MoveSpeed)/2;
|
||||||
|
dashCooldownUpgradeLevel = (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.DashCoolDown)/4;
|
||||||
|
|
||||||
attackPower *= attackUpgradeLevel;
|
attackPower *= attackUpgradeLevel;
|
||||||
moveSpeed *= moveSpeedUpgradeLevel;
|
moveSpeed *= moveSpeedUpgradeLevel;
|
||||||
|
dashCooldownDuration -= dashCooldownUpgradeLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
@ -89,6 +99,10 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
|||||||
_playerStates[CurrentState].Update();
|
_playerStates[CurrentState].Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 대시 쿨타임 진행
|
||||||
|
if (dashCooldownTimer > 0f)
|
||||||
|
dashCooldownTimer -= Time.deltaTime;
|
||||||
|
|
||||||
// Hit 상태거나 게임 끝났을 땐 땐 입력 무시
|
// Hit 상태거나 게임 끝났을 땐 땐 입력 무시
|
||||||
if (CurrentState == PlayerState.Hit || CurrentState == PlayerState.Dead || CurrentState == PlayerState.Win)
|
if (CurrentState == PlayerState.Hit || CurrentState == PlayerState.Dead || CurrentState == PlayerState.Win)
|
||||||
return;
|
return;
|
||||||
@ -239,6 +253,13 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
|||||||
{
|
{
|
||||||
if (!_isBattle) return;
|
if (!_isBattle) return;
|
||||||
|
|
||||||
|
// 쿨타임 중이면 무시
|
||||||
|
if (IsDashOnCooldown)
|
||||||
|
{
|
||||||
|
Debug.Log("대시 쿨타임 중");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 만약 공격 중이면 강제로 공격 종료
|
// 만약 공격 중이면 강제로 공격 종료
|
||||||
if (_currentAction == _attackAction && _attackAction.IsActive)
|
if (_currentAction == _attackAction && _attackAction.IsActive)
|
||||||
{
|
{
|
||||||
@ -252,6 +273,9 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
|||||||
|
|
||||||
_currentAction = _actionDash;
|
_currentAction = _actionDash;
|
||||||
_actionDash.StartAction(this);
|
_actionDash.StartAction(this);
|
||||||
|
|
||||||
|
// 쿨타임 시작
|
||||||
|
dashCooldownTimer = dashCooldownDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnActionEnded(IPlayerAction action)
|
public void OnActionEnded(IPlayerAction action)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user