hch
8 天以前 27fcdab4830ef0791105be6529a1dfac36b85982
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using UnityEngine.UI; // DOTween 插件引用
using Cysharp.Threading.Tasks;
using System;
 
 
public class OneLevelWin : UIBase
{
    protected Image m_TitleIcon;
    protected FunctionButtonGroup m_Group;
    protected Button m_Left;
    protected Button m_Right;
    protected Button m_Close;
 
    protected Text m_Copper;
    protected Text m_Diamond;
    protected Text m_BindDiamond;
 
    protected RectTransform m_SubWindowContainer;
    public RectTransform subWindowContainer { get { return m_SubWindowContainer; } }
 
    private UIBase subWindow = null;
 
    //  init once
    protected override void InitComponent()
    {
        base.InitComponent();
 
 
        // //  跟原版的差别 
        Transform trans = transform;
 
        // if (_rectTransform != null)
        // {
        //     trans = _rectTransform;
        // }
 
        m_TitleIcon = trans.GetComponent<Image>("Pivot/Container_BackGround/Img_Title");
        m_Group = trans.GetComponent<FunctionButtonGroup>("Pivot/Container_Functions");
        m_Left = trans.GetComponent<Button>("Pivot/Container_Buttons/Btn_Left");
        m_Right = trans.GetComponent<Button>("Pivot/Container_Buttons/Btn_Right");
        m_Close = trans.GetComponent<Button>("Pivot/Container_Buttons/Btn_Close");
 
        m_Copper = trans.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/SilverCountBG/CountText");
        if (m_Copper != null)
            m_Diamond = trans.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldCountBG/CountText");
            m_BindDiamond = trans.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldPaperCountBG/CountText");
 
        m_SubWindowContainer = trans.GetComponent<RectTransform>("Pivot/Container_SubWindow");
 
        var name = gameObject.name;
        var infos = WindowConfig.GetWindowFunctionInfos(name);
        foreach (var info in infos)
        {
            var title = Language.Get(info.titleKey);
            if (title.Length == 2)
            {
                title = title.Insert(1, " ");
            }
            m_Group.AddFunction("FunctionButton_Pattern_1", info.order, info.functionId, title, info.redPointId);
        }
 
        m_TitleIcon.SetSprite(WindowConfig.GetTitleIconKey(name));
        m_TitleIcon.SetNativeSize();
 
        m_Close.SetListener(CloseWindow);
        m_Left.SetListener(() => { m_Group.TriggerLast(); });
        m_Right.SetListener(() => { m_Group.TriggerNext(); });
    }
 
    protected override void OnPreOpen()
    {
        base.OnPreOpen();
 
        if (m_Copper == null)
            m_Copper = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/SilverCountBG/CountText");
            m_Diamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldCountBG/CountText");
            m_BindDiamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldPaperCountBG/CountText");
 
        
        UpdateMoney();
    }
 
    protected override void OnPreClose()
    {
        base.OnPreClose();
        CloseSubWindows();
    }
 
    protected override void OnOpen()
    {
        base.OnOpen();
 
        PlayerDatas.Instance.playerDataRefreshEvent += OnPlayerDataUpdate;
 
        ExecuteNextFrame(() => {
            m_Group.TriggerByOrder(functionOrder);
            m_Group.GotoOrder(functionOrder);
        });
 
        m_Left.SetActive(m_Group.unLockedCount > 1);
        m_Right.SetActive(m_Group.unLockedCount > 1);
    }
 
    protected virtual void CloseSubWindows()
    {
        if (null != subWindow)
        {
            subWindow.CloseWindow();
        }
        subWindow = null;
    }
 
    public void SetFunctionListener(int order, Action callBack)
    {
        m_Group.SetFunctionListener(order, callBack);
    }
 
    public void SetFunctionButtonActive(int order, bool isShow)
    {
        m_Group.SetFunctionButtonActive(order, isShow);
    }
 
    public RedPointState GetFunctionButtonRedPointState(int order)
    {
        return m_Group.GetFunctionButtonRedPointState(order);
    }
 
    public void FunctionButtonInvoke(int order)
    {
        m_Group.TriggerByOrder(order);
        m_Group.GotoOrder(order);
    }
 
    private void OnPlayerDataUpdate(PlayerDataType type)
    {
        switch (type)
        {
            case PlayerDataType.Gold:
            case PlayerDataType.GoldPaper:
            case PlayerDataType.Silver:
            case PlayerDataType.ExAttr6:
            case PlayerDataType.default5:
            case PlayerDataType.default6:
                UpdateMoney();
                break;
        }
    }
 
    void UpdateMoney()
    {
        if (m_Copper == null)
            return;
        m_Copper.text = ItemLogicUtility.Instance.OnChangeCoinsUnit(PlayerDatas.Instance.baseData.allCopper);
        m_Diamond.text = UIHelper.GetMoneyCntEx(1).ToString();
        if (PlayerDatas.Instance.baseData.bindDiamond > 0)
            m_BindDiamond.text = ItemLogicUtility.Instance.OnChangeCoinsUnit(PlayerDatas.Instance.baseData.bindDiamond);
        else
            m_BindDiamond.text = UIHelper.GetMoneyCntEx(2).ToString();
    }
}