Updates to testing scene
This commit is contained in:
@@ -17,6 +17,7 @@ namespace UI.CardSystem.StateMachine
|
||||
private Transform _transform;
|
||||
private RectTransform _rectTransform;
|
||||
private ICardSystemSettings _settings;
|
||||
private TweenBase _activeIdleHoverTween;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -257,16 +258,31 @@ namespace UI.CardSystem.StateMachine
|
||||
|
||||
/// <summary>
|
||||
/// Idle hover animation (gentle bobbing loop)
|
||||
/// Returns the TweenBase so caller can stop it later
|
||||
/// Returns the TweenBase so caller can stop it later.
|
||||
/// Only starts if not already running, or kills and restarts.
|
||||
/// </summary>
|
||||
public TweenBase StartIdleHover(float hoverHeight = 10f, float duration = 1.5f)
|
||||
public TweenBase StartIdleHover(float hoverHeight = 10f, float duration = 1.5f, bool restartIfActive = false)
|
||||
{
|
||||
// If already running, either skip or restart
|
||||
if (_activeIdleHoverTween != null)
|
||||
{
|
||||
if (!restartIfActive)
|
||||
{
|
||||
// Already running, skip
|
||||
return _activeIdleHoverTween;
|
||||
}
|
||||
|
||||
// Kill existing and restart
|
||||
_activeIdleHoverTween.Stop();
|
||||
_activeIdleHoverTween = null;
|
||||
}
|
||||
|
||||
if (_rectTransform != null)
|
||||
{
|
||||
Vector2 originalPos = _rectTransform.anchoredPosition;
|
||||
Vector2 targetPos = originalPos + Vector2.up * hoverHeight;
|
||||
|
||||
return Tween.Value(0f, 1f,
|
||||
_activeIdleHoverTween = Tween.Value(0f, 1f,
|
||||
(val) =>
|
||||
{
|
||||
if (_rectTransform != null)
|
||||
@@ -276,11 +292,32 @@ namespace UI.CardSystem.StateMachine
|
||||
}
|
||||
},
|
||||
duration, 0f, Tween.EaseInOut, Tween.LoopType.Loop);
|
||||
|
||||
return _activeIdleHoverTween;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop idle hover animation and return to original position
|
||||
/// </summary>
|
||||
public void StopIdleHover(Vector2 originalPosition, float duration = 0.3f)
|
||||
{
|
||||
// Stop the tracked tween if it exists
|
||||
if (_activeIdleHoverTween != null)
|
||||
{
|
||||
_activeIdleHoverTween.Stop();
|
||||
_activeIdleHoverTween = null;
|
||||
}
|
||||
|
||||
// Return to original position
|
||||
if (_rectTransform != null)
|
||||
{
|
||||
Tween.AnchoredPosition(_rectTransform, originalPosition, duration, 0f, Tween.EaseInOut);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Flip Animations (Two-Phase)
|
||||
|
||||
Reference in New Issue
Block a user