refactor: made the input reader expandable

This commit is contained in:
Gerard Gascón 2024-04-14 18:50:25 +02:00
parent 12304c6bb4
commit 59a3d96b5b
10 changed files with 72 additions and 24 deletions

View file

@ -1,4 +1,5 @@
using Domain;
using Domain.Input;
using Presenter;
using TMPro;
using UnityEngine;
@ -7,9 +8,11 @@ namespace View {
public class CTrencadaInput : MonoBehaviour, ICTrencadaInput {
[SerializeField] private TMP_Text text;
private CTrencadaClick _click;
private CustomInput _customInput;
private void Start() {
_click = FindObjectOfType<Dependencies>().CTrencadaClick;
_customInput = FindObjectOfType<Dependencies>().CustomInput;
}
private void Update() {
@ -17,8 +20,8 @@ namespace View {
}
private void CheckInput() {
Win32API.UpdateInput();
if (Win32API.CTrencadaDown())
_customInput.UpdateInput();
if (_customInput.KeyDown(typeof(CedillaReader)))
_click.Execute();
}

View file

@ -7,12 +7,15 @@ namespace View {
public class Dependencies : MonoBehaviour {
public CTrencadaClick CTrencadaClick { private set; get; }
public Model Model { private set; get; }
public CustomInput CustomInput { private set; get; }
private void Awake() {
Model = new Model(0);
ICTrencadaInput input = FindObjectOfType<CTrencadaInput>();
CTrencadaClick = new CTrencadaClick(Model, input);
CustomInput = new CustomInput();
}
}
}