레스토랑 플레이어 키 바인딩 구조 변경
This commit is contained in:
parent
2b483bf213
commit
8fb94dc08a
@ -0,0 +1,35 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
namespace DDD
|
||||||
|
{
|
||||||
|
public class RestaurantPlayerInput : MonoBehaviour
|
||||||
|
{
|
||||||
|
private RestaurantPlayerDataSo _playerDataSo;
|
||||||
|
|
||||||
|
private async void Start()
|
||||||
|
{
|
||||||
|
_playerDataSo = await AssetManager.LoadAsset<RestaurantPlayerDataSo>(DataConstants.RestaurantPlayerDataSo);
|
||||||
|
_playerDataSo.OpenManagementUiAction = InputManager.Instance.GetAction(InputActionMaps.Restaurant, nameof(RestaurantActions.OpenManagementUi));
|
||||||
|
|
||||||
|
_playerDataSo.OpenManagementUiAction.performed += OnOpenManagementUi;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
if (!_playerDataSo) return;
|
||||||
|
|
||||||
|
_playerDataSo.OpenManagementUiAction.performed -= OnOpenManagementUi;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnOpenManagementUi(InputAction.CallbackContext context)
|
||||||
|
{
|
||||||
|
if (context.performed)
|
||||||
|
{
|
||||||
|
var evt = GameEvents.OpenPopupUiEvent;
|
||||||
|
evt.UiType = typeof(RestaurantManagementUi);
|
||||||
|
EventBus.Broadcast(evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -92,18 +92,21 @@ private async System.Threading.Tasks.Task InitializePlayerData()
|
|||||||
|
|
||||||
private void SubscribeToInputEvents()
|
private void SubscribeToInputEvents()
|
||||||
{
|
{
|
||||||
_playerDataSo.MoveActionReference.action.performed += OnMove;
|
_playerDataSo.MoveAction = InputManager.Instance.GetAction(InputActionMaps.Restaurant, nameof(RestaurantActions.Move));
|
||||||
_playerDataSo.MoveActionReference.action.canceled += OnMove;
|
_playerDataSo.DashAction = InputManager.Instance.GetAction(InputActionMaps.Restaurant, nameof(RestaurantActions.Dash));
|
||||||
_playerDataSo.DashActionReference.action.performed += OnDash;
|
|
||||||
|
_playerDataSo.MoveAction.performed += OnMove;
|
||||||
|
_playerDataSo.MoveAction.canceled += OnMove;
|
||||||
|
_playerDataSo.DashAction.performed += OnDash;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UnsubscribeFromInputEvents()
|
private void UnsubscribeFromInputEvents()
|
||||||
{
|
{
|
||||||
if (!_playerDataSo) return;
|
if (!_playerDataSo) return;
|
||||||
|
|
||||||
_playerDataSo.MoveActionReference.action.performed -= OnMove;
|
_playerDataSo.MoveAction.performed -= OnMove;
|
||||||
_playerDataSo.MoveActionReference.action.canceled -= OnMove;
|
_playerDataSo.MoveAction.canceled -= OnMove;
|
||||||
_playerDataSo.DashActionReference.action.performed -= OnDash;
|
_playerDataSo.DashAction.performed -= OnDash;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -164,7 +167,7 @@ private void ApplyVelocity()
|
|||||||
|
|
||||||
private void OnDash(InputAction.CallbackContext context)
|
private void OnDash(InputAction.CallbackContext context)
|
||||||
{
|
{
|
||||||
if (CanDash())
|
if (context.performed && CanDash())
|
||||||
{
|
{
|
||||||
StartCoroutine(DashCoroutine());
|
StartCoroutine(DashCoroutine());
|
||||||
}
|
}
|
||||||
@ -218,10 +221,13 @@ private void SetCurrentDirection(Vector3 normalDirection)
|
|||||||
#region Input Handling
|
#region Input Handling
|
||||||
|
|
||||||
private void OnMove(InputAction.CallbackContext context)
|
private void OnMove(InputAction.CallbackContext context)
|
||||||
|
{
|
||||||
|
if (context.performed || context.canceled)
|
||||||
{
|
{
|
||||||
Vector2 movementInput = context.ReadValue<Vector2>();
|
Vector2 movementInput = context.ReadValue<Vector2>();
|
||||||
_inputDirection = new Vector3(movementInput.x, 0f, movementInput.y);
|
_inputDirection = new Vector3(movementInput.x, 0f, movementInput.y);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user