少年修仙传客户端代码仓库
hch
2025-03-03 28785d6ddf9c08e49527ede9405c7b6c93c6ed32
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
using System;
using UnityEngine;
using UnityEngine.UI;
 
 
namespace vnxbqy.UI
{
    
    public class FashiongDecomposeWin : Window,SecondWindowInterface
    {
        [SerializeField] Button decomposeBtn;
        [SerializeField] Text wardrobeLvText;
        [SerializeField] Text upgradeExpText;
        [SerializeField] Text getExpText;
        [SerializeField] ScrollerController lineCtrl;
        [SerializeField, Header("创建格子数")] int initGrid = 100;
 
        FashionDressModel model{ get { return ModelCenter.Instance.GetModel<FashionDressModel>(); }}
 
        public Button close { get; set; }
 
        #region Built-in
        protected override void BindController()
        {
            if (this is SecondWindowInterface)
            {
                var frame = this.GetComponentInChildren<SecondFrameLoader>();
                frame.Create();
                close = frame.GetComponentInChildren<Button>();
            }
        }
 
        protected override void AddListeners()
        {
            close.AddListener(CloseClick);
            decomposeBtn.AddListener(ClickDecompose);
        }
 
        protected override void OnPreOpen()
        {
            model.cabinetRefresh += UpdateCabinetInfo;
            FashionDecomposeModel.Instance.UpdateDecomposeExpEvent += UpdateGetExp;
            SetDisplay();
        }
        protected override void OnAfterOpen()
        {
           
        }
 
        protected override void OnPreClose()
        {
            model.cabinetRefresh -= UpdateCabinetInfo;
            FashionDecomposeModel.Instance.UpdateDecomposeExpEvent -= UpdateGetExp;
        }
        protected override void OnAfterClose()
        {
 
        }
        #endregion
 
        private void SetDisplay()
        {
            FashionDecomposeModel.Instance.GetDecomposeItem();
            CreateLineCell();
            UpdateGetExp();
            UpdateCabinetLv();
        }
 
        private void UpdateCabinetInfo()
        {
            FashionDecomposeModel.Instance.GetDecomposeItem();
            UpdateCabinetLv();
            lineCtrl.m_Scorller.RefreshActiveCellViews();
        }
 
        private void CreateLineCell()
        {
            int line = initGrid / 5;
            lineCtrl.Refresh();
            for (int i = 0; i < line; i++)
            {
                lineCtrl.AddCell(ScrollerDataType.Header, i);
            }
            lineCtrl.Restart();
        }
 
        private void UpdateCabinetLv()
        {
            int wardrobeLv = model.cabinetLevel;
            wardrobeLvText.text = Language.Get("FashionDress106",wardrobeLv);
            int curWardrobeExp = model.cabinetExp;
            bool isCabinetMax = wardrobeLv >= model.cabinetMaxLevel ? true : false;
            int upgradeLv = isCabinetMax ? model.cabinetMaxLevel : wardrobeLv + 1;
            var cabinetConfig = FashionDressCabinetConfig.Get(upgradeLv);
            upgradeExpText.SetActive(cabinetConfig != null);
            if (cabinetConfig != null)
            {
                int upgradeWardrobeExp = cabinetConfig.NeedExp;
                if (isCabinetMax)
                {
                    upgradeExpText.text = StringUtility.Contact("(", Language.Get("FashionDress105"),")");
                }
                else
                {
                    upgradeExpText.text = StringUtility.Contact("(", curWardrobeExp, "/", upgradeWardrobeExp, ")");
                }
            }
        }
 
        private void UpdateGetExp()
        {
            int getDecomposeExp = FashionDecomposeModel.Instance.GetSumDecomposeExp();
            getExpText.text = getDecomposeExp.ToString();
        }
 
        private void ClickDecompose()
        {
            int getDecomposeExp = FashionDecomposeModel.Instance.GetSumDecomposeExp();
            if(getDecomposeExp <= 0)
            {
                SysNotifyMgr.Instance.ShowTip("FashionDecomposeRemind");
                return;
            }
            FashionDecomposeModel.Instance.SendDecomposeFashion();
            CloseImmediately();
        }
    }
}