using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using TowerDefense.Level;
|
using UnityEngine.UI;
|
|
/**
|
* 无尽模式结算界面列表脚本
|
* @Author: chenxin
|
* @Date: 2020-10-22 11:06:15
|
*/
|
namespace KTGMGemClient
|
{
|
public class EndlessSettlementPropList : MonoBehaviour
|
{
|
public GameObject ItemPrefab;
|
|
public GameObject Grid;
|
|
private string iconPath = "UI/Props/";
|
|
private string bgPath = "UI/Props/Di/";
|
|
/// <summary>
|
/// 刷新道具列表
|
/// </summary>
|
public void RefreshList()
|
{
|
List<EndlessDrop> list = EndlessDropManager.instance.GetAllObtainedDrop();
|
|
for (int i = 0; i < list.Count; ++i)
|
{
|
for (int j = 0; j < list[i].Reward.count; ++j)
|
{
|
GameObject item = Instantiate(ItemPrefab);
|
EndlessPropIcon propIcon = item.GetComponent<EndlessPropIcon>();
|
string resId = list[i].Reward.id == 0 ? resId = $"{(int)list[i].Reward.type}" : $"{list[i].Reward.type}_{list[i].Reward.id}";
|
|
Sprite iconSp = Resources.Load<Sprite>($"{iconPath}{resId}");
|
Sprite bgSp = Resources.Load<Sprite>($"{bgPath}{resId}");
|
|
propIcon.SetIcon(iconSp);
|
propIcon.SetBg(bgSp);
|
item.transform.SetParent(Grid.transform, false);
|
}
|
}
|
}
|
}
|
}
|