+ UiManager의 CombatUi, OceanUi 모두 분리 각각의 씬에서 CombatUiManager, OceanUiManager로 변경 + Ocean, OceanUi input action map 추가 및 변경 input action map, uiManager 변경에 따른 Player input 로직 변경 + CombatPlayer가 죽으면 GameOverUi 추가 + 재시작 기능 추가 + 인벤토리 Ui 수정 + 슬라임 보스 로직 및 애니메이션 수정
118 lines
3.4 KiB
C#
118 lines
3.4 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);
|
|
CombatUiManager.Inst.CombatItemInventoryUi.Open();
|
|
}
|
|
}
|
|
|
|
public void OnCloseItemInventory(InputAction.CallbackContext context)
|
|
{
|
|
if (context.started)
|
|
{
|
|
CombatUiManager.Inst.CombatItemInventoryUi.Close();
|
|
|
|
SwitchCurrentActionMap(COMBAT);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
} |