diff --git a/Assets/Editor/Settings/SettingsEditorWindow.cs b/Assets/Editor/Settings/SettingsEditorWindow.cs index a69eef05..039e5963 100644 --- a/Assets/Editor/Settings/SettingsEditorWindow.cs +++ b/Assets/Editor/Settings/SettingsEditorWindow.cs @@ -10,7 +10,7 @@ namespace AppleHills.Core.Settings.Editor { private Vector2 scrollPosition; private List allSettings = new List(); - private string[] tabNames = new string[] { "Player & Follower", "Interaction & Items", "Diving Minigame" }; + private string[] tabNames = new string[] { "Player & Follower", "Interaction & Items", "Diving Minigame", "Card System" }; private int selectedTab = 0; private Dictionary serializedSettingsObjects = new Dictionary(); private GUIStyle headerStyle; @@ -48,6 +48,7 @@ namespace AppleHills.Core.Settings.Editor CreateSettingsIfMissing("PlayerFollowerSettings"); CreateSettingsIfMissing("InteractionSettings"); CreateSettingsIfMissing("DivingMinigameSettings"); + CreateSettingsIfMissing("CardSystemSettings"); } private void CreateSettingsIfMissing(string fileName) where T : BaseSettings @@ -114,6 +115,9 @@ namespace AppleHills.Core.Settings.Editor case 2: // Minigames DrawSettingsEditor(); break; + case 3: // Card System + DrawSettingsEditor(); + break; } EditorGUILayout.EndScrollView(); diff --git a/Assets/Scripts/Core/GameManager.cs b/Assets/Scripts/Core/GameManager.cs index 6ccd6750..61bbe092 100644 --- a/Assets/Scripts/Core/GameManager.cs +++ b/Assets/Scripts/Core/GameManager.cs @@ -169,6 +169,7 @@ namespace Core var playerSettings = SettingsProvider.Instance.LoadSettingsSynchronous(); var interactionSettings = SettingsProvider.Instance.LoadSettingsSynchronous(); var minigameSettings = SettingsProvider.Instance.LoadSettingsSynchronous(); + var cardSystemSettings = SettingsProvider.Instance.LoadSettingsSynchronous(); // Register settings with service locator if (playerSettings != null) @@ -200,9 +201,19 @@ namespace Core { Debug.LogError("Failed to load MinigameSettings"); } + + if (cardSystemSettings != null) + { + ServiceLocator.Register(cardSystemSettings); + Logging.Debug("CardSystemSettings registered successfully"); + } + else + { + Debug.LogError("Failed to load CardSystemSettings"); + } // Log success - _settingsLoaded = playerSettings != null && interactionSettings != null && minigameSettings != null; + _settingsLoaded = playerSettings != null && interactionSettings != null && minigameSettings != null && cardSystemSettings != null; if (_settingsLoaded) { Logging.Debug("All settings loaded and registered with ServiceLocator"); diff --git a/Assets/Scripts/Core/Settings/CardSystemSettings.cs b/Assets/Scripts/Core/Settings/CardSystemSettings.cs new file mode 100644 index 00000000..01e1f4ab --- /dev/null +++ b/Assets/Scripts/Core/Settings/CardSystemSettings.cs @@ -0,0 +1,102 @@ +using UnityEngine; + +namespace AppleHills.Core.Settings +{ + /// + /// Settings for the card system - controls animations, interactions, and progression + /// + [CreateAssetMenu(fileName = "CardSystemSettings", menuName = "AppleHills/Settings/Card System", order = 4)] + public class CardSystemSettings : BaseSettings, ICardSystemSettings + { + [Header("Idle Hover Animations")] + [Tooltip("Height of the idle hover animation in pixels")] + [SerializeField] private float idleHoverHeight = 10f; + + [Tooltip("Duration of one complete hover cycle in seconds")] + [SerializeField] private float idleHoverDuration = 1.5f; + + [Tooltip("Scale multiplier when hovering over a card (1.05 = 5% larger)")] + [SerializeField] private float hoverScaleMultiplier = 1.05f; + + [Header("Flip Animations")] + [Tooltip("Duration of the card flip animation in seconds")] + [SerializeField] private float flipDuration = 0.6f; + + [Tooltip("Scale punch amount during flip (1.1 = 10% larger at peak)")] + [SerializeField] private float flipScalePunch = 1.1f; + + [Header("Enlarge/Shrink Animations")] + [Tooltip("Scale for new cards when enlarged (1.5 = 150% of normal size)")] + [SerializeField] private float newCardEnlargedScale = 1.5f; + + [Tooltip("Scale for album cards when enlarged (2.5 = 250% of normal size)")] + [SerializeField] private float albumCardEnlargedScale = 2.5f; + + [Tooltip("Duration of scale animations in seconds")] + [SerializeField] private float scaleDuration = 0.3f; + + [Header("Drag & Drop")] + [Tooltip("Scale multiplier when dragging a card (1.1 = 10% larger)")] + [SerializeField] private float dragScale = 1.1f; + + [Header("Progression System")] + [Tooltip("Number of duplicate cards needed to upgrade rarity")] + [SerializeField] private int cardsToUpgrade = 5; + + [Header("General Animation")] + [Tooltip("Default animation duration when not specified in seconds")] + [SerializeField] private float defaultAnimationDuration = 0.3f; + + // ICardSystemSettings implementation - Idle Hover Animations + public float IdleHoverHeight => idleHoverHeight; + public float IdleHoverDuration => idleHoverDuration; + public float HoverScaleMultiplier => hoverScaleMultiplier; + + // ICardSystemSettings implementation - Flip Animations + public float FlipDuration => flipDuration; + public float FlipScalePunch => flipScalePunch; + + // ICardSystemSettings implementation - Enlarge/Shrink Animations + public float NewCardEnlargedScale => newCardEnlargedScale; + public float AlbumCardEnlargedScale => albumCardEnlargedScale; + public float ScaleDuration => scaleDuration; + + // ICardSystemSettings implementation - Drag & Drop + public float DragScale => dragScale; + + // ICardSystemSettings implementation - Progression System + public int CardsToUpgrade => cardsToUpgrade; + + // ICardSystemSettings implementation - General Animation + public float DefaultAnimationDuration => defaultAnimationDuration; + + public override void OnValidate() + { + base.OnValidate(); + + // Validate idle hover animations + idleHoverHeight = Mathf.Max(0f, idleHoverHeight); + idleHoverDuration = Mathf.Max(0.1f, idleHoverDuration); + hoverScaleMultiplier = Mathf.Max(1.0f, hoverScaleMultiplier); + + // Validate flip animations + flipDuration = Mathf.Max(0.1f, flipDuration); + flipScalePunch = Mathf.Max(1.0f, flipScalePunch); + + // Validate enlarge/shrink animations + newCardEnlargedScale = Mathf.Max(1.0f, newCardEnlargedScale); + albumCardEnlargedScale = Mathf.Max(1.0f, albumCardEnlargedScale); + scaleDuration = Mathf.Max(0.1f, scaleDuration); + + // Validate drag & drop + dragScale = Mathf.Max(1.0f, dragScale); + + // Validate progression system + cardsToUpgrade = Mathf.Max(1, cardsToUpgrade); + + // Validate general animation + defaultAnimationDuration = Mathf.Max(0.1f, defaultAnimationDuration); + } + } +} + diff --git a/Assets/Scripts/Core/Settings/CardSystemSettings.cs.meta b/Assets/Scripts/Core/Settings/CardSystemSettings.cs.meta new file mode 100644 index 00000000..ff5473ca --- /dev/null +++ b/Assets/Scripts/Core/Settings/CardSystemSettings.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ce6f8e26f4e74a9ab16c190529e67638 +timeCreated: 1762934668 \ No newline at end of file diff --git a/Assets/Scripts/Core/Settings/SettingsInterfaces.cs b/Assets/Scripts/Core/Settings/SettingsInterfaces.cs index 0f1a3e85..f2017418 100644 --- a/Assets/Scripts/Core/Settings/SettingsInterfaces.cs +++ b/Assets/Scripts/Core/Settings/SettingsInterfaces.cs @@ -128,9 +128,36 @@ namespace AppleHills.Core.Settings float[] ViewfinderProgressThresholds { get; } float PaddingFactor { get; } float MaxSizePercent { get; } - float MinSizePercent { get; } + public float MinSizePercent { get; } + public PhotoInputModes PhotoInputMode { get; } + } + + /// + /// Interface for card system settings + /// + public interface ICardSystemSettings + { + // Idle Hover Animations + float IdleHoverHeight { get; } + float IdleHoverDuration { get; } + float HoverScaleMultiplier { get; } - // Photo Input Settings - PhotoInputModes PhotoInputMode { get; } + // Flip Animations + float FlipDuration { get; } + float FlipScalePunch { get; } + + // Enlarge/Shrink Animations + float NewCardEnlargedScale { get; } + float AlbumCardEnlargedScale { get; } + float ScaleDuration { get; } + + // Drag & Drop + float DragScale { get; } + + // Progression System + int CardsToUpgrade { get; } + + // General Animation + float DefaultAnimationDuration { get; } } } diff --git a/Assets/Scripts/UI/CardSystem/AlbumCard.cs b/Assets/Scripts/UI/CardSystem/AlbumCard.cs index ca7e6e87..12dbc548 100644 --- a/Assets/Scripts/UI/CardSystem/AlbumCard.cs +++ b/Assets/Scripts/UI/CardSystem/AlbumCard.cs @@ -4,6 +4,7 @@ using Core; using Pixelplacement; using UnityEngine; using UnityEngine.EventSystems; +using AppleHills.Core.Settings; namespace UI.CardSystem { @@ -20,10 +21,6 @@ namespace UI.CardSystem [Header("References")] [SerializeField] private CardDisplay cardDisplay; - [Header("Enlarge Settings")] - [SerializeField] private float enlargedScale = 2.5f; - [SerializeField] private float scaleDuration = 0.3f; - // Events for AlbumViewPage to manage backdrop and reparenting public event Action OnEnlargeRequested; public event Action OnShrinkRequested; @@ -35,9 +32,12 @@ namespace UI.CardSystem private Transform _originalParent; private Vector3 _originalLocalPosition; private Quaternion _originalLocalRotation; + private ICardSystemSettings _settings; private void Awake() { + _settings = GameManager.GetSettingsObject(); + // Auto-find CardDisplay if not assigned if (cardDisplay == null) { @@ -133,7 +133,7 @@ namespace UI.CardSystem _originalLocalRotation = transform.localRotation; // Scale up with snappy tween - Tween.LocalScale(transform, _originalScale * enlargedScale, scaleDuration, 0f, Tween.EaseOutBack); + Tween.LocalScale(transform, _originalScale * _settings.AlbumCardEnlargedScale, _settings.ScaleDuration, 0f, Tween.EaseOutBack); } /// @@ -147,7 +147,7 @@ namespace UI.CardSystem _isEnlarged = false; // Scale back down with snappy tween, invoke callback when done - Tween.LocalScale(transform, _originalScale, scaleDuration, 0f, Tween.EaseInBack, + Tween.LocalScale(transform, _originalScale, _settings.ScaleDuration, 0f, Tween.EaseInBack, completeCallback: () => onComplete?.Invoke()); } diff --git a/Assets/Scripts/UI/CardSystem/FlippableCard.cs b/Assets/Scripts/UI/CardSystem/FlippableCard.cs index 94fb33c4..fa4c6652 100644 --- a/Assets/Scripts/UI/CardSystem/FlippableCard.cs +++ b/Assets/Scripts/UI/CardSystem/FlippableCard.cs @@ -5,6 +5,7 @@ using Pixelplacement; using Pixelplacement.TweenSystem; using UnityEngine; using UnityEngine.EventSystems; +using AppleHills.Core.Settings; namespace UI.CardSystem { @@ -22,23 +23,15 @@ namespace UI.CardSystem [Header("Idle Hover Animation")] [SerializeField] private bool enableIdleHover = true; - [SerializeField] private float idleHoverHeight = 10f; - [SerializeField] private float idleHoverDuration = 1.5f; - [SerializeField] private float hoverScaleMultiplier = 1.05f; - - [Header("Flip Animation")] - [SerializeField] private float flipDuration = 0.6f; - [SerializeField] private float flipScalePunch = 1.1f; [Header("New/Repeat Card Display")] [SerializeField] private GameObject newCardText; [SerializeField] private GameObject newCardIdleText; [SerializeField] private GameObject repeatText; [SerializeField] private GameObject progressBarContainer; - [SerializeField] private int cardsToUpgrade = 5; - [SerializeField] private float enlargedScale = 1.5f; // State + private ICardSystemSettings _settings; private bool _isFlipped = false; private bool _isFlipping = false; private TweenBase _idleHoverTween; @@ -57,10 +50,12 @@ namespace UI.CardSystem public bool IsFlipped => _isFlipped; public CardData CardData => _cardData; - public int CardsToUpgrade => cardsToUpgrade; // Expose upgrade threshold + public int CardsToUpgrade => _settings?.CardsToUpgrade ?? 5; private void Awake() { + _settings = GameManager.GetSettingsObject(); + // Auto-find CardDisplay if not assigned if (cardDisplay == null && cardFrontObject != null) { @@ -149,15 +144,18 @@ namespace UI.CardSystem // Card back: 0° → 90° (rotates away) // Card front: 180° → 90° → 0° (rotates into view) + float flipDur = _settings.FlipDuration; + float flipPunch = _settings.FlipScalePunch; + // Phase 1: Rotate both to 90 degrees (edge view) if (cardBackObject != null) { - Tween.LocalRotation(cardBackObject.transform, Quaternion.Euler(0, 90, 0), flipDuration * 0.5f, 0f, Tween.EaseInOut); + Tween.LocalRotation(cardBackObject.transform, Quaternion.Euler(0, 90, 0), flipDur * 0.5f, 0f, Tween.EaseInOut); } if (cardFrontObject != null) { - Tween.LocalRotation(cardFrontObject.transform, Quaternion.Euler(0, 90, 0), flipDuration * 0.5f, 0f, Tween.EaseInOut, + Tween.LocalRotation(cardFrontObject.transform, Quaternion.Euler(0, 90, 0), flipDur * 0.5f, 0f, Tween.EaseInOut, completeCallback: () => { // At edge (90°), switch visibility @@ -167,7 +165,7 @@ namespace UI.CardSystem cardFrontObject.SetActive(true); // Phase 2: Rotate front from 90 to 0 (show at correct orientation) - Tween.LocalRotation(cardFrontObject.transform, Quaternion.Euler(0, 0, 0), flipDuration * 0.5f, 0f, Tween.EaseInOut, + Tween.LocalRotation(cardFrontObject.transform, Quaternion.Euler(0, 0, 0), flipDur * 0.5f, 0f, Tween.EaseInOut, completeCallback: () => { _isFlipped = true; @@ -181,10 +179,10 @@ namespace UI.CardSystem // Scale punch during flip for extra juice Vector3 originalScale = transform.localScale; - Tween.LocalScale(transform, originalScale * flipScalePunch, flipDuration * 0.5f, 0f, Tween.EaseOutBack, + Tween.LocalScale(transform, originalScale * flipPunch, flipDur * 0.5f, 0f, Tween.EaseOutBack, completeCallback: () => { - Tween.LocalScale(transform, originalScale, flipDuration * 0.5f, 0f, Tween.EaseInBack); + Tween.LocalScale(transform, originalScale, flipDur * 0.5f, 0f, Tween.EaseInBack); }); } @@ -201,7 +199,7 @@ namespace UI.CardSystem return; Vector2 originalPos = rectTransform.anchoredPosition; - Vector2 targetPos = originalPos + Vector2.up * idleHoverHeight; + Vector2 targetPos = originalPos + Vector2.up * _settings.IdleHoverHeight; _idleHoverTween = Tween.Value(0f, 1f, (val) => @@ -212,7 +210,7 @@ namespace UI.CardSystem rectTransform.anchoredPosition = Vector2.Lerp(originalPos, targetPos, t); } }, - idleHoverDuration, 0f, Tween.EaseInOut, Tween.LoopType.Loop); + _settings.IdleHoverDuration, 0f, Tween.EaseInOut, Tween.LoopType.Loop); } /// @@ -242,7 +240,7 @@ namespace UI.CardSystem return; // Scale up slightly on hover - Tween.LocalScale(transform, Vector3.one * hoverScaleMultiplier, 0.2f, 0f, Tween.EaseOutBack); + Tween.LocalScale(transform, Vector3.one * _settings.HoverScaleMultiplier, 0.2f, 0f, Tween.EaseOutBack); } public void OnPointerExit(PointerEventData eventData) @@ -492,7 +490,7 @@ namespace UI.CardSystem /// private void EnlargeCard() { - Tween.LocalScale(transform, Vector3.one * enlargedScale, 0.3f, 0f, Tween.EaseOutBack); + Tween.LocalScale(transform, Vector3.one * _settings.NewCardEnlargedScale, _settings.ScaleDuration, 0f, Tween.EaseOutBack); } /// @@ -500,7 +498,7 @@ namespace UI.CardSystem /// public void ReturnToNormalSize() { - Tween.LocalScale(transform, Vector3.one, 0.3f, 0f, Tween.EaseOutBack, completeCallback: () => + Tween.LocalScale(transform, Vector3.one, _settings.ScaleDuration, 0f, Tween.EaseOutBack, completeCallback: () => { // After returning to normal, hide new card text, show idle text if (_isNew) @@ -531,6 +529,8 @@ namespace UI.CardSystem // Get all child Image components UnityEngine.UI.Image[] progressElements = progressBarContainer.GetComponentsInChildren(true); + int cardsToUpgrade = _settings.CardsToUpgrade; + // Check if we have the required number of elements (should match cardsToUpgrade) if (progressElements.Length < cardsToUpgrade) { diff --git a/Assets/Scripts/UI/CardSystem/StateMachine/CardAnimationConfig.cs b/Assets/Scripts/UI/CardSystem/StateMachine/CardAnimationConfig.cs deleted file mode 100644 index 5f282702..00000000 --- a/Assets/Scripts/UI/CardSystem/StateMachine/CardAnimationConfig.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Assets/Scripts/UI/CardSystem/StateMachine/CardAnimationConfig.cs.meta b/Assets/Scripts/UI/CardSystem/StateMachine/CardAnimationConfig.cs.meta deleted file mode 100644 index f8de6a33..00000000 --- a/Assets/Scripts/UI/CardSystem/StateMachine/CardAnimationConfig.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: ddd745ae12984de9974292d201c89d9c -timeCreated: 1762884650 \ No newline at end of file diff --git a/Assets/Scripts/UI/CardSystem/StateMachine/CardAnimator.cs b/Assets/Scripts/UI/CardSystem/StateMachine/CardAnimator.cs index db66b21b..b9126361 100644 --- a/Assets/Scripts/UI/CardSystem/StateMachine/CardAnimator.cs +++ b/Assets/Scripts/UI/CardSystem/StateMachine/CardAnimator.cs @@ -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 /// 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(); + _settings = GameManager.GetSettingsObject(); } #region Scale Animations @@ -31,7 +32,7 @@ namespace UI.CardSystem.StateMachine /// 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 /// 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 /// 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() /// - 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() /// - 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() /// - 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() /// - 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); } diff --git a/Assets/Scripts/UI/CardSystem/StateMachine/States/CardAlbumEnlargedState.cs b/Assets/Scripts/UI/CardSystem/StateMachine/States/CardAlbumEnlargedState.cs index b0919c69..a6d30b80 100644 --- a/Assets/Scripts/UI/CardSystem/StateMachine/States/CardAlbumEnlargedState.cs +++ b/Assets/Scripts/UI/CardSystem/StateMachine/States/CardAlbumEnlargedState.cs @@ -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(); + _settings = GameManager.GetSettingsObject(); } 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}"); diff --git a/Assets/Scripts/UI/CardSystem/StateMachine/States/CardDraggingState.cs b/Assets/Scripts/UI/CardSystem/StateMachine/States/CardDraggingState.cs index c424038c..a7cc9478 100644 --- a/Assets/Scripts/UI/CardSystem/StateMachine/States/CardDraggingState.cs +++ b/Assets/Scripts/UI/CardSystem/StateMachine/States/CardDraggingState.cs @@ -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 /// 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(); + _settings = GameManager.GetSettingsObject(); } 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}"); } diff --git a/Assets/Scripts/UI/CardSystem/StateMachine/States/CardEnlargedNewState.cs b/Assets/Scripts/UI/CardSystem/StateMachine/States/CardEnlargedNewState.cs index 62f8f61d..38a5b309 100644 --- a/Assets/Scripts/UI/CardSystem/StateMachine/States/CardEnlargedNewState.cs +++ b/Assets/Scripts/UI/CardSystem/StateMachine/States/CardEnlargedNewState.cs @@ -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(); + _settings = GameManager.GetSettingsObject(); } 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); } } diff --git a/Assets/Scripts/UI/CardSystem/StateMachine/States/CardEnlargedRepeatState.cs b/Assets/Scripts/UI/CardSystem/StateMachine/States/CardEnlargedRepeatState.cs index 1eae9bf7..4a78bb9c 100644 --- a/Assets/Scripts/UI/CardSystem/StateMachine/States/CardEnlargedRepeatState.cs +++ b/Assets/Scripts/UI/CardSystem/StateMachine/States/CardEnlargedRepeatState.cs @@ -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(); + _settings = GameManager.GetSettingsObject(); } 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) diff --git a/Assets/Scripts/UI/CardSystem/StateMachine/States/CardIdleState.cs b/Assets/Scripts/UI/CardSystem/StateMachine/States/CardIdleState.cs index ba479161..f060d82d 100644 --- a/Assets/Scripts/UI/CardSystem/StateMachine/States/CardIdleState.cs +++ b/Assets/Scripts/UI/CardSystem/StateMachine/States/CardIdleState.cs @@ -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(); + _settings = GameManager.GetSettingsObject(); } 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); } }