Second draft of the consolidated card system

This commit is contained in:
Michal Adam Pikulski
2025-10-20 12:04:55 +02:00
parent 542dd9a4b7
commit 32f726d229
13 changed files with 1152 additions and 85 deletions

View File

@@ -23,3 +23,4 @@ MonoBehaviour:
- {fileID: 2755712733105741372, guid: 70e6fca1164d9a140b271f4261f1f023, type: 3}
- {fileID: 5034240524438268576, guid: adbb9bfd5489f3f4995966535ca5f24b, type: 3}
- {fileID: 2326026072467672024, guid: c8d9eb8c3ca524b4eb67f6364b455b87, type: 3}
- {fileID: 3528960956969533010, guid: 53eea3840d3cde34a9768b8773a3a7e8, type: 3}

View File

@@ -0,0 +1,49 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3528960956969533010
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4698585910635356118}
- component: {fileID: 1232423156726317973}
m_Layer: 0
m_Name: CardSystemManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4698585910635356118
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3528960956969533010}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 158.01367, y: -59.930664, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1232423156726317973
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3528960956969533010}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8d80347e4bd04c87be23a9399860783d, type: 3}
m_Name:
m_EditorClassIdentifier: AppleHillsScripts::Data.CardSystem.CardSystemManager
availableCards: []
playerInventory:
boosterPackCount: 0

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 53eea3840d3cde34a9768b8773a3a7e8
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -536,6 +536,10 @@ PrefabInstance:
propertyPath: m_Name
value: BoosterOpeningPage
objectReference: {fileID: 0}
- target: {fileID: 1485089218833421720, guid: 06de8e223a669fe48b043983963d1e6a, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2026295995152435872, guid: 06de8e223a669fe48b043983963d1e6a, type: 3}
propertyPath: m_Pivot.x
value: 0.5
@@ -618,35 +622,35 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3492318441088451548, guid: 06de8e223a669fe48b043983963d1e6a, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3492318441088451548, guid: 06de8e223a669fe48b043983963d1e6a, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3492318441088451548, guid: 06de8e223a669fe48b043983963d1e6a, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 125
objectReference: {fileID: 0}
- target: {fileID: 3492318441088451548, guid: 06de8e223a669fe48b043983963d1e6a, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -25
objectReference: {fileID: 0}
- target: {fileID: 4525022388006312158, guid: 06de8e223a669fe48b043983963d1e6a, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4525022388006312158, guid: 06de8e223a669fe48b043983963d1e6a, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4525022388006312158, guid: 06de8e223a669fe48b043983963d1e6a, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 375
objectReference: {fileID: 0}
- target: {fileID: 4525022388006312158, guid: 06de8e223a669fe48b043983963d1e6a, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -25
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
@@ -874,6 +878,10 @@ PrefabInstance:
propertyPath: m_Name
value: MainMenuPage
objectReference: {fileID: 0}
- target: {fileID: 215586258230015996, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3784919015553725210, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_Pivot.x
value: 0.5
@@ -956,75 +964,75 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 6825096203099742481, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6825096203099742481, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6825096203099742481, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: 300
objectReference: {fileID: 0}
- target: {fileID: 6825096203099742481, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_SizeDelta.y
value: 0
value: 80
objectReference: {fileID: 0}
- target: {fileID: 6825096203099742481, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 150
objectReference: {fileID: 0}
- target: {fileID: 6825096203099742481, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -40
objectReference: {fileID: 0}
- target: {fileID: 7359584553354036269, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7359584553354036269, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7359584553354036269, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: 300
objectReference: {fileID: 0}
- target: {fileID: 7359584553354036269, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_SizeDelta.y
value: 0
value: 80
objectReference: {fileID: 0}
- target: {fileID: 7359584553354036269, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 150
objectReference: {fileID: 0}
- target: {fileID: 7359584553354036269, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -150
objectReference: {fileID: 0}
- target: {fileID: 9087503811150501775, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9087503811150501775, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9087503811150501775, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: 300
objectReference: {fileID: 0}
- target: {fileID: 9087503811150501775, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_SizeDelta.y
value: 0
value: 80
objectReference: {fileID: 0}
- target: {fileID: 9087503811150501775, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 150
objectReference: {fileID: 0}
- target: {fileID: 9087503811150501775, guid: 43be0f1cce1e5ae4d86def9da1fe2822, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -260
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []

View File

@@ -34,10 +34,10 @@ RectTransform:
- {fileID: 3003605026999030427}
m_Father: {fileID: 1666992978469506438}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 150, y: -150}
m_SizeDelta: {x: 300, y: 80}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8262356594320332946
CanvasRenderer:
@@ -138,7 +138,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &3784919015553725210
RectTransform:
m_ObjectHideFlags: 0
@@ -154,6 +154,7 @@ RectTransform:
- {fileID: 3630458631707444839}
- {fileID: 153228754897357713}
- {fileID: 1666992978469506438}
- {fileID: 8617983403484926878}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
@@ -178,6 +179,7 @@ MonoBehaviour:
openBoosterButton: {fileID: 979874661361344719}
viewAlbumButton: {fileID: 6681241741793107898}
changeClothesButton: {fileID: 1331007469521797899}
backButton: {fileID: 7356423904297404831}
boosterNotificationDot: {fileID: 1953610677995146669}
canvasGroup: {fileID: 3611756665801410423}
--- !u!225 &3611756665801410423
@@ -226,10 +228,10 @@ RectTransform:
- {fileID: 935304982975062306}
m_Father: {fileID: 1666992978469506438}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 150, y: -260}
m_SizeDelta: {x: 300, y: 80}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3411861085081790681
CanvasRenderer:
@@ -313,6 +315,126 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!1 &1737944465143783675
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8617983403484926878}
- component: {fileID: 4593995292024622811}
- component: {fileID: 8540888888620849884}
- component: {fileID: 7356423904297404831}
m_Layer: 5
m_Name: BackButton
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8617983403484926878
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1737944465143783675}
m_LocalRotation: {x: -0, y: -0, z: -0.7071068, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3784919015553725210}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 159, y: -27}
m_SizeDelta: {x: 88.05109, y: 128.83948}
m_Pivot: {x: 0, y: 1}
--- !u!222 &4593995292024622811
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1737944465143783675}
m_CullTransparentMesh: 1
--- !u!114 &8540888888620849884
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1737944465143783675}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 7399797961453878310, guid: 4ee2d56eceb077249b6d783ac1ab7ec4, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &7356423904297404831
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1737944465143783675}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Button
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 8540888888620849884}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!1 &3677045968037056248
GameObject:
m_ObjectHideFlags: 0
@@ -413,10 +535,10 @@ RectTransform:
- {fileID: 5534139074864658841}
m_Father: {fileID: 1666992978469506438}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 150, y: -40}
m_SizeDelta: {x: 300, y: 80}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3774508876281835580
CanvasRenderer:

File diff suppressed because one or more lines are too long

View File

@@ -268,6 +268,14 @@ PrefabInstance:
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3334079986954822490, guid: 840f3d8a936b39a41b5896328a692005, type: 3}
propertyPath: m_text
value: Card Album Main Page
objectReference: {fileID: 0}
- target: {fileID: 3623949336760016404, guid: 840f3d8a936b39a41b5896328a692005, type: 3}
propertyPath: m_text
value: Browse your cards!
objectReference: {fileID: 0}
- target: {fileID: 4825712728562046718, guid: 840f3d8a936b39a41b5896328a692005, type: 3}
propertyPath: m_IsActive
value: 0

View File

@@ -15,24 +15,7 @@ namespace Data.CardSystem
{
private static CardSystemManager _instance;
private static bool _isQuitting = false;
public static CardSystemManager Instance
{
get
{
if (_instance == null && Application.isPlaying && !_isQuitting)
{
_instance = FindAnyObjectByType<CardSystemManager>();
if (_instance == null)
{
var go = new GameObject("CardSystemManager");
_instance = go.AddComponent<CardSystemManager>();
DontDestroyOnLoad(go);
}
}
return _instance;
}
}
public static CardSystemManager Instance => _instance;
[Header("Card Collection")]
[SerializeField] private List<CardDefinition> availableCards = new List<CardDefinition>();
@@ -51,14 +34,7 @@ namespace Data.CardSystem
private void Awake()
{
if (_instance != null && _instance != this)
{
Destroy(gameObject);
return;
}
_instance = this;
DontDestroyOnLoad(gameObject);
// Build lookup dictionary
BuildDefinitionLookup();

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1b32796fca0a4b168dfb93a282054c86
timeCreated: 1760951960

View File

@@ -0,0 +1,249 @@
using UnityEngine;
using AppleHills.Data.CardSystem;
using System.Collections.Generic;
using UnityEditor;
using Data.CardSystem;
using Core;
using AppleHills.UI.CardSystem;
using UnityEngine.UI;
namespace AppleHills.Tests
{
/// <summary>
/// Testing component for the Card System. Provides editor buttons to test core functionalities.
/// Place this in a test scene to easily test card system features without needing full game implementation.
/// </summary>
public class CardSystemTester : MonoBehaviour
{
[Header("References")]
[SerializeField] private CardSystemManager cardSystemManager;
[SerializeField] private CardAlbumUI cardAlbumUI;
[Header("Test Settings")]
[SerializeField] [Range(1, 10)] private int boosterPacksToAdd = 3;
[SerializeField] [Range(1, 100)] private int cardsToGenerate = 10;
[SerializeField] private bool autoOpenPacksWhenAdded = false;
[Header("Debug Info")]
[SerializeField] [ReadOnly] private int currentBoosterCount;
[SerializeField] [ReadOnly] private int totalCardsInCollection;
[SerializeField] [ReadOnly] private string lastActionMessage;
private void Awake()
{
// Auto-find references if needed
if (cardSystemManager == null)
cardSystemManager = FindAnyObjectByType<CardSystemManager>();
if (cardAlbumUI == null)
cardAlbumUI = FindAnyObjectByType<CardAlbumUI>();
// Log missing references
if (cardSystemManager == null)
Debug.LogError("CardSystemTester: No CardSystemManager found in the scene!");
if (cardAlbumUI == null)
Debug.LogError("CardSystemTester: No CardAlbumUI found in the scene!");
}
private void Start()
{
RefreshDebugInfo();
}
// Refresh the debug information displayed in the inspector
private void RefreshDebugInfo()
{
if (cardSystemManager != null)
{
currentBoosterCount = cardSystemManager.GetBoosterPackCount();
totalCardsInCollection = cardSystemManager.GetCardInventory().GetAllCards().Count;
}
}
#if UNITY_EDITOR
// Custom editor buttons for testing
public void AddBoosterPacks()
{
if (cardSystemManager != null)
{
cardSystemManager.AddBoosterPack(boosterPacksToAdd);
lastActionMessage = $"Added {boosterPacksToAdd} booster pack(s)";
Logging.Debug($"[CardSystemTester] {lastActionMessage}");
RefreshDebugInfo();
if (autoOpenPacksWhenAdded && cardAlbumUI != null)
{
SimulateBackpackClick();
cardAlbumUI.OpenBoosterPack();
}
}
}
public void SimulateBackpackClick()
{
if (cardAlbumUI != null)
{
// This will show the main card menu
// Manually trigger a click on the backpack icon
// Note: This relies on the backpack icon being correctly set up in the CardAlbumUI
if (cardAlbumUI.BackpackIcon != null)
{
Button backpackButton = cardAlbumUI.BackpackIcon.GetComponent<Button>();
if (backpackButton != null)
{
backpackButton.onClick.Invoke();
lastActionMessage = "Opened card menu via backpack click";
Logging.Debug($"[CardSystemTester] {lastActionMessage}");
}
else
{
lastActionMessage = "Failed to find Button component on backpack icon";
Logging.Warning($"[CardSystemTester] {lastActionMessage}");
}
}
else
{
lastActionMessage = "BackpackIcon reference is null";
Logging.Warning($"[CardSystemTester] {lastActionMessage}");
}
}
}
public void OpenBoosterPack()
{
if (cardAlbumUI != null)
{
SimulateBackpackClick(); // First make sure we've opened the menu
cardAlbumUI.OpenBoosterPack();
lastActionMessage = "Opening booster pack";
Logging.Debug($"[CardSystemTester] {lastActionMessage}");
RefreshDebugInfo();
}
}
public void OpenAlbumView()
{
if (cardAlbumUI != null)
{
SimulateBackpackClick(); // First make sure we've opened the menu
cardAlbumUI.OpenAlbumView();
lastActionMessage = "Opening album view";
Logging.Debug($"[CardSystemTester] {lastActionMessage}");
}
}
public void GenerateRandomCards()
{
if (cardSystemManager != null)
{
int cardsAdded = 0;
List<CardDefinition> allDefinitions = cardSystemManager.GetAllCardDefinitions();
if (allDefinitions.Count == 0)
{
lastActionMessage = "Error: No card definitions available";
Logging.Warning($"[CardSystemTester] {lastActionMessage}");
return;
}
for (int i = 0; i < cardsToGenerate; i++)
{
// Get a random card definition
CardDefinition randomDef = allDefinitions[Random.Range(0, allDefinitions.Count)];
// Create a card data instance and add it to inventory
CardData newCard = randomDef.CreateCardData();
cardSystemManager.GetCardInventory().AddCard(newCard);
cardsAdded++;
}
lastActionMessage = $"Generated {cardsAdded} random cards";
Logging.Debug($"[CardSystemTester] {lastActionMessage}");
RefreshDebugInfo();
}
}
public void ClearAllCards()
{
if (cardSystemManager != null)
{
int count = cardSystemManager.GetCardInventory().GetAllCards().Count;
cardSystemManager.GetCardInventory().ClearAllCards();
lastActionMessage = $"Cleared {count} cards from inventory";
Logging.Debug($"[CardSystemTester] {lastActionMessage}");
RefreshDebugInfo();
}
}
#endif
// Update is called once per frame
void Update()
{
}
}
#if UNITY_EDITOR
[CustomEditor(typeof(CardSystemTester))]
public class CardSystemTesterEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
CardSystemTester tester = (CardSystemTester)target;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Test Actions", EditorStyles.boldLabel);
if (GUILayout.Button("Add Booster Packs"))
{
tester.AddBoosterPacks();
}
if (GUILayout.Button("Open Card Menu"))
{
tester.SimulateBackpackClick();
}
if (GUILayout.Button("Open Booster Pack"))
{
tester.OpenBoosterPack();
}
if (GUILayout.Button("Open Album View"))
{
tester.OpenAlbumView();
}
EditorGUILayout.Space();
if (GUILayout.Button("Generate Random Cards"))
{
tester.GenerateRandomCards();
}
if (GUILayout.Button("Clear All Cards"))
{
tester.ClearAllCards();
}
}
}
#endif
}
// Simple attribute to make fields read-only in the inspector
public class ReadOnlyAttribute : PropertyAttribute { }
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public class ReadOnlyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUI.enabled = false;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true;
}
}
#endif

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6c59c766505c4342983594dbe19f3db0
timeCreated: 1760951960

View File

@@ -19,6 +19,7 @@ namespace AppleHills.UI.CardSystem
[SerializeField] private Button openBoosterButton;
[SerializeField] private Button viewAlbumButton;
[SerializeField] private Button changeClothesButton;
[SerializeField] private Button backButton; // Added back button field
[Header("UI Elements")]
[SerializeField] private BoosterNotificationDot boosterNotificationDot; // Changed to BoosterNotificationDot
@@ -56,6 +57,11 @@ namespace AppleHills.UI.CardSystem
// Disable "Coming Soon" feature
changeClothesButton.interactable = false;
}
if (backButton != null) // Set up back button listener
{
backButton.onClick.AddListener(OnBackButtonClicked);
}
}
private void OnEnable()
@@ -80,6 +86,11 @@ namespace AppleHills.UI.CardSystem
{
changeClothesButton.onClick.RemoveListener(OnChangeClothesClicked);
}
if (backButton != null) // Clean up back button listener
{
backButton.onClick.RemoveListener(OnBackButtonClicked);
}
}
/// <summary>
@@ -142,6 +153,20 @@ namespace AppleHills.UI.CardSystem
Logging.Debug("[CardMenuPage] Change Clothes feature coming soon!");
// No implementation yet - "Coming soon" feature
}
/// <summary>
/// Handles click on the Back button
/// </summary>
private void OnBackButtonClicked()
{
// Use the UIPageController to pop this page
// This will hide the card menu and return to the game
if (UIPageController.Instance != null)
{
UIPageController.Instance.PopPage();
Logging.Debug("[CardMenuPage] Exiting card menu back to game");
}
}
/// <summary>
/// Override for transition in animation using Pixelplacement.Tween

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Bootstrap;
using Core;
using UnityEngine;
using UnityEngine.InputSystem;
namespace AppleHills.UI.CardSystem
{
@@ -21,6 +22,9 @@ namespace AppleHills.UI.CardSystem
// Event fired when the page stack changes
public event Action<UIPage> OnPageChanged;
private PlayerInput _playerInput;
private InputAction _cancelAction;
private void Awake()
{
if (_instance != null && _instance != this)
@@ -31,9 +35,46 @@ namespace AppleHills.UI.CardSystem
_instance = this;
// TODO: Handle generic "cancel" action
// _playerInput = FindFirstObjectByType<PlayerInput>();
// if (_playerInput == null)
// {
// Logging.Warning("[UIPageController] No PlayerInput found in the scene. Cancel action might not work.");
// }
// else
// {
// // Get the Cancel action from the UI action map
// _cancelAction = _playerInput.actions.FindAction("UI/Cancel");
// if (_cancelAction != null)
// {
// _cancelAction.performed += OnCancelActionPerformed;
// }
// else
// {
// Logging.Warning("[UIPageController] Cancel action not found in the input actions asset.");
// }
// }
// Register for post-boot initialization
BootCompletionService.RegisterInitAction(InitializePostBoot);
}
private void OnDestroy()
{
// Clean up event subscription when the controller is destroyed
if (_cancelAction != null)
{
_cancelAction.performed -= OnCancelActionPerformed;
}
}
private void OnCancelActionPerformed(InputAction.CallbackContext context)
{
if (_pageStack.Count > 0)
{
_pageStack.Peek().OnBackPressed();
}
}
private void InitializePostBoot()
{
@@ -105,16 +146,5 @@ namespace AppleHills.UI.CardSystem
OnPageChanged?.Invoke(null);
Logging.Debug("[UIPageController] Cleared page stack");
}
/// <summary>
/// Handles back button input and navigates to the previous page if possible.
/// </summary>
private void Update()
{
if (UnityEngine.Input.GetKeyDown(KeyCode.Escape) && _pageStack.Count > 0)
{
_pageStack.Peek().OnBackPressed();
}
}
}
}