53 lines
1.5 KiB
C#
53 lines
1.5 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(InputAction.CallbackContext context);
|
|
public event AttackInput OnAttackInputReceived;
|
|
|
|
private void OnEnable()
|
|
{
|
|
playerInput.actions.FindAction("Attack").performed += OnAttackEvent;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
playerInput.actions.FindAction("Attack").performed -= OnAttackEvent;
|
|
}
|
|
|
|
[Button("셋팅 초기화")]
|
|
private void InitSetting()
|
|
{
|
|
playerInput = GetComponent<PlayerInput>();
|
|
}
|
|
|
|
private void OnMove(InputValue value)
|
|
{
|
|
var movementInput = value.Get<Vector2>();
|
|
OnMoveInputReceived?.Invoke(movementInput);
|
|
}
|
|
|
|
private void OnDash()
|
|
{
|
|
OnDashInputReceived?.Invoke();
|
|
}
|
|
|
|
private void OnAttackEvent(InputAction.CallbackContext context)
|
|
{
|
|
OnAttackInputReceived?.Invoke(context);
|
|
}
|
|
}
|
|
} |