First MVP of sorting minigame (#60)
Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Co-authored-by: Michal Pikulski <michal@foolhardyhorizons.com> Reviewed-on: #60
This commit is contained in:
@@ -631,6 +631,25 @@ namespace Data.CardSystem
|
||||
return _pendingRevealCards.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a random card definition of the specified rarity.
|
||||
/// Used by minigames to spawn cards without affecting player's collection.
|
||||
/// </summary>
|
||||
public CardDefinition GetRandomCardDefinitionByRarity(CardRarity targetRarity)
|
||||
{
|
||||
// Filter available cards by rarity
|
||||
var matchingCards = availableCards.Where(c => c.Rarity == targetRarity).ToList();
|
||||
|
||||
if (matchingCards.Count == 0)
|
||||
{
|
||||
Debug.LogWarning($"[CardSystemManager] No card definitions found for rarity {targetRarity}");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return random card from matching rarity
|
||||
return matchingCards[UnityEngine.Random.Range(0, matchingCards.Count)];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -401,6 +401,56 @@ namespace UI.CardSystem.StateMachine
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Color/Tint Animations
|
||||
|
||||
private TweenBase _activeBlinkTween;
|
||||
private Color _originalColor;
|
||||
|
||||
/// <summary>
|
||||
/// Blink an image red repeatedly (for fell-off-conveyor state)
|
||||
/// </summary>
|
||||
public void BlinkRed(UnityEngine.UI.Image image, float blinkSpeed = 0.25f)
|
||||
{
|
||||
if (image == null) return;
|
||||
|
||||
// Stop any existing blink
|
||||
StopBlinking();
|
||||
|
||||
// Store original color
|
||||
_originalColor = image.color;
|
||||
|
||||
// Start blinking red loop
|
||||
BlinkLoop(image, blinkSpeed);
|
||||
}
|
||||
|
||||
private void BlinkLoop(UnityEngine.UI.Image image, float blinkSpeed)
|
||||
{
|
||||
if (image == null) return;
|
||||
|
||||
// Tween to red
|
||||
_activeBlinkTween = Tween.Color(image, Color.red, blinkSpeed, 0f, Tween.EaseInOut,
|
||||
completeCallback: () =>
|
||||
{
|
||||
// Tween back to original
|
||||
_activeBlinkTween = Tween.Color(image, _originalColor, blinkSpeed, 0f, Tween.EaseInOut,
|
||||
completeCallback: () => BlinkLoop(image, blinkSpeed)); // Loop
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop blinking animation and restore original color
|
||||
/// </summary>
|
||||
public void StopBlinking()
|
||||
{
|
||||
if (_activeBlinkTween != null)
|
||||
{
|
||||
_activeBlinkTween.Stop();
|
||||
_activeBlinkTween = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user