수정 내역 1. 아이템 인벤토리 씬별로 스크립트 구분 2. 전투씬에 GameOver, Clear, Menu Ui 추가 버그 수정 내역 1. 팝업UI 간의 충돌 버그 수정
130 lines
3.8 KiB
C#
130 lines
3.8 KiB
C#
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
public class CombatInput : MonoBehaviour
|
|
{
|
|
// Components
|
|
private PlayerInput playerInput;
|
|
|
|
// Const
|
|
public const string COMBAT = "Combat";
|
|
public 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);
|
|
CombatUiManager.Inst.CombatItemInventoryUi.Open();
|
|
}
|
|
}
|
|
|
|
public void OnCloseItemInventory(InputAction.CallbackContext context)
|
|
{
|
|
if (context.started)
|
|
{
|
|
if (!CombatUiManager.Inst.CombatItemInventoryUi.gameObject.activeSelf) return;
|
|
|
|
CombatUiManager.Inst.CombatItemInventoryUi.Close();
|
|
|
|
SwitchCurrentActionMap(COMBAT);
|
|
}
|
|
}
|
|
|
|
public void OnOpenMenu(InputAction.CallbackContext context)
|
|
{
|
|
if (context.started)
|
|
{
|
|
CombatUiManager.Inst.CombatMenuPopupUi.Open();
|
|
|
|
SwitchCurrentActionMap(COMBAT_UI);
|
|
}
|
|
}
|
|
|
|
public void OnCancel(InputAction.CallbackContext context)
|
|
{
|
|
if (context.started)
|
|
{
|
|
CombatUiManager.Inst.CloseLastPopup();
|
|
|
|
if (!CombatUiManager.Inst.IsPopupListEmpty()) return;
|
|
|
|
SwitchCurrentActionMap(COMBAT);
|
|
}
|
|
}
|
|
|
|
// Methods
|
|
private void SwitchCurrentActionMap(string actionMapName)
|
|
{
|
|
playerInput.SwitchCurrentActionMap(actionMapName);
|
|
}
|
|
}
|
|
} |