Add a semi-finished booster opening sequence
This commit is contained in:
@@ -16,8 +16,11 @@ namespace UI.CardSystem.DragDrop
|
||||
[Header("Tap to Open")]
|
||||
[SerializeField] private bool canTapToOpen = true;
|
||||
[SerializeField] private int maxTapsToOpen = 3;
|
||||
[SerializeField] private float tapPulseScale = 1.15f;
|
||||
[SerializeField] private float tapPulseDuration = 0.2f;
|
||||
[SerializeField] private ParticleSystem openingParticleSystem;
|
||||
|
||||
// Events
|
||||
// ...existing code...
|
||||
public event System.Action<BoosterPackDraggable> OnBoosterOpened;
|
||||
public event System.Action<BoosterPackDraggable, int, int> OnTapped; // (booster, currentTap, maxTaps)
|
||||
public event System.Action<BoosterPackDraggable> OnReadyToOpen; // Final tap reached
|
||||
@@ -33,11 +36,30 @@ namespace UI.CardSystem.DragDrop
|
||||
{
|
||||
base.OnPointerUpHook(longPress);
|
||||
|
||||
// Handle tap-to-open logic (only when in slot and not dragged)
|
||||
if (canTapToOpen && !_wasDragged && !longPress && CurrentSlot != null)
|
||||
// Handle tap-to-open logic (only when in slot and not a long press)
|
||||
if (canTapToOpen && !longPress && CurrentSlot != null)
|
||||
{
|
||||
_currentTapCount++;
|
||||
|
||||
// Pulse effect on tap (scales visual up and back down)
|
||||
if (Visual != null)
|
||||
{
|
||||
// Calculate pulse intensity based on tap progress
|
||||
float tapProgress = _currentTapCount / (float)maxTapsToOpen;
|
||||
float currentPulseScale = 1f + (tapPulseScale - 1f) * (0.5f + tapProgress * 0.5f); // Increases from 1.075 to 1.15
|
||||
|
||||
// Save the current scale before pulsing
|
||||
Vector3 baseScale = Visual.transform.localScale;
|
||||
|
||||
Pixelplacement.Tween.Cancel(Visual.transform.GetInstanceID());
|
||||
Pixelplacement.Tween.LocalScale(Visual.transform, baseScale * currentPulseScale, tapPulseDuration * 0.5f, 0f,
|
||||
Pixelplacement.Tween.EaseOutBack, completeCallback: () =>
|
||||
{
|
||||
// Return to the base scale we had before pulsing
|
||||
Pixelplacement.Tween.LocalScale(Visual.transform, baseScale, tapPulseDuration * 0.5f, 0f, Pixelplacement.Tween.EaseInBack);
|
||||
});
|
||||
}
|
||||
|
||||
OnTapped?.Invoke(this, _currentTapCount, maxTapsToOpen);
|
||||
|
||||
if (_currentTapCount >= maxTapsToOpen)
|
||||
@@ -48,8 +70,8 @@ namespace UI.CardSystem.DragDrop
|
||||
return; // Don't process double-click if tap-to-open is active
|
||||
}
|
||||
|
||||
// Check for double click
|
||||
if (canOpenOnDoubleClick && !longPress && !_wasDragged)
|
||||
// ...existing code...
|
||||
if (canOpenOnDoubleClick && !longPress)
|
||||
{
|
||||
float timeSinceLastClick = Time.time - _lastClickTime;
|
||||
|
||||
@@ -84,6 +106,12 @@ namespace UI.CardSystem.DragDrop
|
||||
|
||||
_isOpening = true;
|
||||
|
||||
// Play particle effect
|
||||
if (openingParticleSystem != null)
|
||||
{
|
||||
openingParticleSystem.Play();
|
||||
}
|
||||
|
||||
OnBoosterOpened?.Invoke(this);
|
||||
|
||||
// The actual opening logic (calling CardSystemManager) should be handled
|
||||
@@ -98,8 +126,27 @@ namespace UI.CardSystem.DragDrop
|
||||
public void ResetOpeningState()
|
||||
{
|
||||
_isOpening = false;
|
||||
_currentTapCount = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether this booster is in the opening slot (disables dragging, enables tapping)
|
||||
/// </summary>
|
||||
public void SetInOpeningSlot(bool inSlot)
|
||||
{
|
||||
SetDraggingEnabled(!inSlot); // Disable dragging when in opening slot
|
||||
canTapToOpen = inSlot; // Enable tap-to-open when in opening slot
|
||||
|
||||
if (inSlot)
|
||||
{
|
||||
_currentTapCount = 0; // Reset tap counter when placed
|
||||
}
|
||||
else
|
||||
{
|
||||
ResetOpeningState(); // Reset completely when removed
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset tap count (useful when starting a new opening sequence)
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user