Add initial game systems and input handling for player interactions

This commit is contained in:
2025-12-09 22:20:38 +01:00
commit 5e0db113aa
182 changed files with 70557 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
using System;
using Abstractions;
using UnityEngine;
namespace Presentation
{
public class ElfController : MonoBehaviour
{
[Header("Movement")] [SerializeField] private float moveSpeed = 10f;
[Header("Cane mechanics")] [SerializeField]
private Transform canePivot;
[SerializeField] private float maxTiltAngle = 30f;
[SerializeField] private float tiltSpeed = 15f;
private IInputService _inputService;
public void Configure(IInputService inputService)
{
_inputService = inputService;
}
private void Update()
{
if (_inputService == null) return;
var move = _inputService.GetHorizontalMovement();
transform.Translate(Vector3.right * (move * moveSpeed * Time.deltaTime));
HandleCaneRotation(move);
}
private void HandleCaneRotation(float inputDirection)
{
var targetAngle = 0f;
if (inputDirection > 0.1f)
{
targetAngle = -maxTiltAngle;
}
else if (inputDirection < -0.1f)
{
targetAngle = maxTiltAngle;
}
else
{
targetAngle = 0f;
}
var targetRotation = Quaternion.Euler(0f, 0f, targetAngle);
canePivot.localRotation = Quaternion.Lerp(
canePivot.localRotation,
targetRotation,
Time.deltaTime * tiltSpeed
);
}
}
}