少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Sunday, April 28, 2019
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
 
namespace Snxxz.UI
{
 
    public class OneLevelWin : Window
    {
        protected Image m_TitleIcon;
        protected FunctionButtonGroup m_Group;
        protected Button m_Left;
        protected Button m_Right;
        protected Button m_Close;
 
        protected RectTransform m_SubWindowContainer;
        public RectTransform subWindowContainer { get { return m_SubWindowContainer; } }
 
        PositionTween positionTween;
 
        #region Built-in
        protected override void BindController()
        {
            positionTween = this.AddMissingComponent<PositionTween>();
 
            positionTween.curve = BuiltInLoader.LoadScriptableObject<TweenCurve>("Linear");
            positionTween.delayMode = Tween.DelayMode.TwiceFrame;
            positionTween.duration = 0.3f;
            positionTween.from = new Vector3(0, 750, 0);
            positionTween.to = Vector3.zero;
            positionTween.trigger = Tween.Trigger.Manual;
            positionTween.wrapMode = Tween.WrapMode.Once;
 
            windowInfo.tween = positionTween;
 
            m_TitleIcon = this.GetComponent<Image>("Pivot/Container_BackGround/Img_Title");
            m_Group = this.GetComponent<FunctionButtonGroup>("Pivot/Container_Functions");
            m_Left = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Left");
            m_Right = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Right");
            m_Close = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Close");
 
            m_SubWindowContainer = this.GetComponent<RectTransform>("Pivot/Container_SubWindow");
 
            var name = this.GetType().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();
        }
 
        protected override void AddListeners()
        {
            m_Close.SetListener(() => { WindowCenter.Instance.Close(this.GetType().Name); });
            m_Left.SetListener(() => { m_Group.TriggerLast(); });
            m_Right.SetListener(() => { m_Group.TriggerNext(); });
        }
 
        protected override void OnPreOpen()
        {
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            CloseSubWindows();
        }
 
        protected override void OnAfterClose()
        {
        }
 
        protected override void OnActived()
        {
            base.OnActived();
 
            m_Group.TriggerByOrder(functionOrder);
            m_Left.gameObject.SetActive(m_Group.unLockedCount > 1);
            m_Right.gameObject.SetActive(m_Group.unLockedCount > 1);
        }
 
        #endregion
 
        protected virtual void CloseSubWindows()
        {
            var subWindows = WindowConfig.GetChildWindows(this.GetType().Name);
            foreach (var window in subWindows)
            {
                WindowCenter.Instance.Close(window);
            }
        }
 
        protected void SetFunctionListener(int order, UnityAction callBack)
        {
            m_Group.SetFunctionListener(order, callBack);
        }
 
    }
 
}