修复技能输入并更新战斗资源
This commit is contained in:
@@ -90,6 +90,7 @@ namespace XGame.VirtualInput
|
||||
private float pointerDownTime;
|
||||
private bool holdStarted;
|
||||
private float nextHoldTickTime;
|
||||
private Vector2 pointerDownScreenPosition;
|
||||
private Vector2 lastScreenPosition;
|
||||
private ActionButtonEvent lastDragEvent;
|
||||
|
||||
@@ -278,6 +279,7 @@ namespace XGame.VirtualInput
|
||||
pointerDownTime = now;
|
||||
nextHoldTickTime = now + holdThresholdSeconds + holdTickIntervalSeconds;
|
||||
holdStarted = false;
|
||||
pointerDownScreenPosition = screenPosition;
|
||||
lastScreenPosition = screenPosition;
|
||||
lastDragEvent = MakeEvent(ActionButtonPhase.Down, screenPosition, pointerId, now);
|
||||
SetAimVisible(false);
|
||||
@@ -344,9 +346,9 @@ namespace XGame.VirtualInput
|
||||
return ActionButtonPhase.Cancel;
|
||||
}
|
||||
|
||||
return MakeEvent(ActionButtonPhase.Release, screenPosition, activePointerId, Time.unscaledTime).Distance01 >= releaseDistanceThreshold01
|
||||
? ActionButtonPhase.Release
|
||||
: ActionButtonPhase.Tap;
|
||||
return IsInsideButton(screenPosition) && !HasMeaningfulDrag(screenPosition)
|
||||
? ActionButtonPhase.Tap
|
||||
: ActionButtonPhase.Release;
|
||||
}
|
||||
|
||||
private ActionButtonEvent MakeEvent(ActionButtonPhase phase, Vector2 screenPosition, int pointerId, float now)
|
||||
@@ -378,6 +380,18 @@ namespace XGame.VirtualInput
|
||||
return RectTransformUtility.RectangleContainsScreenPoint(cancelArea, screenPosition, GetUICamera(cancelArea));
|
||||
}
|
||||
|
||||
private bool IsInsideButton(Vector2 screenPosition)
|
||||
{
|
||||
RectTransform rect = rectTransform != null ? rectTransform : transform as RectTransform;
|
||||
return rect != null && RectTransformUtility.RectangleContainsScreenPoint(rect, screenPosition, GetUICamera(rect));
|
||||
}
|
||||
|
||||
private bool HasMeaningfulDrag(Vector2 screenPosition)
|
||||
{
|
||||
float threshold = GetScreenRadius() * maxDragRadiusMultiplier * releaseDistanceThreshold01;
|
||||
return (screenPosition - pointerDownScreenPosition).magnitude >= Mathf.Max(1f, threshold);
|
||||
}
|
||||
|
||||
private void RefreshVisuals()
|
||||
{
|
||||
bool interactable = IsInteractable;
|
||||
@@ -424,6 +438,7 @@ namespace XGame.VirtualInput
|
||||
pointerDown = false;
|
||||
activePointerId = int.MinValue;
|
||||
holdStarted = false;
|
||||
pointerDownScreenPosition = Vector2.zero;
|
||||
lastScreenPosition = Vector2.zero;
|
||||
lastDragEvent = default;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user