chenxin
2020-10-27 e33d0e85cf5d01e953d95197488eeffc67835f3a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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/";
 
        /// <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);
                }
            }
        }
    }
}