Setup more of the card system stuff

This commit is contained in:
Michal Pikulski
2025-10-17 16:17:50 +02:00
committed by Michal Adam Pikulski
parent b1df36d48c
commit 80005e6b7d
8 changed files with 1029 additions and 1703 deletions

View File

@@ -25,12 +25,12 @@ RectTransform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3555924788298046233} m_GameObject: {fileID: 3555924788298046233}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 4399514539281523652} m_Father: {fileID: 8243838592031101330}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
@@ -75,6 +75,43 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 m_PixelsPerUnitMultiplier: 1
--- !u!1 &3813704348964656314
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8243838592031101330}
m_Layer: 5
m_Name: Container
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8243838592031101330
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3813704348964656314}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2510839793683184596}
- {fileID: 912809337432025300}
m_Father: {fileID: 4399514539281523652}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &4367103374191057909 --- !u!1 &4367103374191057909
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -100,12 +137,12 @@ RectTransform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4367103374191057909} m_GameObject: {fileID: 4367103374191057909}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 4399514539281523652} m_Father: {fileID: 8243838592031101330}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
@@ -220,6 +257,8 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 4399514539281523652} - component: {fileID: 4399514539281523652}
- component: {fileID: 7701049314552813552}
- component: {fileID: 6728421751561708195}
m_Layer: 5 m_Layer: 5
m_Name: BoosterNotifications m_Name: BoosterNotifications
m_TagString: Untagged m_TagString: Untagged
@@ -239,8 +278,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 2510839793683184596} - {fileID: 8243838592031101330}
- {fileID: 912809337432025300}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1} m_AnchorMin: {x: 1, y: 1}
@@ -248,3 +286,49 @@ RectTransform:
m_AnchoredPosition: {x: 37.5, y: 37.5} m_AnchoredPosition: {x: 37.5, y: 37.5}
m_SizeDelta: {x: 75, y: 75} m_SizeDelta: {x: 75, y: 75}
m_Pivot: {x: 1, y: 1} m_Pivot: {x: 1, y: 1}
--- !u!114 &7701049314552813552
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6686144552275602124}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ed8cced1478640229c5a61e3c6bd42df, type: 3}
m_Name:
m_EditorClassIdentifier: AppleHillsScripts::AppleHills.UI.CardSystem.BoosterNotificationDot
dotBackground: {fileID: 3813704348964656314}
countText: {fileID: 7140808185011848511}
hideWhenZero: 1
useAnimation: 1
textPrefix:
textSuffix:
textColor: {r: 1, g: 1, b: 1, a: 1}
useTween: 1
pulseDuration: 0.3
pulseScale: 1.2
animator: {fileID: 6728421751561708195}
animationTrigger: Update
--- !u!95 &6728421751561708195
Animator:
serializedVersion: 7
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6686144552275602124}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 0}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_AnimatePhysics: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: c14aa7cdf8bbc614a9db84180151aab9 guid: 43be0f1cce1e5ae4d86def9da1fe2822
PrefabImporter: PrefabImporter:
externalObjects: {} externalObjects: {}
userData: userData:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,185 @@
using UnityEngine;
using TMPro;
using Pixelplacement;
using Pixelplacement.TweenSystem;
namespace AppleHills.UI.CardSystem
{
/// <summary>
/// Manages a notification dot that displays a count (e.g., booster packs)
/// Can be reused across different UI elements that need to show numeric notifications
/// </summary>
public class BoosterNotificationDot : MonoBehaviour
{
[Header("UI References")]
[SerializeField] private GameObject dotBackground;
[SerializeField] private TextMeshProUGUI countText;
[Header("Settings")]
[SerializeField] private bool hideWhenZero = true;
[SerializeField] private bool useAnimation = false;
[SerializeField] private string textPrefix = "";
[SerializeField] private string textSuffix = "";
[SerializeField] private Color textColor = Color.white;
[Header("Animation")]
[SerializeField] private bool useTween = true;
[SerializeField] private float pulseDuration = 0.3f;
[SerializeField] private float pulseScale = 1.2f;
// Optional animator reference
[SerializeField] private Animator animator;
[SerializeField] private string animationTrigger = "Update";
// Current count value
private int _currentCount;
private Vector3 _originalScale;
private TweenBase _activeTween;
private void Awake()
{
// Store original scale for pulse animation
if (dotBackground != null)
{
_originalScale = dotBackground.transform.localScale;
}
// Apply text color
if (countText != null)
{
countText.color = textColor;
}
// Initial setup based on current count
SetCount(_currentCount);
}
/// <summary>
/// Sets the count displayed on the notification dot
/// Also handles visibility based on settings
/// </summary>
public void SetCount(int count)
{
bool countChanged = count != _currentCount;
_currentCount = count;
// Update text
if (countText != null)
{
countText.text = textPrefix + count.ToString() + textSuffix;
}
// Handle visibility
if (hideWhenZero)
{
SetVisibility(count > 0);
}
// Play animation if value changed and animation is enabled
if (countChanged && count > 0)
{
if (useAnimation)
{
Animate();
}
}
}
/// <summary>
/// Gets the current count value
/// </summary>
public int GetCount()
{
return _currentCount;
}
/// <summary>
/// Set text formatting options
/// </summary>
public void SetFormatting(string prefix, string suffix, Color color)
{
textPrefix = prefix;
textSuffix = suffix;
textColor = color;
if (countText != null)
{
countText.color = color;
// Update text with new formatting
countText.text = textPrefix + _currentCount.ToString() + textSuffix;
}
}
/// <summary>
/// Explicitly control the notification dot visibility
/// </summary>
public void SetVisibility(bool isVisible)
{
if (dotBackground != null)
{
dotBackground.SetActive(isVisible);
}
if (countText != null)
{
countText.gameObject.SetActive(isVisible);
}
}
/// <summary>
/// Show the notification dot
/// </summary>
public void Show()
{
SetVisibility(true);
}
/// <summary>
/// Hide the notification dot
/// </summary>
public void Hide()
{
SetVisibility(false);
}
/// <summary>
/// Play animation manually - either using Animator or Tween
/// </summary>
public void Animate()
{
if (useAnimation)
{
if (animator != null)
{
animator.SetTrigger(animationTrigger);
}
else if (useTween && dotBackground != null)
{
// Cancel any existing tweens on this transform
_activeTween.Cancel();
// Reset to original scale
dotBackground.transform.localScale = _originalScale;
// Pulse animation using Tween
_activeTween = Tween.LocalScale(dotBackground.transform,
_originalScale * pulseScale,
pulseDuration/2,
0,
Tween.EaseOut,
Tween.LoopType.None,
null,
() => {
// Scale back to original size
Tween.LocalScale(dotBackground.transform,
_originalScale,
pulseDuration/2,
0,
Tween.EaseIn);
});
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ed8cced1478640229c5a61e3c6bd42df
timeCreated: 1760710148

View File

@@ -23,8 +23,7 @@ namespace AppleHills.UI.CardSystem
[Header("UI Elements")] [Header("UI Elements")]
[SerializeField] private Button backpackButton; [SerializeField] private Button backpackButton;
[SerializeField] private Text boosterCountText; [SerializeField] private BoosterNotificationDot boosterNotificationDot; // Changed to BoosterNotificationDot
[SerializeField] private GameObject notificationDot;
[SerializeField] private GameObject backpackAnimationTarget; [SerializeField] private GameObject backpackAnimationTarget;
[SerializeField] private GameObject newCardNotification; [SerializeField] private GameObject newCardNotification;
@@ -62,8 +61,8 @@ namespace AppleHills.UI.CardSystem
ShowOnlyBackpackIcon(); ShowOnlyBackpackIcon();
// Hide notifications initially // Hide notifications initially
if (notificationDot != null) if (boosterNotificationDot != null)
notificationDot.SetActive(false); boosterNotificationDot.gameObject.SetActive(false);
if (newCardNotification != null) if (newCardNotification != null)
newCardNotification.SetActive(false); newCardNotification.SetActive(false);
@@ -154,8 +153,8 @@ namespace AppleHills.UI.CardSystem
_pageController.PushPage(mainMenuPage); _pageController.PushPage(mainMenuPage);
// Clear notification // Clear notification
if (notificationDot != null) if (boosterNotificationDot != null)
notificationDot.SetActive(false); boosterNotificationDot.gameObject.SetActive(false);
_hasUnseenCards = false; _hasUnseenCards = false;
} }
@@ -269,13 +268,13 @@ namespace AppleHills.UI.CardSystem
/// </summary> /// </summary>
private void UpdateBoosterCount(int count) private void UpdateBoosterCount(int count)
{ {
if (boosterCountText != null) if (boosterNotificationDot != null)
{ {
boosterCountText.text = count.ToString(); boosterNotificationDot.SetCount(count);
// Animate the text for feedback // Animate the text for feedback
boosterCountText.transform.localScale = Vector3.one * 1.2f; boosterNotificationDot.transform.localScale = Vector3.one * 1.2f;
Tween.LocalScale(boosterCountText.transform, Vector3.one, 0.3f, 0f); Tween.LocalScale(boosterNotificationDot.transform, Vector3.one, 0.3f, 0f);
} }
} }
@@ -299,8 +298,8 @@ namespace AppleHills.UI.CardSystem
_pageController.CurrentPage != boosterOpeningPage) _pageController.CurrentPage != boosterOpeningPage)
{ {
_hasUnseenCards = true; _hasUnseenCards = true;
if (notificationDot != null) if (boosterNotificationDot != null)
notificationDot.SetActive(true); boosterNotificationDot.gameObject.SetActive(true);
} }
Logging.Debug($"[CardAlbumUI] New card collected: {card.Name}"); Logging.Debug($"[CardAlbumUI] New card collected: {card.Name}");

View File

@@ -3,7 +3,7 @@ using AppleHills.Data.CardSystem;
using Core; using Core;
using Data.CardSystem; using Data.CardSystem;
using Pixelplacement; using Pixelplacement;
using TMPro; // Added TMP namespace using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@@ -21,7 +21,7 @@ namespace AppleHills.UI.CardSystem
[SerializeField] private Button changeClothesButton; [SerializeField] private Button changeClothesButton;
[Header("UI Elements")] [Header("UI Elements")]
[SerializeField] private TextMeshProUGUI boosterCountText; // Changed to TextMeshProUGUI [SerializeField] private BoosterNotificationDot boosterNotificationDot; // Changed to BoosterNotificationDot
[SerializeField] private CanvasGroup canvasGroup; [SerializeField] private CanvasGroup canvasGroup;
private CardAlbumUI _cardAlbumUI; private CardAlbumUI _cardAlbumUI;
@@ -91,10 +91,10 @@ namespace AppleHills.UI.CardSystem
int boosterCount = _cardManager.GetBoosterPackCount(); int boosterCount = _cardManager.GetBoosterPackCount();
// Update booster count text // Update booster count text using the notification dot
if (boosterCountText != null) if (boosterNotificationDot != null)
{ {
boosterCountText.text = $"Boosters: {boosterCount}"; boosterNotificationDot.SetCount(boosterCount);
} }
// Enable/disable open booster button based on availability // Enable/disable open booster button based on availability