少年修仙传客户端代码仓库
hch
2020-11-02 e1a6fa4d577ebf4833cc91bef8d2ff334ebb750f
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
165
166
167
168
169
170
171
172
173
174
175
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Snxxz.UI
{
    [XLua.LuaCallCSharp]
    public class OpenServerActivityCenter : Singleton<OpenServerActivityCenter>
    {
        public event Action openServerActivityStateChange;
 
        Dictionary<int, IOpenServerActivity> openServerActivitys = new Dictionary<int, IOpenServerActivity>();
        Dictionary<int, ILuaOpenServerActivity> luaOpenServerAcitivitys = new Dictionary<int, ILuaOpenServerActivity>();
 
        public int selectFuncOrder = -1;
 
        public OpenServerActivityCenter()
        {
            TimeUtility.OnServerOpenDayRefresh += OnServerOpenDayRefresh;
        }
 
        public void Register(int funcOrder, IOpenServerActivity activity)
        {
            if (!openServerActivitys.ContainsKey(funcOrder))
            {
                openServerActivitys.Add(funcOrder, activity);
                activity.onStateUpdate += OnStateUpdate;
            }
        }
 
        public void RegisterLuaActivity(int funcOrder, string luaTableName)
        {
            if (!openServerActivitys.ContainsKey(funcOrder))
            {
                var activity = LuaUtility.Global.Get<IOpenServerActivity>(luaTableName);
                if (activity != null)
                {
                    openServerActivitys.Add(funcOrder, activity);
                    activity.onStateUpdate += OnStateUpdate;
                }
 
                var luaActivity = LuaUtility.Global.Get<ILuaOpenServerActivity>(luaTableName);
                if (luaActivity != null)
                {
                    luaOpenServerAcitivitys[funcOrder] = luaActivity;
                }
            }
        }
 
        private void OnStateUpdate(int _order)
        {
            if (openServerActivityStateChange != null)
            {
                openServerActivityStateChange();
            }
        }
 
        private void OnServerOpenDayRefresh()
        {
            if (openServerActivityStateChange != null)
            {
                openServerActivityStateChange();
            }
        }
 
        public bool IsAnyActivityOpen(out int _functionOrder)
        {
            _functionOrder = 0;
            foreach (var _order in openServerActivitys.Keys)
            {
                if (openServerActivitys[_order].IsOpen || openServerActivitys[_order].IsAdvance)
                {
                    _functionOrder = _order;
                    return true;
                }
            }
            return false;
        }
 
        public bool IsActivityOpen(int _funcOrder)
        {
            if (openServerActivitys.ContainsKey(_funcOrder))
            {
                return openServerActivitys[_funcOrder].IsOpen || openServerActivitys[_funcOrder].IsAdvance;
            }
            return false;
        }
 
        public bool IsPriorityOpenOpen(int _funcOrder)
        {
            if (openServerActivitys.ContainsKey(_funcOrder))
            {
                return openServerActivitys[_funcOrder].priorityOpen;
            }
            return false;
        }
 
        public void SetSelectDefaultChildType(int _funcOrder)
        {
            if (luaOpenServerAcitivitys.ContainsKey(_funcOrder))
            {
                luaOpenServerAcitivitys[_funcOrder].SetSelectDefaultChildType();
            }
        }
 
        public bool ExistChildBookmark(int _funcOrder)
        {
            switch (_funcOrder)
            {
                case 0:
                case 2:
                case 19:
                case 22:
                    return true;
                default:
                    var config = OpenServerActivityConfig.Get(_funcOrder);
                    if (config != null)
                    {
                        return config.childTypes.Length > 0;
                    }
                    return false;
            }
        }
 
        public int GetChildSelectType(int _funcOrder)
        {
            if (luaOpenServerAcitivitys.ContainsKey(_funcOrder))
            {
                return luaOpenServerAcitivitys[_funcOrder].selectType;
            }
            return 0;
        }
 
        public int[] GetChildTypes(int _funcOrder)
        {
            var config = OpenServerActivityConfig.Get(_funcOrder);
            if (config != null)
            {
                return config.childTypes;
            }
            return null;
        }
 
        public void SetSelectChildType(int _funcOrder, int type)
        {
            if (luaOpenServerAcitivitys.ContainsKey(_funcOrder))
            {
                luaOpenServerAcitivitys[_funcOrder].SetSelectChildType(type);
            }
        }
 
        public void ProcessErrorTip()
        {
            SysNotifyMgr.Instance.ShowTip("ActiveOutTime");
        }
    }
 
    [XLua.CSharpCallLua]
    public interface IOpenServerActivity
    {
        bool IsOpen { get; }
        bool IsAdvance { get; }
        bool priorityOpen { get; }
 
        event Action<int> onStateUpdate;
    }
 
    [XLua.CSharpCallLua]
    public interface ILuaOpenServerActivity
    {
        int selectType { get; }
        void SetSelectDefaultChildType();
        void SetSelectChildType(int type);
    }
}