113 lines
3.3 KiB
C#
113 lines
3.3 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class GetItemWindows : SingletonMonoBehaviour<GetItemWindows>
|
|
{
|
|
//아이템 획득 정보 필요
|
|
//아이템 이펙트
|
|
|
|
[SerializeField] GameObject itemImgPrefab;
|
|
[SerializeField] Transform content;
|
|
[SerializeField] List<itemImgPrefab> items = new List<itemImgPrefab>();
|
|
RectTransform rect;
|
|
|
|
private bool isAnim = false;
|
|
|
|
private readonly float minWidth = 1600f;
|
|
private readonly float boxSize = 150f;
|
|
private readonly float spacing = 50f;
|
|
protected override void OnAwake()
|
|
{
|
|
gameObject.SetActive(false);
|
|
rect = content.GetComponent<RectTransform>();
|
|
for (int n = 0; n < 50; n++)
|
|
{
|
|
items.Add(Instantiate(itemImgPrefab, content).GetComponent<itemImgPrefab>());
|
|
items[n].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void SetUI(long addGold, long addCash, List<DeckUnitInfo> deckUnit, List<Equipment> equipment, List<ConsumableItem> consumableItem, List<EtcItem> etcItem)
|
|
{
|
|
isAnim = true;
|
|
gameObject.SetActive(true);
|
|
int num = 0;
|
|
if (addGold > 0)
|
|
{
|
|
Debug.Log($"{addGold}골드 획득!");
|
|
items[num].Set(GameManager.Instance.gold, addGold);
|
|
num++;
|
|
}
|
|
|
|
if (addCash > 0)
|
|
{
|
|
Debug.Log($"{addCash}케쉬 획득!");
|
|
items[num].Set(GameManager.Instance.cash, addCash);
|
|
num++;
|
|
}
|
|
|
|
if (deckUnit != null && deckUnit.Count != 0)
|
|
{
|
|
for(int n = 0; n < deckUnit.Count; n++)
|
|
{
|
|
Debug.Log($"{deckUnit[n].unit_data_id}케릭터 획득!");
|
|
items[num++].Set(null, 0);
|
|
}
|
|
}
|
|
if (equipment != null && equipment.Count != 0)
|
|
{
|
|
for (int n = 0; n < equipment.Count; n++)
|
|
{
|
|
Debug.Log($"{equipment[n].equipment_data_id}장비 획득!");
|
|
items[num++].Set(null, 0);
|
|
}
|
|
}
|
|
if (consumableItem != null && consumableItem.Count != 0)
|
|
{
|
|
for (int n = 0; n < consumableItem.Count; n++)
|
|
{
|
|
Debug.Log($"{consumableItem[n].consumable_item_data_id}아이탬 {consumableItem[n].count}개획득!");
|
|
items[num++].Set(null, consumableItem[n].count);
|
|
}
|
|
}
|
|
if (etcItem != null && etcItem.Count != 0)
|
|
{
|
|
for (int n = 0; n < etcItem.Count; n++)
|
|
{
|
|
Debug.Log($"{etcItem[n].etc_item_data_id}아이탬 {etcItem[n].count}개획득!");
|
|
items[num++].Set(null,0);
|
|
}
|
|
}
|
|
|
|
float size = (boxSize * num) + (spacing * num);
|
|
rect.offsetMin = Vector2.zero;
|
|
rect.offsetMax = new Vector2(minWidth < size ? size : minWidth, 0);
|
|
|
|
isAnim = false;
|
|
}
|
|
|
|
public void OnExit()
|
|
{
|
|
for (int n = 0; n < items.Count; n++)
|
|
{
|
|
if (items[n].gameObject.activeSelf)
|
|
items[n].gameObject.SetActive(false);
|
|
else
|
|
break;
|
|
}
|
|
if (!isAnim)
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
|
|
[ContextMenu("test")]
|
|
public void test()
|
|
{
|
|
Debug.Log(content.GetComponent<RectTransform>().offsetMin);
|
|
Debug.Log(content.GetComponent<RectTransform>().offsetMax);
|
|
}
|
|
}
|