[TASK] Show collected duck stickers
This commit is contained in:
37
Assets/CollectedStickersUI.cs
Normal file
37
Assets/CollectedStickersUI.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CollectedStickersUI : MonoBehaviour
|
||||
{
|
||||
public Transform collectedStickerParent;
|
||||
public StickerDisplay stickerDisplayPrefab;
|
||||
|
||||
private readonly Dictionary<DuckStickerData, StickerDisplay> _stickerDisplays = new Dictionary<DuckStickerData, StickerDisplay>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
RefreshStickerDisplay();
|
||||
}
|
||||
|
||||
public void OnStickerCollected(DuckStickerData sticker)
|
||||
{
|
||||
RefreshStickerDisplay();
|
||||
}
|
||||
|
||||
private void RefreshStickerDisplay()
|
||||
{
|
||||
var collectedStickers = DuckStickerManager.Instance.CollectedStickers;
|
||||
foreach (var sticker in collectedStickers)
|
||||
{
|
||||
if (!_stickerDisplays.ContainsKey(sticker))
|
||||
{
|
||||
var stickerDisplay = Instantiate(stickerDisplayPrefab, collectedStickerParent);
|
||||
stickerDisplay.Sticker = sticker;
|
||||
_stickerDisplays.Add(sticker, stickerDisplay);
|
||||
}
|
||||
_stickerDisplays[sticker].CollectedCount = DuckStickerManager.Instance.GetStickerCollectedCount(sticker);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user