Implement movement input handling and update UI components for treasure collection
This commit is contained in:
@@ -17,6 +17,7 @@ public class PlayerController : Character
|
||||
private InputManager _inputManager;
|
||||
private PlayerState _playerState;
|
||||
private HammerThrower _hammerThrower;
|
||||
private Vector2 _currentMovement;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -25,6 +26,7 @@ public class PlayerController : Character
|
||||
_hammerThrower = GetComponent<HammerThrower>();
|
||||
|
||||
_inputManager.OnFire += OnFireButtonPressed;
|
||||
_inputManager.OnMovementChanged += OnMovementChanged;
|
||||
base.Init();
|
||||
}
|
||||
|
||||
@@ -38,6 +40,15 @@ public class PlayerController : Character
|
||||
_inputManager.OnDisable();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_inputManager != null)
|
||||
{
|
||||
_inputManager.OnFire -= OnFireButtonPressed;
|
||||
_inputManager.OnMovementChanged -= OnMovementChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_hammer == null && !_isHoldingHammer)
|
||||
@@ -46,11 +57,15 @@ public class PlayerController : Character
|
||||
_isHoldingHammer = true;
|
||||
}
|
||||
|
||||
Vector2 move = _inputManager.Movement;
|
||||
MoveTo(move.x, isAllowVertical ? move.y : 0);
|
||||
MoveTo(_currentMovement.x, isAllowVertical ? _currentMovement.y : 0);
|
||||
_hammerThrower.SetFacingDirection(_facingRight);
|
||||
}
|
||||
|
||||
private void OnMovementChanged(Vector2 movement)
|
||||
{
|
||||
_currentMovement = movement;
|
||||
}
|
||||
|
||||
private void OnFireButtonPressed()
|
||||
{
|
||||
if (_hammerThrower.CanThrow)
|
||||
|
||||
Reference in New Issue
Block a user