少年修仙传客户端代码仓库
client_Wu Xijin
2018-10-26 19997f58e0df812218eb50074acdba8b6ad6fe49
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections;
using System.Collections.Generic;
using TableConfig;
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    public class PutawayItem : MonoBehaviour
    {
        [SerializeField] Button m_Buy;
        [SerializeField] Text m_Price;
        [SerializeField] Image m_ItemBG;
        [SerializeField] Image m_ItemIcon;
        [SerializeField] Text m_ItemName;
        [SerializeField] Text m_ItemCount;
        [SerializeField] Transform[] m_Stars;
 
        public void Init(MarketItemData data, Action<MarketItemData> callback)
        {
            ItemConfig config = Config.Instance.Get<ItemConfig>((int)data.ItemTypeID);
            int uintprice = (int)data.PriceCount / data.Count;
            if (uintprice < 1)
            {
                m_Price.text = "<1";
            }
            else
            {
                m_Price.text = data.PriceCount.ToString();
            }
            m_Buy.onClick.RemoveAllListeners();
            m_Buy.onClick.AddListener(() =>
            {
                if (callback != null)
                {
                    callback(data);
                }
            });
            if (config != null)
            {
                m_ItemName.text = config.ItemName;
                var itemColor = config.ItemColor;
                if (config.Type == 111)//翅膀
                {
                    itemColor = UIHelper.GetItemColor(config.ID, ConfigParse.Analysis(data.UserData));
                }
                m_ItemBG.SetItemBackGround(itemColor);
                bool _bright = (m_ItemName is RichText) ? (m_ItemName as RichText).colorType == RichText.ColorType.Bright : true;
                m_ItemName.color = UIHelper.GetUIColor(itemColor, _bright);
                m_ItemIcon.SetSprite(config.IconKey);
                for (int i = 0; i < m_Stars.Length; i++)
                {
                    if (i < config.StarLevel)
                    {
                        m_Stars[i].gameObject.SetActive(true);
                    }
                    else
                    {
                        m_Stars[i].gameObject.SetActive(false);
                    }
                }
            }
            if (data.Count == 1)
            {
                m_ItemCount.gameObject.SetActive(false);
            }
            else
            {
                m_ItemCount.gameObject.SetActive(true);
                m_ItemCount.text = data.Count.ToString();
            }
        }
    }
}