Big Input refactor
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Handles endless descender movement in response to tap and hold input events.
|
||||
/// Moves the character horizontally to follow the finger or tap position.
|
||||
/// </summary>
|
||||
public class EndlessDescenderController : MonoBehaviour, ITouchInputConsumer
|
||||
{
|
||||
private float targetFingerX;
|
||||
@@ -20,45 +24,41 @@ public class EndlessDescenderController : MonoBehaviour, ITouchInputConsumer
|
||||
isTouchActive = false;
|
||||
}
|
||||
|
||||
// Implement new ITouchInputConsumer contract
|
||||
/// <summary>
|
||||
/// Handles tap input. Moves to the tapped X position.
|
||||
/// </summary>
|
||||
public void OnTap(Vector2 worldPosition)
|
||||
{
|
||||
// Treat tap as a quick move to the tapped X position
|
||||
Debug.Log($"[EndlessDescenderController] OnTap at {worldPosition}");
|
||||
targetFingerX = Mathf.Clamp(worldPosition.x, GameManager.Instance.EndlessDescenderClampXMin, GameManager.Instance.EndlessDescenderClampXMax);
|
||||
isTouchActive = true;
|
||||
}
|
||||
|
||||
public void OnDragStart(Vector2 position)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public void OnDrag(Vector2 position)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public void OnDragEnd(Vector2 position)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the start of a hold input. Begins tracking the finger.
|
||||
/// </summary>
|
||||
public void OnHoldStart(Vector2 worldPosition)
|
||||
{
|
||||
// Start hold, update target X
|
||||
Debug.Log($"[EndlessDescenderController] OnHoldStart at {worldPosition}");
|
||||
targetFingerX = Mathf.Clamp(worldPosition.x, GameManager.Instance.EndlessDescenderClampXMin, GameManager.Instance.EndlessDescenderClampXMax);
|
||||
isTouchActive = true;
|
||||
}
|
||||
|
||||
public void OnHold(Vector2 worldPosition)
|
||||
/// <summary>
|
||||
/// Handles hold move input. Updates the target X position as the finger moves.
|
||||
/// </summary>
|
||||
public void OnHoldMove(Vector2 worldPosition)
|
||||
{
|
||||
// Update target x as finger moves
|
||||
Debug.Log($"[EndlessDescenderController] OnHoldMove at {worldPosition}");
|
||||
targetFingerX = Mathf.Clamp(worldPosition.x, GameManager.Instance.EndlessDescenderClampXMin, GameManager.Instance.EndlessDescenderClampXMax);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the end of a hold input. Stops tracking.
|
||||
/// </summary>
|
||||
public void OnHoldEnd(Vector2 worldPosition)
|
||||
{
|
||||
// Stop hold
|
||||
Debug.Log($"[EndlessDescenderController] OnHoldEnd at {worldPosition}");
|
||||
isTouchActive = false;
|
||||
}
|
||||
|
||||
@@ -87,9 +87,5 @@ public class EndlessDescenderController : MonoBehaviour, ITouchInputConsumer
|
||||
newY += wobble.VerticalOffset;
|
||||
}
|
||||
transform.position = new Vector3(newX, newY, transform.position.z);
|
||||
// Debug.Log($"EndlessDescenderController: Moved from {oldPos} to {transform.position} (targetX={targetX}, lerpSpeed={lerpSpeed}, offset={offset}, exponent={exponent}, moveStep={moveStep})");
|
||||
}
|
||||
|
||||
// Optionally, handle touch release if needed
|
||||
// You can add a method to reset isTouchActive if desired
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user