| | |
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using UnityEngine;
|
| | | //修改成控制多个活动模块,如精彩活动模板1,精彩活动模板2
|
| | |
|
| | | public class OpenServerActivityCenter : Singleton<OpenServerActivityCenter>
|
| | | {
|
| | | public event Action openServerActivityStateChange;
|
| | |
|
| | | //{活动模板:{活动ID:活动接口}}
|
| | | Dictionary<int, Dictionary<int, IOpenServerActivity>> GameServerActivitys = new Dictionary<int, Dictionary<int, IOpenServerActivity>>();
|
| | |
|
| | | public int selectFuncOrder = -1;
|
| | |
|
| | | public enum ActivityType
|
| | | {
|
| | | AT_JCHD = 0, //精彩活动
|
| | | AT_DateActivity, //日期型活动- 按日期开放的排行榜系列活动相关 id从200开始(与其他活动区分,虽然id重复并没有关系), 类同节日活动
|
| | | }
|
| | |
|
| | | public OpenServerActivityCenter()
|
| | | {
|
| | | TimeUtility.OnServerOpenDayRefresh -= OnServerOpenDayRefresh;
|
| | | TimeUtility.OnServerOpenDayRefresh += OnServerOpenDayRefresh;
|
| | | }
|
| | |
|
| | | public void Register(int funcOrder, IOpenServerActivity activity, int activityType = (int)ActivityType.AT_JCHD)
|
| | | {
|
| | | if (!GameServerActivitys.ContainsKey(activityType))
|
| | | {
|
| | | GameServerActivitys.Add(activityType, new Dictionary<int, IOpenServerActivity>());
|
| | | }
|
| | |
|
| | | var openServerActivitys = GameServerActivitys[activityType];
|
| | | if (!openServerActivitys.ContainsKey(funcOrder))
|
| | | {
|
| | | openServerActivitys.Add(funcOrder, activity);
|
| | | activity.onStateUpdate -= OnStateUpdate;
|
| | | activity.onStateUpdate += OnStateUpdate;
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnStateUpdate(int _order)
|
| | | {
|
| | | if (openServerActivityStateChange != null)
|
| | | {
|
| | | openServerActivityStateChange();
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnServerOpenDayRefresh()
|
| | | {
|
| | | if (openServerActivityStateChange != null)
|
| | | {
|
| | | openServerActivityStateChange();
|
| | | }
|
| | | }
|
| | |
|
| | | public bool IsAnyActivityOpen(out int _functionOrder, int activityType = (int)ActivityType.AT_JCHD)
|
| | | {
|
| | | if (!GameServerActivitys.ContainsKey(activityType))
|
| | | {
|
| | | GameServerActivitys.Add(activityType, new Dictionary<int, IOpenServerActivity>());
|
| | | }
|
| | |
|
| | | var openServerActivitys = GameServerActivitys[activityType];
|
| | | _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, int activityType = (int)ActivityType.AT_JCHD)
|
| | | {
|
| | | if (!GameServerActivitys.ContainsKey(activityType))
|
| | | {
|
| | | GameServerActivitys.Add(activityType, new Dictionary<int, IOpenServerActivity>());
|
| | | }
|
| | | |
| | | bool isOpen = false;
|
| | | var openServerActivitys = GameServerActivitys[activityType];
|
| | | if (openServerActivitys.ContainsKey(_funcOrder))
|
| | | {
|
| | | isOpen = openServerActivitys[_funcOrder].IsOpen || openServerActivitys[_funcOrder].IsAdvance;
|
| | | }
|
| | |
|
| | | return isOpen;
|
| | | }
|
| | |
|
| | | public bool IsPriorityOpenOpen(int _funcOrder, int activityType = (int)ActivityType.AT_JCHD)
|
| | | {
|
| | | if (!GameServerActivitys.ContainsKey(activityType))
|
| | | {
|
| | | GameServerActivitys.Add(activityType, new Dictionary<int, IOpenServerActivity>());
|
| | | }
|
| | |
|
| | | var openServerActivitys = GameServerActivitys[activityType];
|
| | | if (openServerActivitys.ContainsKey(_funcOrder))
|
| | | {
|
| | | return openServerActivitys[_funcOrder].priorityOpen;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | public void ProcessErrorTip()
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("ActiveOutTime");
|
| | | }
|
| | |
|
| | | //AT_Activity2 日期型活动-默认设计都是同一个入口,根据活动替换图标和名称,打开不同界面
|
| | | public NewDayActivityInfo GetNewDayActionEnterInfo()
|
| | | {
|
| | | // if (IsActivityOpen((int)NewDayActivityID.BossTrial, (int)ActivityType.AT_Activity2))
|
| | | // {
|
| | | // return new NewDayActivityInfo() { activityID = (int)NewDayActivityID.BossTrial, redpointID = MainRedDot.BossTrialRepoint, winName = "BossTrialActWin" };
|
| | | // }
|
| | | // else if (IsActivityOpen((int)NewDayActivityID.SecretPlaceXB, (int)ActivityType.AT_Activity2))
|
| | | // {
|
| | | // return new NewDayActivityInfo() { activityID = (int)NewDayActivityID.SecretPlaceXB, redpointID = MainRedDot.MjxbRedpoint, winName = "SecretPlaceActWin" };
|
| | | // }
|
| | | // else if (IsActivityOpen((int)NewDayActivityID.PetHorseAct, (int)ActivityType.AT_Activity2))
|
| | | // {
|
| | | // return new NewDayActivityInfo() { activityID = (int)NewDayActivityID.PetHorseAct, redpointID = MainRedDot.QCTrainActRedpoint, winName = "PetHorseActWin" };
|
| | | // }
|
| | | // else if (IsActivityOpen((int)NewDayActivityID.TreasurePavilionAct, (int)ActivityType.AT_Activity2))
|
| | | // {
|
| | | // return new NewDayActivityInfo() { activityID = (int)NewDayActivityID.TreasurePavilionAct, redpointID = MainRedDot.TreasurePavilionRankActRepoint, winName = "TreasurePavilionRankActWin" };
|
| | | // }
|
| | |
|
| | | return new NewDayActivityInfo() { activityID = 0 };
|
| | | }
|
| | |
|
| | | //AT_Activity2 入口信息
|
| | | public struct NewDayActivityInfo
|
| | | {
|
| | | public int activityID;
|
| | | public int redpointID;
|
| | | public string winName;
|
| | | }
|
| | | }
|
| | |
|
| | | public interface IOpenServerActivity
|
| | | {
|
| | | bool IsOpen { get; }
|
| | | bool IsAdvance { get; }
|
| | | bool priorityOpen { get; }
|
| | |
|
| | | event Action<int> onStateUpdate;
|
| | | }
|
| | |
|
| | | public class ILOpenServerActivityProxy : IOpenServerActivity
|
| | | {
|
| | | public bool IsOpen => funcIsOpen();
|
| | |
|
| | | public bool IsAdvance => funcIsAdvance();
|
| | |
|
| | | public bool priorityOpen => funcPriorityOpen();
|
| | |
|
| | | public event Action<int> onStateUpdate;
|
| | |
|
| | | private Func<bool> funcIsOpen;
|
| | | private Func<bool> funcIsAdvance;
|
| | | private Func<bool> funcPriorityOpen;
|
| | |
|
| | | public ILOpenServerActivityProxy(Func<bool> isOpen, Func<bool> isAdvance, Func<bool> priorityOpen)
|
| | | {
|
| | | funcIsOpen = isOpen;
|
| | | funcIsAdvance = isAdvance;
|
| | | funcPriorityOpen = priorityOpen;
|
| | | }
|
| | |
|
| | |
|
| | | public void StateUpdate(int id)
|
| | | {
|
| | | if (onStateUpdate != null)
|
| | | {
|
| | | onStateUpdate(id);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | //修改成控制多个活动模块,如精彩活动模板1,精彩活动模板2 |
| | | |
| | | public class OpenServerActivityCenter : Singleton<OpenServerActivityCenter> |
| | | { |
| | | public event Action openServerActivityStateChange; |
| | | |
| | | //{活动ID:活动接口} |
| | | Dictionary<int, IOpenServerActivity> GameServerActivitys = new Dictionary<int, IOpenServerActivity>(); |
| | | |
| | | public int selectFuncOrder = -1; |
| | | |
| | | public OpenServerActivityCenter() |
| | | { |
| | | TimeUtility.OnServerOpenDayRefresh -= OnServerOpenDayRefresh; |
| | | TimeUtility.OnServerOpenDayRefresh += OnServerOpenDayRefresh; |
| | | } |
| | | |
| | | public void Register(int funcOrder, IOpenServerActivity activity) |
| | | { |
| | | if (!GameServerActivitys.ContainsKey(funcOrder)) |
| | | { |
| | | GameServerActivitys.Add(funcOrder, activity); |
| | | activity.onStateUpdate -= OnStateUpdate; |
| | | activity.onStateUpdate += OnStateUpdate; |
| | | } |
| | | } |
| | | |
| | | 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 GameServerActivitys.Keys) |
| | | { |
| | | if (GameServerActivitys[_order].IsOpen || GameServerActivitys[_order].IsAdvance) |
| | | { |
| | | _functionOrder = _order; |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public bool IsActivityOpen(int _funcOrder) |
| | | { |
| | | bool isOpen = false; |
| | | if (GameServerActivitys.ContainsKey(_funcOrder)) |
| | | { |
| | | isOpen = GameServerActivitys[_funcOrder].IsOpen || GameServerActivitys[_funcOrder].IsAdvance; |
| | | } |
| | | |
| | | return isOpen; |
| | | } |
| | | |
| | | public bool IsPriorityOpenOpen(int _funcOrder) |
| | | { |
| | | if (GameServerActivitys.ContainsKey(_funcOrder)) |
| | | { |
| | | return GameServerActivitys[_funcOrder].priorityOpen; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | public void ProcessErrorTip() |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("ActiveOutTime"); |
| | | } |
| | | } |
| | | |
| | | public interface IOpenServerActivity |
| | | { |
| | | bool IsOpen { get; } |
| | | bool IsAdvance { get; } |
| | | bool priorityOpen { get; } |
| | | |
| | | event Action<int> onStateUpdate; |
| | | } |
| | | |
| | | public class ILOpenServerActivityProxy : IOpenServerActivity |
| | | { |
| | | public bool IsOpen => funcIsOpen(); |
| | | |
| | | public bool IsAdvance => funcIsAdvance(); |
| | | |
| | | public bool priorityOpen => funcPriorityOpen(); |
| | | |
| | | public event Action<int> onStateUpdate; |
| | | |
| | | private Func<bool> funcIsOpen; |
| | | private Func<bool> funcIsAdvance; |
| | | private Func<bool> funcPriorityOpen; |
| | | |
| | | public ILOpenServerActivityProxy(Func<bool> isOpen, Func<bool> isAdvance, Func<bool> priorityOpen) |
| | | { |
| | | funcIsOpen = isOpen; |
| | | funcIsAdvance = isAdvance; |
| | | funcPriorityOpen = priorityOpen; |
| | | } |
| | | |
| | | |
| | | public void StateUpdate(int id) |
| | | { |
| | | if (onStateUpdate != null) |
| | | { |
| | | onStateUpdate(id); |
| | | } |
| | | } |
| | | |
| | | } |