少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    [XLua.Hotfix]
    public class GatherSoulHoleBehaviour : MonoBehaviour
    {
        [SerializeField] int hole;
        [SerializeField] RectTransform m_ContainreItem;
        [SerializeField] RectTransform m_ContainerEquipSign;
        [SerializeField] RectTransform m_ContainerLock;
        [SerializeField] RectTransform m_ContaienrRedpoint;
        [SerializeField] Image m_Icon;
        [SerializeField] Text m_ItemName;
        [SerializeField] Text m_Level;
        [SerializeField] Text m_Condition;
        [SerializeField] Button m_Func;
 
        GatheringSoulModel model
        {
            get { return ModelCenter.Instance.GetModel<GatheringSoulModel>(); }
        }
 
        GatherSoulComposeModel composeModel
        {
            get { return ModelCenter.Instance.GetModel<GatherSoulComposeModel>(); }
        }
 
        bool existItem = false;
 
        private void Awake()
        {
            m_Func.onClick.AddListener(OnFunc);
        }
 
        public void Display()
        {
            model.gatherSoulHoleRefresh -= GatherSoulHoleRefresh;
            model.gatherSoulHoleRefresh += GatherSoulHoleRefresh;
 
            RedpointCenter.Instance.redpointValueChangeEvent -= RedpointValueChangeEvent;
            RedpointCenter.Instance.redpointValueChangeEvent += RedpointValueChangeEvent;
 
            DisplayBase();
            DisplayRedpoint();
        }
 
        void DisplayBase()
        {
            bool unlockHole = model.IsHoleUnlock(hole);
            GatherSoulItem item;
            bool equiped = model.TryGetItem(hole, out item);
            m_ContainreItem.gameObject.SetActive(equiped);
            m_ContainerLock.gameObject.SetActive(!unlockHole);
            m_ContainerEquipSign.gameObject.SetActive(!equiped && unlockHole);
            existItem = equiped;
            if (equiped)
            {
                var config = ItemConfig.Get(item.id);
                m_Icon.SetSprite(config.IconKey);
                m_ItemName.text = config.ItemName;
                m_Level.text = item.level.ToString();
                m_ItemName.color = UIHelper.GetUIColor(config.ItemColor);
            }
            if (!unlockHole)
            {
                DisplayCondition();
            }
        }
 
        void DisplayCondition()
        {
            GatherSoulHoleCondition condition;
            if (model.TryGetHoleCondition(hole, out condition))
            {
                m_Condition.text = Language.Get("GatherSoulHoleOpenCondition", condition.level);
            }
        }
 
        private void OnFunc()
        {
            if (!model.IsHoleUnlock(hole))
            {
                GatherSoulHoleCondition condition;
                if (model.TryGetHoleCondition(hole, out condition))
                {
                    SysNotifyMgr.Instance.ShowTip("GatherSoulHoleOpenCondition", condition.level);
                }
            }
            else
            {
                GatherSoulItem item;
                if (model.TryGetItem(hole, out item))
                {
                    ItemTipUtility.ShowGatherSoul(PackType.InterimPack, hole);
                }
                else
                {
                    if (!model.ContainsEquipSoul(hole))
                    {
                        SysNotifyMgr.Instance.ShowTip("NoneSoulSatisfyEquip");
                    }
                    else
                    {
                        GatherSoulEquipListWin.selectHole = hole;
                        WindowCenter.Instance.Open<GatherSoulEquipListWin>();
                    }
                }
            }
        }
 
        private void RedpointValueChangeEvent(int id)
        {
            if (id == model.equipRedpoint.id || id == model.levelUpRedpoint.id
                || id == model.replaceRedpoint.id)
            {
                DisplayRedpoint();
            }
        }
 
        void DisplayRedpoint()
        {
            bool requireRedpoint = (model.equipRedpoint.state == RedPointState.Simple && model.equipRedpointHole == hole)
                || (model.levelUpRedpoint.state == RedPointState.Simple && model.levelUpRedpointHole == hole);
            m_ContaienrRedpoint.gameObject.SetActive(requireRedpoint);
        }
 
        private void GatherSoulHoleRefresh(int hole)
        {
            if (this.hole == hole)
            {
                bool exist = existItem;
                DisplayBase();
                if (!exist && existItem && model.serverInited)
                {
                    EffectMgr.Instance.PlayUIEffect(3079, 2100, transform, false);
                }
            }
        }
 
        public void Dispose()
        {
            model.gatherSoulHoleRefresh -= GatherSoulHoleRefresh;
            RedpointCenter.Instance.redpointValueChangeEvent -= RedpointValueChangeEvent;
        }
    }
}