78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
public class CombatInput : MonoBehaviour
|
|
{
|
|
[Required] public PlayerInput playerInput;
|
|
|
|
public delegate void MoveInput(Vector2 movementInput);
|
|
public event MoveInput OnMoveInputReceived;
|
|
|
|
public delegate void DashInput();
|
|
public event DashInput OnDashInputReceived;
|
|
|
|
public delegate void AttackInput(bool usedMouse);
|
|
public event AttackInput OnAttackInputReceived;
|
|
|
|
[Button("셋팅 초기화")]
|
|
private void InitSetting()
|
|
{
|
|
playerInput = GetComponent<PlayerInput>();
|
|
}
|
|
|
|
public void OnMove(InputAction.CallbackContext context)
|
|
{
|
|
var movementInput = context.ReadValue<Vector2>();
|
|
OnMoveInputReceived?.Invoke(movementInput);
|
|
}
|
|
|
|
public void OnDash(InputAction.CallbackContext context)
|
|
{
|
|
if (context.started)
|
|
{
|
|
OnDashInputReceived?.Invoke();
|
|
}
|
|
}
|
|
|
|
public void OnAttack(InputAction.CallbackContext context)
|
|
{
|
|
if (context.started)
|
|
{
|
|
var device = context.control.device;
|
|
bool usedMouse;
|
|
|
|
switch (device)
|
|
{
|
|
case Keyboard:
|
|
usedMouse = false;
|
|
break;
|
|
case Mouse:
|
|
usedMouse = true;
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
|
|
OnAttackInputReceived?.Invoke(usedMouse);
|
|
}
|
|
}
|
|
|
|
private void OnItemInventory()
|
|
{
|
|
var activeSelf = UiManager.Inst.CombatUi.CombatItemInventoryUi.gameObject.activeSelf;
|
|
UiManager.Inst.CombatUi.CombatItemInventoryUi.SetActiveInventoryUi(!activeSelf);
|
|
}
|
|
|
|
private void OnEsc()
|
|
{
|
|
if (UiManager.Inst.CombatUi.CombatItemInventoryUi.gameObject.activeSelf)
|
|
{
|
|
UiManager.Inst.CombatUi.CombatItemInventoryUi.SetActiveInventoryUi(false);
|
|
}
|
|
}
|
|
}
|
|
} |