Refactor and reorganize scripts for improved structure and functionality

- 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.
This commit is contained in:
2026-06-05 14:33:20 +03:00
parent 39294ec527
commit 7579175d24
33 changed files with 458 additions and 278 deletions
+30 -11
View File
@@ -1,24 +1,43 @@
using System;
using UnityEngine;
using UnityEngine.InputSystem;
public class InputManager : MonoBehaviour
{
private InputActions _inputActions;
private InputActions _actions;
public event EventHandler<Vector2> OnMovementInput;
public event EventHandler OnFireButtonPressed;
public Vector2 Movement { get; private set; }
public event Action OnFire;
private void Awake()
{
_inputActions = new InputActions();
_inputActions.Player.Movement.performed += ctx => OnMovementInput?.Invoke(ctx.ReadValue<Vector2>());
_inputActions.Player.Fire.performed += ctx => OnFireButtonPressed?.Invoke();
_actions = new InputActions();
// Movement
_actions.Player.Movement.performed += OnMovementPerformed;
_actions.Player.Movement.canceled += OnMovementCanceled;
// Fire
_actions.Player.Fire.performed += ctx => OnFire?.Invoke();
}
private void OnEnable()
public void OnEnable()
{
_inputActions.Enable();
_actions.Enable();
}
private void OnDisable()
public void OnDisable()
{
_inputActions.Disable();
_actions.Disable();
}
}
private void OnMovementPerformed(InputAction.CallbackContext ctx)
{
Movement = ctx.ReadValue<Vector2>();
}
private void OnMovementCanceled(InputAction.CallbackContext ctx)
{
Movement = Vector2.zero;
}
}