Add initial game systems and input handling for player interactions
This commit is contained in:
32
Assets/Scripts/Infrastructure/PlayerOneInput.cs
Normal file
32
Assets/Scripts/Infrastructure/PlayerOneInput.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using Abstractions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Infrastructure
|
||||
{
|
||||
public class PlayerOneInput : IInputService, IDisposable
|
||||
{
|
||||
private readonly Actions _input = new();
|
||||
|
||||
public PlayerOneInput ()
|
||||
{
|
||||
_input.Player.Enable();
|
||||
}
|
||||
|
||||
public float GetHorizontalMovement()
|
||||
{
|
||||
return _input.Player.Move.ReadValue<Vector2>().x;
|
||||
}
|
||||
|
||||
public bool IsActionPressed()
|
||||
{
|
||||
return _input.Player.Interact.triggered;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_input.Player.Disable();
|
||||
_input?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user