add project files

This commit is contained in:
Boris Nikolaev
2026-08-14 01:58:31 +03:00
parent 9134cad79b
commit 5f1e94b653
4399 changed files with 12286903 additions and 0 deletions
+100
View File
@@ -0,0 +1,100 @@
using UnityEngine;
using OHM.UnityToolkit;
using UnityEngine.Serialization;
public class InputController : MonoBehaviour
{
[SerializeField]
[FormerlySerializedAs("core")]
private CoreController _core;
private bool _downValid;
private Vector2 GetTouchPos()
{
if (Input.touchCount >= 1)
{
return Input.GetTouch(0).position;
}
#if UNITY_EDITOR || UNITY_STANDALONE
return Input.mousePosition;
#else
return Vector2.zero;
#endif
}
private bool TouchDown()
{
if (Input.touchCount >= 1)
{
return Input.GetTouch(0).phase == TouchPhase.Began;
}
#if UNITY_EDITOR || UNITY_STANDALONE
return Input.GetMouseButtonDown(0);
#else
return false;
#endif
}
private bool TouchHold()
{
if (Input.touchCount >= 1)
{
TouchPhase phase = Input.GetTouch(0).phase;
return phase == TouchPhase.Moved || phase == TouchPhase.Stationary;
}
#if UNITY_EDITOR || UNITY_STANDALONE
return Input.GetMouseButton(0);
#else
return false;
#endif
}
private bool TouchUp()
{
if (Input.touchCount >= 1)
{
return Input.GetTouch(0).phase == TouchPhase.Ended;
}
#if UNITY_EDITOR || UNITY_STANDALONE
return Input.GetMouseButtonUp(0);
#else
return false;
#endif
}
private void Update()
{
Vector2 touchPos = GetTouchPos();
if (!UIUtils.IsInputBlocked(touchPos) && TouchDown())
{
IInputsListener listener = _core.GetCurrentInputsListener();
if (listener != null)
{
listener.InputDown(touchPos);
}
_downValid = true;
}
else if (_downValid)
{
if (TouchHold())
{
IInputsListener listener2 = _core.GetCurrentInputsListener();
if (listener2 != null)
{
listener2.InputMove(touchPos);
}
}
else if (TouchUp())
{
_downValid = false;
IInputsListener listener3 = _core.GetCurrentInputsListener();
if (listener3 != null)
{
listener3.InputUp();
}
}
}
}
}