2024-06-03 18:26:03 +00:00
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
|
|
|
namespace BlueWater
|
|
|
|
{
|
|
|
|
public enum InputActionMaps
|
|
|
|
{
|
|
|
|
None = 0,
|
2024-06-06 11:07:07 +00:00
|
|
|
Tycoon,
|
|
|
|
TycoonUi,
|
2024-06-16 21:29:06 +00:00
|
|
|
CombatTitle,
|
2024-06-03 18:26:03 +00:00
|
|
|
Combat,
|
|
|
|
CombatUi,
|
|
|
|
}
|
|
|
|
|
|
|
|
public class PlayerInputKeyManager : Singleton<PlayerInputKeyManager>
|
|
|
|
{
|
|
|
|
[SerializeField]
|
|
|
|
private PlayerInput _currentPlayerInput;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 현재 실행되고 있는 PlayerInput을 관리할 수 있게
|
|
|
|
/// PlayerInput 컴포넌트를 받아와서 사용하는 경우에 필수로 호출
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="playerInput"></param>
|
|
|
|
public void SetCurrentPlayerInput(PlayerInput playerInput) => _currentPlayerInput = playerInput;
|
|
|
|
|
|
|
|
private bool IsNullCurrentPlayerInput()
|
|
|
|
{
|
2024-06-16 21:29:06 +00:00
|
|
|
if (_currentPlayerInput && _currentPlayerInput.enabled) return false;
|
2024-06-03 18:26:03 +00:00
|
|
|
|
2024-06-21 22:11:53 +00:00
|
|
|
Debug.Log("CurrentPlayerInput가 할당되지 않았습니다.");
|
2024-06-03 18:26:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SwitchCurrentActionMap(string inputActionMaps)
|
|
|
|
{
|
|
|
|
if (IsNullCurrentPlayerInput()) return;
|
|
|
|
|
|
|
|
_currentPlayerInput.SwitchCurrentActionMap(inputActionMaps);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SwitchCurrentActionMap(InputActionMaps inputActionMaps)
|
|
|
|
{
|
|
|
|
if (IsNullCurrentPlayerInput()) return;
|
|
|
|
|
|
|
|
_currentPlayerInput.SwitchCurrentActionMap(inputActionMaps.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
public InputActionMap GetCurrentInputActionMap()
|
|
|
|
{
|
|
|
|
if (IsNullCurrentPlayerInput()) return null;
|
|
|
|
|
|
|
|
return _currentPlayerInput.currentActionMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void EnableCurrentPlayerInput()
|
|
|
|
{
|
2024-06-21 22:11:53 +00:00
|
|
|
if (!_currentPlayerInput) return;
|
2024-06-03 18:26:03 +00:00
|
|
|
|
|
|
|
_currentPlayerInput.enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DisableCurrentPlayerInput()
|
|
|
|
{
|
|
|
|
if (IsNullCurrentPlayerInput()) return;
|
|
|
|
|
|
|
|
_currentPlayerInput.enabled = false;
|
|
|
|
}
|
|
|
|
|
2024-06-04 13:15:14 +00:00
|
|
|
public void DisableAllActionMaps()
|
|
|
|
{
|
|
|
|
if (IsNullCurrentPlayerInput()) return;
|
|
|
|
|
|
|
|
foreach (var element in _currentPlayerInput.actions.actionMaps)
|
|
|
|
{
|
|
|
|
element.Disable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-03 18:26:03 +00:00
|
|
|
public void DisableAllActionsExcept(string exceptActionName)
|
|
|
|
{
|
|
|
|
if (IsNullCurrentPlayerInput()) return;
|
|
|
|
|
|
|
|
var exceptAction = _currentPlayerInput.currentActionMap.FindAction(exceptActionName);
|
|
|
|
|
|
|
|
foreach (var action in _currentPlayerInput.currentActionMap.actions)
|
|
|
|
{
|
|
|
|
if (action != exceptAction)
|
|
|
|
{
|
|
|
|
action.Disable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
action.Enable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-16 21:29:06 +00:00
|
|
|
public void EnableAllActionsMaps()
|
2024-06-03 18:26:03 +00:00
|
|
|
{
|
|
|
|
if (IsNullCurrentPlayerInput()) return;
|
|
|
|
|
|
|
|
foreach (var action in _currentPlayerInput.actions)
|
|
|
|
{
|
|
|
|
action.Enable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|