少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
 
namespace vnxbqy.UI
{
    // 炼器战令
    public class LianQiZhanLingWin : Window
    {
        [SerializeField] ScrollerController scroller;
        [SerializeField] ButtonEx btnClose;
        [SerializeField] ButtonEx btnPaidLock;
        [SerializeField] ButtonEx btnPaidLockH;
        [SerializeField] TextEx txtNowNeedValue;
        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
        ZhanLingHActBuyModel zhanLingHActBuyModel { get { return ModelCenter.Instance.GetModel<ZhanLingHActBuyModel>(); } }
        LianQiZhanLingModel model { get { return ModelCenter.Instance.GetModel<LianQiZhanLingModel>(); } }
 
        protected override void AddListeners()
        {
            btnClose.SetListener(() =>
            {
                CloseClick();
            });
 
            btnPaidLock.SetListener(() =>
            {
                zhanLingHActBuyModel.ShowZhanLingHBuy(model.ZhanLingHType, 1, model.GetValue1());
            });
 
            btnPaidLockH.SetListener(() =>
            {
                zhanLingHActBuyModel.ShowZhanLingHBuy(model.ZhanLingHType, 2, model.GetValue1());
            });
        }
 
        protected override void OnPreOpen()
        {
            model.UpdateGiftStateEvent += UpdateGiftStateEvent;
            scroller.OnRefreshCell += OnScrollerRefreshCell;
            vipModel.rechargeCountEvent += OnRechargeCountEvent;
            Display();
        }
 
        private void Display()
        {
            //0 没购买进阶和玄级 1 购买了进阶没买玄级 2 购买了玄级没买进阶 3 购买了进阶和玄级
            int buyState = model.GetBuyState(model.ZhanLingHType);
            scroller.m_Scorller.RefreshActiveCellViews();
            txtNowNeedValue.text = Language.Get("LianQiZhanLing04", model.GetValue1());
            btnPaidLock.SetActive(buyState == 0 || buyState == 2);
            btnPaidLockH.SetActive(buyState == 0 || buyState == 1);
            int ctgId1 = model.ctgIdDict[model.ZhanLingHType][0];
            int ctgId2 = model.ctgIdDictH[model.ZhanLingHType][0];
            model.IsPlayAnimation = true;
        }
 
        protected override void OnAfterOpen()
        {
            Initialize();
        }
 
        protected override void OnPreClose()
        {
            model.UpdateGiftStateEvent -= UpdateGiftStateEvent;
            scroller.OnRefreshCell -= OnScrollerRefreshCell;
            vipModel.rechargeCountEvent -= OnRechargeCountEvent;
        }
 
        private void OnRechargeCountEvent(int obj)
        {
            if (obj == model.ctgIdDict[model.ZhanLingHType][0] ||
                obj == model.ctgIdDictH[model.ZhanLingHType][0])
            {
                Display();
                scroller.m_Scorller.RefreshActiveCellViews();
            }
        }
 
        private void UpdateGiftStateEvent()
        {
            Display();
            scroller.m_Scorller.RefreshActiveCellViews();
        }
 
        private float timer = 0.0f;
        private bool canPlayAnimation = true;
 
        protected override void LateUpdate()
        {
            // 更新计时器
            timer += Time.unscaledDeltaTime;
 
            // 检查计时器是否超过 0.3 秒
            if (timer >= 0.3f)
            {
                canPlayAnimation = true;
 
                timer = 0.0f;
            }
        }
 
        private void OnScrollerRefreshCell(ScrollerDataType type, CellView cell)
        {
            var _cell = cell as LianQiZhanLingCell;
            _cell.Display(_cell.index);
 
            if (canPlayAnimation)
            {
                model.IsPlayAnimation = true;
                canPlayAnimation = false;
            }
        }
 
        private void Initialize()
        {
            List<int> cellList = ILZhanlingConfig.GetTypeToIDDict(model.ZhanLingHType).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.ZhanLingHType));
            model.IsPlayAnimation = true;
        }
 
        protected override void BindController()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
    }
}