using System.Collections; using System.Collections.Generic; using UnityEngine; using TowerDefense.Level; /** * 无尽模式结算界面列表脚本 * @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/"; /// /// 刷新道具列表 /// public void RefreshList() { List 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(); 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($"{iconPath}{resId}"); Sprite bgSp = Resources.Load($"{bgPath}{resId}"); propIcon.SetIcon(iconSp); propIcon.SetBg(bgSp); item.transform.SetParent(Grid.transform); } } } } }