Add initial game systems and input handling for player interactions
This commit is contained in:
8
Assets/Scripts/Infrastructure/IPersistenceService.cs
Normal file
8
Assets/Scripts/Infrastructure/IPersistenceService.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Infrastructure
|
||||
{
|
||||
public interface IPersistenceService
|
||||
{
|
||||
void SaveHighScore(string key, int score);
|
||||
int LoadHighScore(string key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78982eb5342e49b5aa23fe22e84d4da8
|
||||
timeCreated: 1765312139
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Infrastructure/PlayerOneInput.cs.meta
Normal file
3
Assets/Scripts/Infrastructure/PlayerOneInput.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb373e773ac5427087b07b63c9accc90
|
||||
timeCreated: 1765308257
|
||||
18
Assets/Scripts/Infrastructure/PlayerPrefsPersistence.cs
Normal file
18
Assets/Scripts/Infrastructure/PlayerPrefsPersistence.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Infrastructure
|
||||
{
|
||||
public class PlayerPrefsPersistence : IPersistenceService
|
||||
{
|
||||
public void SaveHighScore(string key, int score)
|
||||
{
|
||||
PlayerPrefs.SetInt(key, score);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
public int LoadHighScore(string key)
|
||||
{
|
||||
return PlayerPrefs.GetInt(key, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fed5bb3ae38d41dc9cc89464b1c611e9
|
||||
timeCreated: 1765312168
|
||||
23
Assets/Scripts/Infrastructure/PlayerTwoInput.cs
Normal file
23
Assets/Scripts/Infrastructure/PlayerTwoInput.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using Abstractions;
|
||||
|
||||
namespace Infrastructure
|
||||
{
|
||||
public class PlayerTwoInput : IInputService, IDisposable
|
||||
{
|
||||
public float GetHorizontalMovement()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsActionPressed()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Infrastructure/PlayerTwoInput.cs.meta
Normal file
3
Assets/Scripts/Infrastructure/PlayerTwoInput.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8e90fd115b7440b9ccff749d09b6bcd
|
||||
timeCreated: 1765308287
|
||||
Reference in New Issue
Block a user