Make cards use settings

This commit is contained in:
Michal Pikulski
2025-11-12 09:24:27 +01:00
committed by Michal Pikulski
parent 4fdbbb0aa8
commit a6471ede45
15 changed files with 232 additions and 69 deletions

View File

@@ -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}");

View File

@@ -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}");
}

View File

@@ -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);
}
}

View File

@@ -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)

View File

@@ -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);
}
}