[TASK] Show collected duck stickers

This commit is contained in:
2019-08-24 00:31:21 +02:00
parent 279c5fbbbe
commit c8ab81a848
43 changed files with 4969 additions and 97 deletions

View 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);
}
}
}