Slotting cards in album after revealing
This commit is contained in:
57
Assets/Scripts/UI/CardSystem/AlbumCardSlot.cs
Normal file
57
Assets/Scripts/UI/CardSystem/AlbumCardSlot.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using AppleHills.Data.CardSystem;
|
||||
using UI.DragAndDrop.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI.CardSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Specialized slot for album pages that only accepts a specific card.
|
||||
/// Validates cards based on their CardDefinition.
|
||||
/// </summary>
|
||||
public class AlbumCardSlot : DraggableSlot
|
||||
{
|
||||
[Header("Album Slot Configuration")]
|
||||
[SerializeField] private CardDefinition targetCardDefinition; // Which card this slot accepts
|
||||
|
||||
private bool _isOccupiedPermanently = false;
|
||||
|
||||
/// <summary>
|
||||
/// Set the target card this slot should accept
|
||||
/// </summary>
|
||||
public void SetTargetCard(CardDefinition definition)
|
||||
{
|
||||
targetCardDefinition = definition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if this slot can accept a specific card
|
||||
/// </summary>
|
||||
public bool CanAcceptCard(CardData cardData)
|
||||
{
|
||||
if (cardData == null || targetCardDefinition == null) return false;
|
||||
if (_isOccupiedPermanently) return false;
|
||||
|
||||
// Card must match this slot's target definition
|
||||
return cardData.DefinitionId == targetCardDefinition.Id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a card is successfully placed in this slot
|
||||
/// </summary>
|
||||
public void OnCardPlaced()
|
||||
{
|
||||
_isOccupiedPermanently = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if this slot has been permanently filled
|
||||
/// </summary>
|
||||
public bool IsOccupiedPermanently => _isOccupiedPermanently;
|
||||
|
||||
/// <summary>
|
||||
/// Get the target card definition for this slot
|
||||
/// </summary>
|
||||
public CardDefinition TargetCardDefinition => targetCardDefinition;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user