少年修仙传客户端代码仓库
client_Wu Xijin
2018-09-21 b24abe465bdc9725f7225aea36b049c9f99a94a5
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
76
77
78
79
80
81
82
83
84
85
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, October 13, 2017
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using Snxxz.UI;
using TableConfig;
 
namespace Snxxz.UI
{
 
    public class PotentialItemBehaviour : ScrollItem
    {
        [SerializeField]
        ItemBehaviour m_ItemBehaviour;
        [SerializeField]
        Text m_CostCount;
        [SerializeField]
        Text m_SuccessRatio;
        [SerializeField]
        Button m_Click;
        [SerializeField]
        Text m_AddBtnText;
        [SerializeField]
        SmoothMask m_SmoothMask;
 
        TreasureModel m_Model;
        TreasureModel model { get { return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<TreasureModel>()); } }
 
        PlayerPackModel _playerPack;
        PlayerPackModel playerPack
        {
            get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
        }
 
        int own = 0;
        int need = 0;
        PotentialBook potentialBook;
 
        public override void Display(object _data)
        {
            base.Display(_data);
 
            potentialBook = (PotentialBook)_data;
 
            own = playerPack.GetItemCountByID(PackType.rptItem,potentialBook.itemId);
            need = potentialBook.needCount;
            m_ItemBehaviour.showCount = false;
            m_ItemBehaviour.SetItem(potentialBook.itemId, 1);
            m_CostCount.text = StringUtility.Contact(own, "/", need);
            m_CostCount.color = own >= need ? UIHelper.GetUIColor(TextColType.White) : UIHelper.GetUIColor(TextColType.Red);
            //m_Click.interactable = own >= need;
            m_AddBtnText.color = own >= need ? UIHelper.GetUIColor(TextColType.NavyBrown) : UIHelper.GetUIColor(TextColType.White);
            //m_Click.image.material = own >= need ? m_SmoothMask.imageMaterials[0] : m_SmoothMask.imageMaterials[1];
            var config = Config.Instance.Get<TreasureSkillConfig>(potentialBook.levelUpId);
            var upRate = potentialBook.successRate - config.InitialRate;
            m_SuccessRatio.text = Language.Get("HallowsWin_UpSuccess", StringUtility.Contact((upRate * 0.01f).ToString("f0"), "%"));
        }
 
        private void SelectPotentialBook()
        {
            //if (own >= need)
            //{
                model.selectedPotentialBook = potentialBook.itemId;
                WindowCenter.Instance.Close<PotentialItemUseWin>();
            //}
            //else
            //{
            //    SysNotifyMgr.Instance.ShowTip("SPItemNotEnough");
            //}
        }
 
        private void Awake()
        {
            m_Click.AddListener(SelectPotentialBook);
        }
 
    }
 
}