add unity project
add SOLID examples
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DefaultNamespace.Solid
|
||||
{
|
||||
public class PlayerInput : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float _speed = 10.0f;
|
||||
[SerializeField] private float _rotationSpeed = 60.0f;
|
||||
|
||||
public Vector3 Movement { get; private set; }
|
||||
public float Rotation { get; private set; }
|
||||
|
||||
public event Action IsFired;
|
||||
|
||||
public void HandleInput()
|
||||
{
|
||||
Movement = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
|
||||
Movement *= _speed * Time.deltaTime;
|
||||
|
||||
Rotation = Input.GetAxis("Mouse X") * _rotationSpeed * Time.deltaTime;
|
||||
|
||||
if (Input.GetButtonDown("Fire1"))
|
||||
{
|
||||
IsFired?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user