More snappy tap animation

This commit is contained in:
Michal Pikulski
2025-11-06 18:43:06 +01:00
parent a9b9fb87b5
commit d01859cec0
9 changed files with 397 additions and 47 deletions

View File

@@ -1,4 +1,5 @@
using Pixelplacement;
using Pixelplacement.TweenSystem;
using UI.DragAndDrop.Core;
using UnityEngine;
using UnityEngine.UI;
@@ -24,6 +25,10 @@ namespace UI.CardSystem.DragDrop
private BoosterPackDraggable _boosterDraggable;
// Effect tracking
private int _glowRotationTweenId = -1;
private float _defaultGlowRate = 10f;
public override void Initialize(DraggableObject parent)
{
base.Initialize(parent);
@@ -58,8 +63,8 @@ namespace UI.CardSystem.DragDrop
protected override void UpdateVisualContent()
{
// Update glow rotation for visual interest
if (glowTransform != null)
// Update glow rotation for visual interest (skip if effects suppressed)
if (glowTransform != null && !_effectsSuppressed)
{
glowTransform.Rotate(Vector3.forward * 30f * Time.deltaTime);
}
@@ -77,6 +82,7 @@ namespace UI.CardSystem.DragDrop
/// <summary>
/// Play progressive shake animation based on tap intensity
/// This is always allowed, even when effects are suppressed
/// </summary>
public void PlayShakeAnimation(int intensity, int maxIntensity)
{
@@ -98,17 +104,11 @@ namespace UI.CardSystem.DragDrop
shakeDuration, 0f, Tween.EaseInBack);
});
// Scale punch (gets bigger with each tap)
float punchScale = 1f + (normalizedIntensity * 0.2f);
Tween.LocalScale(transform, Vector3.one * punchScale,
shakeDuration / 2f, 0f, Tween.EaseOutBack,
completeCallback: () => {
Tween.LocalScale(transform, Vector3.one,
shakeDuration / 2f, 0f, Tween.EaseInBack);
});
// NOTE: Scale pulse is handled by BoosterPackDraggable.OnPointerUpHook()
// We don't need a duplicate scale tween here - it would conflict!
// Extra glow burst on final tap
if (intensity == maxIntensity && glowEffect != null)
// Extra glow burst on final tap (only if effects not suppressed)
if (intensity == maxIntensity && glowEffect != null && !_effectsSuppressed)
{
var emission = glowEffect.emission;
emission.rateOverTimeMultiplier = 50f;
@@ -155,8 +155,8 @@ namespace UI.CardSystem.DragDrop
{
base.OnPointerEnterVisual();
// Extra glow when hovering
if (glowEffect != null)
// Extra glow when hovering (skip if effects suppressed)
if (glowEffect != null && !_effectsSuppressed)
{
var emission = glowEffect.emission;
emission.rateOverTimeMultiplier = 20f;
@@ -167,14 +167,141 @@ namespace UI.CardSystem.DragDrop
{
base.OnPointerExitVisual();
// Restore normal glow
if (glowEffect != null)
// Restore normal glow (skip if effects suppressed)
if (glowEffect != null && !_effectsSuppressed)
{
var emission = glowEffect.emission;
emission.rateOverTimeMultiplier = 10f;
emission.rateOverTimeMultiplier = _defaultGlowRate;
}
}
#region Effect Management Overrides
protected override void OnEffectsSuppressed()
{
base.OnEffectsSuppressed();
// Stop glow effect
if (glowEffect != null)
{
glowEffect.Stop();
}
// Cancel glow rotation tween if tracked
if (_glowRotationTweenId != -1)
{
Tween.Stop(_glowRotationTweenId);
_glowRotationTweenId = -1;
}
// Reset glow rotation to zero
if (glowTransform != null)
{
glowTransform.localRotation = Quaternion.identity;
}
}
protected override void OnEffectsResumed()
{
base.OnEffectsResumed();
// Resume glow effect
if (glowEffect != null && !glowEffect.isPlaying)
{
glowEffect.Play();
}
}
protected override void OnEffectsReset()
{
base.OnEffectsReset();
// Stop glow effect
if (glowEffect != null)
{
glowEffect.Stop();
}
// Reset glow rotation
if (glowTransform != null)
{
glowTransform.localRotation = Quaternion.identity;
}
// NOTE: Tap pulse scale is handled by BoosterPackDraggable, not here
}
#endregion
#region Event Handler Overrides (Block when in Opening Slot)
protected override void HandleDragStarted(DraggableObject draggable)
{
// Don't call base if effects are suppressed (in opening slot)
if (_effectsSuppressed)
return;
base.HandleDragStarted(draggable);
}
protected override void HandleDragEnded(DraggableObject draggable)
{
// Don't call base if effects are suppressed (in opening slot)
if (_effectsSuppressed)
return;
base.HandleDragEnded(draggable);
}
protected override void HandlePointerEnter(DraggableObject draggable)
{
// Don't call base if effects are suppressed (in opening slot)
if (_effectsSuppressed)
return;
base.HandlePointerEnter(draggable);
}
protected override void HandlePointerExit(DraggableObject draggable)
{
// Don't call base if effects are suppressed (in opening slot)
if (_effectsSuppressed)
return;
base.HandlePointerExit(draggable);
}
protected override void HandlePointerDown(DraggableObject draggable)
{
// Don't call base if effects are suppressed (in opening slot)
// This allows the BoosterPackDraggable to handle tap pulse itself
if (_effectsSuppressed)
return;
base.HandlePointerDown(draggable);
}
protected override void HandlePointerUp(DraggableObject draggable, bool longPress)
{
// Don't call base if effects are suppressed (in opening slot)
// This allows the BoosterPackDraggable to handle tap pulse itself
if (_effectsSuppressed)
return;
base.HandlePointerUp(draggable, longPress);
}
protected override void HandleSelection(DraggableObject draggable, bool selected)
{
// Don't call base if effects are suppressed (in opening slot)
if (_effectsSuppressed)
return;
base.HandleSelection(draggable, selected);
}
#endregion
protected override void OnDestroy()
{
base.OnDestroy();