少年修仙传客户端代码仓库
lcy
3 天以前 6d8908e1fcfb62e174d1fa60eb6aa31f65dff3e1
提交 | 用户 | age
a27c7f 1 //--------------------------------------------------------
H 2 //    [Author]:           第二世界
3 //    [  Date ]:           Tuesday, June 11, 2019
4 //--------------------------------------------------------
5
6 using UnityEngine.UI;
7 using System.Collections.Generic;
8 using vnxbqy.UI;
9 using UnityEngine;
10 using System;
11
12 public class TreasurePavilionUpgradeWin : ILWindow
13 {
14     Button m_Close;
15     Button starButton;
16     Button lvButton;
17     RedpointBehaviour starRedPoint;
18     RedpointBehaviour lvRedPoint;
19     Image starChooseImage;
20     Image lvChooseImage;
21     Button leftButton;
22     Button rightButton;
23     Transform treasurePavilionCell;
24     Transform starAttrPanel;
25     Transform lvAttrPanel;
b3d443 26     TreasurePavilionUpgradeChooseModel treasurePavilionUpgradeChooseModel { get { return ModelCenter.Instance.GetModelEx<TreasurePavilionUpgradeChooseModel>(); } }
a27c7f 27     #region Built-in
H 28     protected override void BindController()
29     {
30         m_Close = proxy.GetWidgtEx<Button>("Img_Close");
31         starButton = proxy.GetWidgtEx<Button>("starButton");
32         lvButton = proxy.GetWidgtEx<Button>("LVButton");
33         starRedPoint = proxy.GetWidgtEx<RedpointBehaviour>("starRedPoint");
34         lvRedPoint = proxy.GetWidgtEx<RedpointBehaviour>("LVRedPoint");
35         starChooseImage = proxy.GetWidgtEx<Image>("starChooseImage");
36         lvChooseImage = proxy.GetWidgtEx<Image>("LVChooseImage");
37         leftButton = proxy.GetWidgtEx<Button>("leftButton");
38         rightButton = proxy.GetWidgtEx<Button>("rightButton");
39         treasurePavilionCell = proxy.GetWidgtEx<Transform>("TreasurePavilionCell");
40         starAttrPanel = proxy.GetWidgtEx<Transform>("starAttrPanel");
41         lvAttrPanel = proxy.GetWidgtEx<Transform>("lvAttrPanel");
42     }
43
44     protected override void AddListeners()
45     {
46         m_Close.SetListener(()=> {
47             CloseWin<TreasurePavilionUpgradeWin>();
48         });
49
50         starButton.SetListener(()=> {
51             TreasurePavilionModel.Instance.upgradeFuncOrder = 0;
52             DisplayPanel();
53         });
54
55         lvButton.SetListener(() => {
56             TreasurePavilionModel.Instance.upgradeFuncOrder = 1;
57             DisplayPanel();
58         });
59
60         leftButton.SetListener(() => {
61             TreasurePavilionModel.Instance.upgradeGubao = FindGubao(0);
62             DisplayByGubao();
63         });
64
65         rightButton.SetListener(() => {
66             TreasurePavilionModel.Instance.upgradeGubao = FindGubao(1);
67             DisplayByGubao();
68         });
69     }
70
71     protected override void OnPreOpen()
72     {
73         TreasurePavilionModel.Instance.UpdateGubaoEvent += DisplayByGubao;
b3d443 74         treasurePavilionUpgradeChooseModel.UpdateInfoAction += DisplayByGubao;
L 75         treasurePavilionUpgradeChooseModel.ClearAllInfo();
a27c7f 76     }
H 77
78     protected override void OnAfterOpen()
79     {
80         DisplayPanel();
81     }
82
83     protected override void OnPreClose()
84     {
85         TreasurePavilionModel.Instance.UpdateGubaoEvent -= DisplayByGubao;
b3d443 86         treasurePavilionUpgradeChooseModel.UpdateInfoAction -= DisplayByGubao;
27c692 87         WindowCenter.Instance.OpenIL<TreasurePavilionWin>();
a27c7f 88     }
H 89
90     #endregion
91
92     //功能模块显示
93     void DisplayPanel()
94     {
95         if (TreasurePavilionModel.Instance.upgradeFuncOrder == 0)
96         {
97             starChooseImage.SetActiveIL(true);
98             starAttrPanel.SetActiveIL(true);
99             lvChooseImage.SetActiveIL(false);
100             lvAttrPanel.SetActiveIL(false);
101         }
102         else
103         {
104             starChooseImage.SetActiveIL(false);
105             starAttrPanel.SetActiveIL(false);
106             lvChooseImage.SetActiveIL(true);
107             lvAttrPanel.SetActiveIL(true);
108         }
109         DisplayByGubao();
110     }
111
112     void DisplayByGubao()
113     {
114         starRedPoint.redpointId = (MainRedPoint.cbgRedpoint * 10000 + TreasurePavilionModel.Instance.upgradeGubao) * 10 + 1;
115         lvRedPoint.redpointId = (MainRedPoint.cbgRedpoint * 10000 + TreasurePavilionModel.Instance.upgradeGubao) * 10 + 2;
116         var _cell = treasurePavilionCell.GetILBehaviour<TreasurePavilionCell>();
117         _cell.Display(TreasurePavilionModel.Instance.upgradeGubao);
118
119         if (TreasurePavilionModel.Instance.upgradeFuncOrder == 0)
120         {
121             var _tmpcell = starAttrPanel.GetILBehaviour<TreasurePavilionUpgradeStarCell>();
122             _tmpcell.Display(TreasurePavilionModel.Instance.upgradeGubao);
123         }
124         else
125         {
126             var _tmpcell = lvAttrPanel.GetILBehaviour<TreasurePavilionUpgradeLVCell>();
127             _tmpcell.Display(TreasurePavilionModel.Instance.upgradeGubao);
128         }
129     }
130
131     //leftRight 0左1右
132     int FindGubao(int leftRight)
133     {
134         var gubaoList = TreasurePavilionModel.Instance.GetGubaoList();
135         int index = gubaoList.IndexOf(TreasurePavilionModel.Instance.upgradeGubao);
136         if (leftRight == 0)
137         {
138             index = Math.Max(0, index - 1);
139         }
140         else
141         {
142             index = Math.Min(gubaoList.Count - 1, index + 1);
143         }
144         var gubaoInfo = TreasurePavilionModel.Instance.TryGetGubaoInfo(gubaoList[index]);
145         if (gubaoInfo.Count == 0)
146         {
147             //未激活
148             return TreasurePavilionModel.Instance.upgradeGubao;
149         }
150
151         return gubaoList[index];
152     }
153 }