少年修仙传客户端代码仓库
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, December 11, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    [XLua.Hotfix]
    public class GatherSoulTipWin : Window
    {
        [SerializeField] CanvasGroup m_CanvaGroup;
        [SerializeField] Image m_EquipedSign;
        [SerializeField] GatherSoulTipBase m_Base;
        [SerializeField] ScrollRect m_Scroller;
        [SerializeField] LayoutElement m_ScrollerLayout;
        [SerializeField] VerticalLayoutGroup m_ContentLayout;
        [SerializeField] GatherSoulTipProperty m_Property;
        [SerializeField] GatherSoulTipResolve m_Resolve;
        [SerializeField] RectTransform m_ContainerGetWay;
        [SerializeField] Button[] m_Funcs;
        [SerializeField] Text[] m_FuncBtnDisplays;
        [SerializeField] RectTransform[] m_Redpoints;
        [SerializeField] Text m_GetWay;
 
        [SerializeField] Button m_Close;
 
        [SerializeField] Vector2 m_ScrollerHeight = new Vector2(180, 260);
 
        GatheringSoulModel model
        {
            get { return ModelCenter.Instance.GetModel<GatheringSoulModel>(); }
        }
 
        ItemTipUtility.TipData tipData
        {
            get { return ItemTipUtility.mainTipData; }
        }
 
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_Close.onClick.AddListener(CloseClick);
        }
 
        protected override void OnPreOpen()
        {
            DisplayEquipedSign();
            Display();
            DisplayGetWay();
            DisplayFuncs();
 
            m_CanvaGroup.alpha = 0;
            m_Scroller.verticalNormalizedPosition = 1;
        }
 
        protected override void OnActived()
        {
            base.OnActived();
            transform.SetAsLastSibling();
            StartCoroutine(Co_GetHeight());
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            StopAllCoroutines();
        }
 
        protected override void OnAfterClose()
        {
        }
        #endregion
 
        IEnumerator Co_GetHeight()
        {
            yield return null;
            yield return null;
            var height = m_Property.GetHeight();
            height += m_Resolve.GetHeight();
            height += m_ContentLayout.padding.top;
            height += m_ContentLayout.padding.bottom;
            height += m_ContentLayout.spacing * 1;
            height = Mathf.Clamp(height, m_ScrollerHeight.x, m_ScrollerHeight.y);
            m_ScrollerLayout.preferredHeight = height;
            yield return null;
            m_CanvaGroup.alpha = 1;
        }
 
        void DisplayEquipedSign()
        {
            var packType = ItemTipUtility.mainTipData.gatherSoul.packType;
            m_EquipedSign.gameObject.SetActive(packType == PackType.InterimPack);
        }
 
        void Display()
        {
            var id = tipData.itemId;
            var level = tipData.gatherSoul.level;
            m_Base.Display(id, level);
            m_Property.Display(id, level);
            m_Resolve.Display(id, level);
        }
 
        void DisplayGetWay()
        {
            var config = ItemConfig.Get(tipData.itemId);
            m_ContainerGetWay.gameObject.SetActive(config != null && !string.IsNullOrEmpty(config.Description));
            if (config != null && !string.IsNullOrEmpty(config.Description))
            {
                m_GetWay.text = config.Description;
            }
        }
 
        void DisplayFuncs()
        {
            var operates = tipData.operates;
            var index = 0;
            if (operates != null)
            {
                foreach (var type in operates)
                {
                    var callBackType = type;
                    if (index < m_Funcs.Length)
                    {
                        m_Funcs[index].gameObject.SetActive(true);
                        m_Funcs[index].RemoveAllListeners();
                        m_Funcs[index].AddListener(() =>
                        {
                            ItemTipUtility.GatherSoulOperate(callBackType);
                        });
                        m_FuncBtnDisplays[index].text = Language.Get(StringUtility.Contact("ItemHandle_", callBackType));
                        m_Redpoints[index].gameObject.SetActive(false);
 
                        if (callBackType == ItemOperateType.LevelUp)
                        {
                            m_Redpoints[index].gameObject.SetActive(model.levelUpRedpoint.state == RedPointState.Simple
                              && tipData.gatherSoul.packType == PackType.InterimPack
                              && model.levelUpRedpointHole == tipData.gatherSoul.index);
                        }
                        else if (callBackType == ItemOperateType.Replace)
                        {
                            m_Redpoints[index].gameObject.SetActive(model.replaceRedpoint.state == RedPointState.Simple
                                && tipData.gatherSoul.packType == PackType.GatherSoul
                                && tipData.gatherSoul.index == model.replaceRedpointIndex);
                        }
                    }
                    index++;
                }
            }
            for (int i = index; i < m_Funcs.Length; i++)
            {
                m_Funcs[i].gameObject.SetActive(false);
            }
        }
    }
}