少年修仙传客户端代码仓库
hch
2025-04-03 c154ac0832fe4379a00d3e1cda700e7d2a7383c7
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
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
 
namespace vnxbqy.UI
{
    // ÏÉÔµÕ½Áî
    public class FairyAffinityZhanLingWin : Window
    {
        [SerializeField] ScrollerController scroller;
        [SerializeField] TextEx txtBuy;
        [SerializeField] TextEx txtProfitRatio;
        [SerializeField] TextEx txtBuyValue;
        [SerializeField] ButtonEx btnBuy;
        [SerializeField] ImageEx imgBuy;
        TextEx orgPrice;
        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
        FairyAffinityZhanLingModel model { get { return ModelCenter.Instance.GetModel<FairyAffinityZhanLingModel>(); } }
 
        #region Built-in
 
        protected override void AddListeners()
        {
            btnBuy.SetListener(() =>
            {
                vipModel.CTG(model.ctgIdDict[model.ZhanLingType]);
            });
        }
 
        protected override void BindController()
        {
            var obj = btnBuy.FindComponent("Text", "Txt_orgPrice");
            if (obj != null)
                orgPrice = obj as TextEx;
        }
 
        protected override void OnPreOpen()
        {
            PlayerDatas.Instance.playerDataRefreshEvent += OnplayerDataRefreshEvent;
            model.UpdateGiftStateEvent += UpdateGiftStateEvent;
            scroller.OnRefreshCell += OnScrollerRefreshCell;
 
            bool isBuyZhanLing = model.IsBuy();
            btnBuy.SetActiveIL(!isBuyZhanLing);
            imgBuy.SetActiveIL(isBuyZhanLing);
            OrderInfoConfig orderCfg;
            vipModel.TryGetOrderInfo(model.ctgIdDict[model.ZhanLingType], out orderCfg);
            txtBuy.text = Language.Get("PayMoneyNum", orderCfg.PayRMBNum);
            if (orgPrice != null)
            {
                orgPrice.SetActiveIL(PlayerDatas.Instance.baseData.IsActive90Off);
                orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderCfg.m_PayRMBNum));
            }
            txtProfitRatio.text = Language.Get("BlessedLand039", CTGConfig.Get(model.ctgIdDict[model.ZhanLingType]).Percentage);
            txtBuyValue.text = model.buyValue.ToString();
        }
 
        protected override void OnPreClose()
        {
            PlayerDatas.Instance.playerDataRefreshEvent -= OnplayerDataRefreshEvent;
            model.UpdateGiftStateEvent -= UpdateGiftStateEvent;
            scroller.OnRefreshCell -= OnScrollerRefreshCell;
        }
 
        protected override void OnAfterOpen()
        {
            Initialize();
        }
 
        protected override void OnAfterClose()
        {
        }
 
        #endregion
 
        private void OnplayerDataRefreshEvent(PlayerDataType type)
        {
            if (type == PlayerDataType.default42)
            {
                if (model.zhanLingInfoDict == null || !model.zhanLingInfoDict.ContainsKey(model.ZhanLingType))
                    return;
 
                scroller.m_Scorller.RefreshActiveCellViews();
                model.IsPlayAnimation = true;
            }
        }
 
        private void UpdateGiftStateEvent()
        {
            scroller.m_Scorller.RefreshActiveCellViews();
            bool isBuyZhanLing = model.IsBuy();
            btnBuy.SetActiveIL(!isBuyZhanLing);
            imgBuy.SetActiveIL(isBuyZhanLing);
            model.IsPlayAnimation = true;
        }
 
        private void OnScrollerRefreshCell(ScrollerDataType type, CellView cell)
        {
            var _cell = cell as FairyAffinityZhanLingCell;
            _cell.Display(_cell.index);
            model.IsPlayAnimation = true;
        }
 
        private void Initialize()
        {
            List<int> cellList = ILZhanlingConfig.GetTypeToIDDict(model.ZhanLingType).Keys.ToList();
            scroller.Refresh();
            for (int i = 0; i < cellList.Count; i++)
            {
                scroller.AddCell(ScrollerDataType.Header, cellList[i]);
            }
            scroller.Restart();
            scroller.JumpIndex(model.GetJumpStartIndex(model.ZhanLingType));
            model.IsPlayAnimation = true;
        }
    }
}