7579175d24
- Removed obsolete scripts: Chest, BreakableWall, Door, DoorInteract, and UiManager. - Moved Chest and BreakableWall scripts to EnvironmentObjects folder. - Introduced HammerThrower class to manage hammer throwing mechanics. - Updated PlayerController to utilize new InputManager and HammerThrower. - Refactored PlayerState to manage player state and item collection. - Enhanced UI management in UiManager to reflect player item collection. - Updated EnemyAI to remove unused movement logic. - Adjusted KeyChest to interact with PlayerState instead of Player. - Cleaned up code and improved event handling for item collection.
44 lines
922 B
C#
44 lines
922 B
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class InputManager : MonoBehaviour
|
|
{
|
|
private InputActions _actions;
|
|
|
|
public Vector2 Movement { get; private set; }
|
|
public event Action OnFire;
|
|
|
|
private void Awake()
|
|
{
|
|
_actions = new InputActions();
|
|
|
|
// Movement
|
|
_actions.Player.Movement.performed += OnMovementPerformed;
|
|
_actions.Player.Movement.canceled += OnMovementCanceled;
|
|
|
|
// Fire
|
|
_actions.Player.Fire.performed += ctx => OnFire?.Invoke();
|
|
}
|
|
|
|
public void OnEnable()
|
|
{
|
|
_actions.Enable();
|
|
}
|
|
|
|
public void OnDisable()
|
|
{
|
|
_actions.Disable();
|
|
}
|
|
|
|
private void OnMovementPerformed(InputAction.CallbackContext ctx)
|
|
{
|
|
Movement = ctx.ReadValue<Vector2>();
|
|
}
|
|
|
|
private void OnMovementCanceled(InputAction.CallbackContext ctx)
|
|
{
|
|
Movement = Vector2.zero;
|
|
}
|
|
}
|