Merge a card refresh (#59)
- **Refactored Card Placement Flow** - Separated card presentation from orchestration logic - Extracted `CornerCardManager` for pending card lifecycle (spawn, shuffle, rebuild) - Extracted `AlbumNavigationService` for book page navigation and zone mapping - Extracted `CardEnlargeController` for backdrop management and card reparenting - Implemented controller pattern (non-MonoBehaviour) for complex logic - Cards now unparent from slots before rebuild to prevent premature destruction - **Improved Corner Card Display** - Fixed cards spawning on top of each other during rebuild - Implemented shuffle-to-front logic (remaining cards occupy slots 0→1→2) - Added smart card selection (prioritizes cards matching current album page) - Pending cards now removed from queue immediately on drag start - Corner cards rebuild after each placement with proper slot reassignment - **Enhanced Album Card Viewing** - Added dramatic scale increase when viewing cards from album slots - Implemented shrink animation when dismissing enlarged cards - Cards transition: `PlacedInSlotState` → `AlbumEnlargedState` → `PlacedInSlotState` - Backdrop shows/hides with card enlarge/shrink cycle - Cards reparent to enlarged container while viewing, return to slot after - **State Machine Improvements** - Added `CardStateNames` constants for type-safe state transitions - Implemented `ICardClickHandler` and `ICardStateDragHandler` interfaces - State transitions now use cached property indices - `BoosterCardContext` separated from `CardContext` for single responsibility - **Code Cleanup** - Identified unused `SlotContainerHelper.cs` (superseded by `CornerCardManager`) - Identified unused `BoosterPackDraggable.canOpenOnDrop` field - Identified unused `AlbumViewPage._previousInputMode` (hardcoded value) - Identified unused `Card.OnPlacedInAlbumSlot` event (no subscribers) Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Co-authored-by: Michal Pikulski <michal@foolhardyhorizons.com> Reviewed-on: #59
This commit is contained in:
59
Assets/Scripts/CardSystem/Data/CardDefinition.cs
Normal file
59
Assets/Scripts/CardSystem/Data/CardDefinition.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AppleHills.Data.CardSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Scriptable object defining a collectible card's properties.
|
||||
/// Used as a template for generating CardData instances.
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "New Card", menuName = "AppleHills/Card System/Card Definition")]
|
||||
public class CardDefinition : ScriptableObject
|
||||
{
|
||||
[Header("Identification")]
|
||||
[Tooltip("Unique identifier for this card definition")]
|
||||
public string Id = Guid.NewGuid().ToString();
|
||||
|
||||
[Header("Basic Info")]
|
||||
public string Name;
|
||||
|
||||
[Tooltip("Use a custom file name instead of the card name")]
|
||||
public bool UseCustomFileName = false;
|
||||
|
||||
[Tooltip("Custom file name (only used if UseCustomFileName is true)")]
|
||||
public string CustomFileName = "";
|
||||
|
||||
[TextArea(3, 5)]
|
||||
public string Description;
|
||||
public CardRarity Rarity;
|
||||
public CardZone Zone;
|
||||
|
||||
[Header("Visual Elements")]
|
||||
public Sprite CardImage; // The actual card image
|
||||
|
||||
[Header("Collection Info")]
|
||||
public int CollectionIndex; // Position in the album
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new CardData instance from this definition
|
||||
/// </summary>
|
||||
public CardData CreateCardData()
|
||||
{
|
||||
return new CardData(this);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is CardDefinition other)
|
||||
{
|
||||
return string.Equals(Id, other.Id, StringComparison.Ordinal);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id != null ? Id.GetHashCode() : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user