少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
using vnxbqy.UI;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
 
// 骑宠战令
public class MountedPetZhanLingWin : Window
{
    [SerializeField] ScrollerController scroller;
    [SerializeField] ButtonEx btnClose;
    [SerializeField] ButtonEx btnPaidLock;
    [SerializeField] ButtonEx btnPaidLockH;
    [SerializeField] TextEx txtPaidLock;
    [SerializeField] TextEx txtPaidLockH;
    [SerializeField] TextEx txtNowNeedValue;
    VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
    ZhanLingHBuyModel zhanLingHBuyModel { get { return ModelCenter.Instance.GetModel<ZhanLingHBuyModel>(); } }
    MountedPetZhanLingModel model { get { return ModelCenter.Instance.GetModel<MountedPetZhanLingModel>(); } }
    PetHorseActModel petHorseActModel { get { return ModelCenter.Instance.GetModel<PetHorseActModel>(); } }
    protected override void AddListeners()
    {
        btnClose.SetListener(() =>
        {
            WindowCenter.Instance.Close<MountedPetZhanLingWin>();
        });
 
        btnPaidLock.SetListener(() =>
        {
            zhanLingHBuyModel.ShowZhanLingHBuy(model.ZhanLingHType, 1, "ZhanLingHBuyBG2");
        });
 
        btnPaidLockH.SetListener(() =>
        {
            zhanLingHBuyModel.ShowZhanLingHBuy(model.ZhanLingHType, 2, "ZhanLingHBuyBG2");
        });
    }
 
    protected override void OnPreOpen()
    {
        model.UpdateGiftStateEvent += UpdateGiftStateEvent;
        scroller.OnRefreshCell += OnScrollerRefreshCell;
        vipModel.rechargeCountEvent += OnRechargeCountEvent;
        Display();
    }
 
    void Display()
    {
        //0 没购买进阶和玄级 1 购买了进阶没买玄级 2 购买了玄级没买进阶 3 购买了进阶和玄级
        int buyState = model.GetBuyState(model.ZhanLingHType);
        scroller.m_Scorller.RefreshActiveCellViews();
        txtNowNeedValue.text = Language.Get("MountedPetZhanLingWin01", petHorseActModel.actScore);
        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];
        txtPaidLock.text = CTGConfig.Get(ctgId1).Title;
        txtPaidLockH.text = CTGConfig.Get(ctgId2).Title;
        model.IsPlayAnimation = true;
    }
 
    protected override void OnAfterOpen()
    {
        Initialize();
    }
 
 
    protected override void OnPreClose()
    {
        model.UpdateGiftStateEvent -= UpdateGiftStateEvent;
        scroller.OnRefreshCell -= OnScrollerRefreshCell;
        vipModel.rechargeCountEvent -= OnRechargeCountEvent;
    }
 
    void OnUpdateSoulInfos(bool noChangeCnt)
    {
        Display();
    }
 
    void OnRechargeCountEvent(int obj)
    {
        if (obj == model.ctgIdDict[model.ZhanLingHType][0] ||
            obj == model.ctgIdDictH[model.ZhanLingHType][0])
        {
            Display();
        }
    }
 
    private void UpdateGiftStateEvent()
    {
        Display();
    }
 
    private void OnScrollerRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell as MountedPetZhanLingCell;
        _cell.Display(_cell.index);
        model.IsPlayAnimation = true;
    }
 
    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()
    {
    }
}