Make cards use settings
This commit is contained in:
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddd745ae12984de9974292d201c89d9c
|
||||
timeCreated: 1762884650
|
||||
@@ -2,6 +2,8 @@
|
||||
using Pixelplacement.TweenSystem;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using AppleHills.Core.Settings;
|
||||
using Core;
|
||||
|
||||
namespace UI.CardSystem.StateMachine
|
||||
{
|
||||
@@ -12,16 +14,15 @@ namespace UI.CardSystem.StateMachine
|
||||
/// </summary>
|
||||
public class CardAnimator : MonoBehaviour
|
||||
{
|
||||
[Header("Animation Settings")]
|
||||
[SerializeField] private float defaultDuration = 0.3f;
|
||||
|
||||
private Transform _transform;
|
||||
private RectTransform _rectTransform;
|
||||
private ICardSystemSettings _settings;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_transform = transform;
|
||||
_rectTransform = GetComponent<RectTransform>();
|
||||
_settings = GameManager.GetSettingsObject<ICardSystemSettings>();
|
||||
}
|
||||
|
||||
#region Scale Animations
|
||||
@@ -31,7 +32,7 @@ namespace UI.CardSystem.StateMachine
|
||||
/// </summary>
|
||||
public TweenBase AnimateScale(Vector3 targetScale, float? duration = null, Action onComplete = null)
|
||||
{
|
||||
return Tween.LocalScale(_transform, targetScale, duration ?? defaultDuration, 0f,
|
||||
return Tween.LocalScale(_transform, targetScale, duration ?? _settings.DefaultAnimationDuration, 0f,
|
||||
Tween.EaseInOut, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ namespace UI.CardSystem.StateMachine
|
||||
return null;
|
||||
}
|
||||
|
||||
return Tween.AnchoredPosition(_rectTransform, targetPosition, duration ?? defaultDuration, 0f,
|
||||
return Tween.AnchoredPosition(_rectTransform, targetPosition, duration ?? _settings.DefaultAnimationDuration, 0f,
|
||||
Tween.EaseInOut, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
@@ -94,7 +95,7 @@ namespace UI.CardSystem.StateMachine
|
||||
/// </summary>
|
||||
public TweenBase AnimateLocalPosition(Vector3 targetPosition, float? duration = null, Action onComplete = null)
|
||||
{
|
||||
return Tween.LocalPosition(_transform, targetPosition, duration ?? defaultDuration, 0f,
|
||||
return Tween.LocalPosition(_transform, targetPosition, duration ?? _settings.DefaultAnimationDuration, 0f,
|
||||
Tween.EaseInOut, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ namespace UI.CardSystem.StateMachine
|
||||
/// </summary>
|
||||
public TweenBase AnimateLocalRotation(Quaternion targetRotation, float? duration = null, Action onComplete = null)
|
||||
{
|
||||
return Tween.LocalRotation(_transform, targetRotation, duration ?? defaultDuration, 0f,
|
||||
return Tween.LocalRotation(_transform, targetRotation, duration ?? _settings.DefaultAnimationDuration, 0f,
|
||||
Tween.EaseInOut, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
@@ -129,17 +130,19 @@ namespace UI.CardSystem.StateMachine
|
||||
/// Play card flip animation - rotates card back from 0° to 90°, then card front from 180° to 0°
|
||||
/// Based on FlippableCard.FlipToReveal()
|
||||
/// </summary>
|
||||
public void PlayFlip(Transform cardBack, Transform cardFront, float duration = 0.6f, Action onComplete = null)
|
||||
public void PlayFlip(Transform cardBack, Transform cardFront, float? duration = null, Action onComplete = null)
|
||||
{
|
||||
float flipDuration = duration ?? _settings.FlipDuration;
|
||||
|
||||
// Phase 1: Rotate both to 90 degrees (edge view)
|
||||
if (cardBack != null)
|
||||
{
|
||||
Tween.LocalRotation(cardBack, Quaternion.Euler(0, 90, 0), duration * 0.5f, 0f, Tween.EaseInOut);
|
||||
Tween.LocalRotation(cardBack, Quaternion.Euler(0, 90, 0), flipDuration * 0.5f, 0f, Tween.EaseInOut);
|
||||
}
|
||||
|
||||
if (cardFront != null)
|
||||
{
|
||||
Tween.LocalRotation(cardFront, Quaternion.Euler(0, 90, 0), duration * 0.5f, 0f, Tween.EaseInOut,
|
||||
Tween.LocalRotation(cardFront, Quaternion.Euler(0, 90, 0), flipDuration * 0.5f, 0f, Tween.EaseInOut,
|
||||
completeCallback: () =>
|
||||
{
|
||||
// At edge (90°), switch visibility
|
||||
@@ -149,7 +152,7 @@ namespace UI.CardSystem.StateMachine
|
||||
cardFront.gameObject.SetActive(true);
|
||||
|
||||
// Phase 2: Rotate front from 90 to 0 (show at correct orientation)
|
||||
Tween.LocalRotation(cardFront, Quaternion.Euler(0, 0, 0), duration * 0.5f, 0f, Tween.EaseInOut,
|
||||
Tween.LocalRotation(cardFront, Quaternion.Euler(0, 0, 0), flipDuration * 0.5f, 0f, Tween.EaseInOut,
|
||||
completeCallback: onComplete);
|
||||
});
|
||||
}
|
||||
@@ -159,14 +162,16 @@ namespace UI.CardSystem.StateMachine
|
||||
/// Play scale punch during flip animation for extra juice
|
||||
/// Based on FlippableCard.FlipToReveal()
|
||||
/// </summary>
|
||||
public void PlayFlipScalePunch(float punchScale = 1.1f, float duration = 0.6f)
|
||||
public void PlayFlipScalePunch(float? punchScale = null, float? duration = null)
|
||||
{
|
||||
float punch = punchScale ?? _settings.FlipScalePunch;
|
||||
float flipDuration = duration ?? _settings.FlipDuration;
|
||||
Vector3 originalScale = _transform.localScale;
|
||||
|
||||
Tween.LocalScale(_transform, originalScale * punchScale, duration * 0.5f, 0f, Tween.EaseOutBack,
|
||||
Tween.LocalScale(_transform, originalScale * punch, flipDuration * 0.5f, 0f, Tween.EaseOutBack,
|
||||
completeCallback: () =>
|
||||
{
|
||||
Tween.LocalScale(_transform, originalScale, duration * 0.5f, 0f, Tween.EaseInBack);
|
||||
Tween.LocalScale(_transform, originalScale, flipDuration * 0.5f, 0f, Tween.EaseInBack);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -178,9 +183,12 @@ namespace UI.CardSystem.StateMachine
|
||||
/// Enlarge card to specified scale
|
||||
/// Based on FlippableCard.EnlargeCard() and AlbumCard.EnlargeCard()
|
||||
/// </summary>
|
||||
public void PlayEnlarge(float targetScale = 2.5f, float duration = 0.3f, Action onComplete = null)
|
||||
public void PlayEnlarge(float? targetScale = null, float? duration = null, Action onComplete = null)
|
||||
{
|
||||
Tween.LocalScale(_transform, Vector3.one * targetScale, duration, 0f, Tween.EaseOutBack,
|
||||
float scale = targetScale ?? _settings.NewCardEnlargedScale;
|
||||
float scaleDuration = duration ?? _settings.ScaleDuration;
|
||||
|
||||
Tween.LocalScale(_transform, Vector3.one * scale, scaleDuration, 0f, Tween.EaseOutBack,
|
||||
completeCallback: onComplete);
|
||||
}
|
||||
|
||||
@@ -188,9 +196,11 @@ namespace UI.CardSystem.StateMachine
|
||||
/// Shrink card back to original scale
|
||||
/// Based on AlbumCard.ShrinkCard() and FlippableCard.ReturnToNormalSize()
|
||||
/// </summary>
|
||||
public void PlayShrink(Vector3 targetScale, float duration = 0.3f, Action onComplete = null)
|
||||
public void PlayShrink(Vector3 targetScale, float? duration = null, Action onComplete = null)
|
||||
{
|
||||
Tween.LocalScale(_transform, targetScale, duration, 0f, Tween.EaseInBack,
|
||||
float scaleDuration = duration ?? _settings.ScaleDuration;
|
||||
|
||||
Tween.LocalScale(_transform, targetScale, scaleDuration, 0f, Tween.EaseInBack,
|
||||
completeCallback: onComplete);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UI.CardSystem.StateMachine;
|
||||
using AppleHills.Core.Settings;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
@@ -13,6 +13,7 @@ namespace UI.CardSystem.StateMachine.States
|
||||
public class CardAlbumEnlargedState : AppleState, IPointerClickHandler
|
||||
{
|
||||
private CardContext _context;
|
||||
private ICardSystemSettings _settings;
|
||||
private Vector3 _originalScale;
|
||||
private Transform _originalParent;
|
||||
private Vector3 _originalLocalPosition;
|
||||
@@ -25,6 +26,7 @@ namespace UI.CardSystem.StateMachine.States
|
||||
private void Awake()
|
||||
{
|
||||
_context = GetComponentInParent<CardContext>();
|
||||
_settings = GameManager.GetSettingsObject<ICardSystemSettings>();
|
||||
}
|
||||
|
||||
public override void OnEnterState()
|
||||
@@ -38,10 +40,10 @@ namespace UI.CardSystem.StateMachine.States
|
||||
// Notify page to show backdrop and reparent card to top layer
|
||||
OnEnlargeRequested?.Invoke(this);
|
||||
|
||||
// Enlarge the card
|
||||
// Enlarge the card using album scale setting
|
||||
if (_context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayEnlarge();
|
||||
_context.Animator.PlayEnlarge(_settings.AlbumCardEnlargedScale);
|
||||
}
|
||||
|
||||
Logging.Debug($"[CardAlbumEnlargedState] Card enlarged from album: {_context.CardData?.Name}");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using Core;
|
||||
using AppleHills.Core.Settings;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
@@ -11,16 +11,15 @@ namespace UI.CardSystem.StateMachine.States
|
||||
/// </summary>
|
||||
public class CardDraggingState : AppleState
|
||||
{
|
||||
[Header("Drag Settings")]
|
||||
[SerializeField] private float dragScale = 1.1f;
|
||||
|
||||
private CardContext _context;
|
||||
private ICardSystemSettings _settings;
|
||||
private Vector3 _originalScale;
|
||||
private Vector3 _dragStartPosition;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_context = GetComponentInParent<CardContext>();
|
||||
_settings = GameManager.GetSettingsObject<ICardSystemSettings>();
|
||||
}
|
||||
|
||||
public override void OnEnterState()
|
||||
@@ -30,7 +29,7 @@ namespace UI.CardSystem.StateMachine.States
|
||||
_dragStartPosition = _context.RootTransform.position;
|
||||
|
||||
// Scale up slightly during drag for visual feedback
|
||||
_context.RootTransform.localScale = _originalScale * dragScale;
|
||||
_context.RootTransform.localScale = _originalScale * _settings.DragScale;
|
||||
|
||||
Logging.Debug($"[CardDraggingState] Entered drag state for card: {_context.CardData?.Name}");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using AppleHills.Core.Settings;
|
||||
using Core;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
@@ -14,11 +16,13 @@ namespace UI.CardSystem.StateMachine.States
|
||||
[SerializeField] private GameObject newCardBadge;
|
||||
|
||||
private CardContext _context;
|
||||
private ICardSystemSettings _settings;
|
||||
private Vector3 _originalScale;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_context = GetComponentInParent<CardContext>();
|
||||
_settings = GameManager.GetSettingsObject<ICardSystemSettings>();
|
||||
}
|
||||
|
||||
public override void OnEnterState()
|
||||
@@ -35,7 +39,7 @@ namespace UI.CardSystem.StateMachine.States
|
||||
// Enlarge the card
|
||||
if (_context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayEnlarge();
|
||||
_context.Animator.PlayEnlarge(_settings.NewCardEnlargedScale);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using AppleHills.Core.Settings;
|
||||
using Core;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
@@ -16,14 +18,15 @@ namespace UI.CardSystem.StateMachine.States
|
||||
[SerializeField] private GameObject progressBarContainer;
|
||||
[SerializeField] private Image progressBarFill;
|
||||
[SerializeField] private TextMeshProUGUI progressText;
|
||||
[SerializeField] private int cardsToUpgrade = 5;
|
||||
|
||||
private CardContext _context;
|
||||
private ICardSystemSettings _settings;
|
||||
private Vector3 _originalScale;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_context = GetComponentInParent<CardContext>();
|
||||
_settings = GameManager.GetSettingsObject<ICardSystemSettings>();
|
||||
}
|
||||
|
||||
public override void OnEnterState()
|
||||
@@ -41,13 +44,14 @@ namespace UI.CardSystem.StateMachine.States
|
||||
// Enlarge the card
|
||||
if (_context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayEnlarge();
|
||||
_context.Animator.PlayEnlarge(_settings.NewCardEnlargedScale);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateProgressBar()
|
||||
{
|
||||
int currentCount = _context.RepeatCardCount;
|
||||
int cardsToUpgrade = _settings.CardsToUpgrade;
|
||||
float progress = (float)currentCount / cardsToUpgrade;
|
||||
|
||||
if (progressBarFill != null)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
using Pixelplacement.TweenSystem;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using AppleHills.Core.Settings;
|
||||
using Core;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
@@ -17,17 +19,16 @@ namespace UI.CardSystem.StateMachine.States
|
||||
|
||||
[Header("Idle Hover Settings")]
|
||||
[SerializeField] private bool enableIdleHover = true;
|
||||
[SerializeField] private float idleHoverHeight = 10f;
|
||||
[SerializeField] private float idleHoverDuration = 1.5f;
|
||||
[SerializeField] private float hoverScaleMultiplier = 1.05f;
|
||||
|
||||
private CardContext _context;
|
||||
private ICardSystemSettings _settings;
|
||||
private TweenBase _idleHoverTween;
|
||||
private Vector2 _originalPosition;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_context = GetComponentInParent<CardContext>();
|
||||
_settings = GameManager.GetSettingsObject<ICardSystemSettings>();
|
||||
}
|
||||
|
||||
public override void OnEnterState()
|
||||
@@ -57,7 +58,7 @@ namespace UI.CardSystem.StateMachine.States
|
||||
// Start idle hover animation
|
||||
if (enableIdleHover && _context.Animator != null)
|
||||
{
|
||||
_idleHoverTween = _context.Animator.StartIdleHover(idleHoverHeight, idleHoverDuration);
|
||||
_idleHoverTween = _context.Animator.StartIdleHover(_settings.IdleHoverHeight, _settings.IdleHoverDuration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +67,7 @@ namespace UI.CardSystem.StateMachine.States
|
||||
// Scale up slightly on hover
|
||||
if (_context.Animator != null)
|
||||
{
|
||||
_context.Animator.AnimateScale(Vector3.one * hoverScaleMultiplier, 0.2f);
|
||||
_context.Animator.AnimateScale(Vector3.one * _settings.HoverScaleMultiplier, 0.2f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user