65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using BlueWater.Uis;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.InputSystem;
|
||
|
|
||
|
namespace BlueWater.Players.Tycoons
|
||
|
{
|
||
|
public class TycoonInput : MonoBehaviour
|
||
|
{
|
||
|
// variables
|
||
|
#region variables
|
||
|
|
||
|
// Components
|
||
|
private PlayerInput _playerInput;
|
||
|
|
||
|
// Events
|
||
|
public event Action<Vector2> OnMoveInputReceived;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
// Initialize methods
|
||
|
#region Initialize methods
|
||
|
|
||
|
public void InitializeComponents(PlayerInput playerInput)
|
||
|
{
|
||
|
_playerInput = playerInput;
|
||
|
_playerInput.enabled = true;
|
||
|
PlayerInputKeyManager.Instance.SetCurrentPlayerInput(_playerInput);
|
||
|
PlayerInputKeyManager.Instance.SwitchCurrentActionMap(InputActionMaps.Tycoon);
|
||
|
|
||
|
StartCoroutine(nameof(PlayerInputCoroutine));
|
||
|
}
|
||
|
|
||
|
private IEnumerator PlayerInputCoroutine()
|
||
|
{
|
||
|
yield return new WaitForSeconds(0.5f);
|
||
|
|
||
|
PlayerInputKeyManager.Instance.DisableAllActionMaps();
|
||
|
PlayerInputKeyManager.Instance.EnableCurrentPlayerInput();
|
||
|
PlayerInputKeyManager.Instance.SwitchCurrentActionMap(InputActionMaps.Tycoon);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
// Player input methods
|
||
|
#region Player input methods
|
||
|
|
||
|
public void OnMove(InputAction.CallbackContext context)
|
||
|
{
|
||
|
var movementInput = context.ReadValue<Vector2>();
|
||
|
OnMoveInputReceived?.Invoke(movementInput);
|
||
|
}
|
||
|
|
||
|
public void OnInteraction(InputAction.CallbackContext context)
|
||
|
{
|
||
|
if (context.performed)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|