+ CombatPlayer 기능별 분리 + Combat, CombatUi 전용 input action map 추가 + 스킬 시스템 로직 수정 + 전투플레이어 스킬(검의 왈츠) 로직 변경
119 lines
3.5 KiB
C#
119 lines
3.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
public class CombatInput : MonoBehaviour
|
|
{
|
|
// Components
|
|
private PlayerInput playerInput;
|
|
|
|
// Const
|
|
private const string COMBAT = "Combat";
|
|
private const string COMBAT_UI = "CombatUi";
|
|
|
|
// Events
|
|
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;
|
|
|
|
public delegate void ActivateMainSkillInput();
|
|
public event ActivateMainSkillInput OnActivateMainSkillInputReceived;
|
|
|
|
// Init
|
|
public void InitComponent(PlayerInput playerInput)
|
|
{
|
|
this.playerInput = playerInput;
|
|
}
|
|
|
|
// Player input methods
|
|
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);
|
|
}
|
|
}
|
|
|
|
public void OnActivateMainSkill(InputAction.CallbackContext context)
|
|
{
|
|
if (context.started)
|
|
{
|
|
OnActivateMainSkillInputReceived?.Invoke();
|
|
}
|
|
}
|
|
|
|
public void OnOpenItemInventory(InputAction.CallbackContext context)
|
|
{
|
|
if (context.started)
|
|
{
|
|
SwitchCurrentActionMap(COMBAT_UI);
|
|
UiManager.Inst.CombatUi.CombatItemInventoryUi.SetActiveInventoryUi(true);
|
|
}
|
|
}
|
|
|
|
public void OnCloseItemInventory(InputAction.CallbackContext context)
|
|
{
|
|
if (context.started)
|
|
{
|
|
UiManager.Inst.CombatUi.CombatItemInventoryUi.SetActiveInventoryUi(false);
|
|
|
|
// Todo : 또 다른 UI 체크?
|
|
SwitchCurrentActionMap(COMBAT);
|
|
}
|
|
}
|
|
|
|
public void OnCancel(InputAction.CallbackContext context)
|
|
{
|
|
if (context.started)
|
|
{
|
|
if (UiManager.Inst.CombatUi.CombatItemInventoryUi.gameObject.activeSelf)
|
|
{
|
|
UiManager.Inst.CombatUi.CombatItemInventoryUi.SetActiveInventoryUi(false);
|
|
SwitchCurrentActionMap(COMBAT);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Methods
|
|
private void SwitchCurrentActionMap(string actionMapName)
|
|
{
|
|
playerInput.SwitchCurrentActionMap(actionMapName);
|
|
}
|
|
}
|
|
} |