using System; using System.Collections.Generic; using System.Linq; using UnityEngine; public class OSActivityManager : GameSystemManager { Dictionary rankOpenDays = new Dictionary(); //排行榜类型:【开始开服天, 结束开服天】 public Dictionary mainLevelRankAwards = new Dictionary(); //主线关卡名次:奖励 public Dictionary heroCallRankAwards = new Dictionary(); //武将招募名次:奖励 public List osHeroCallGiftSortList = new List(); //开服招募礼包 充值ID + 100000000 Dictionary rankTypeToFuncID = new Dictionary() { {3, 45}, {4, 46}, }; public override void Init() { DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += BeforePlayerDataInitialize; StoreModel.Instance.RefreshBuyShopLimitEvent += RefreshStore; FuncOpen.Instance.OnFuncStateChangeEvent += FuncStateChange; ParseConfig(); } public override void Release() { DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= BeforePlayerDataInitialize; StoreModel.Instance.RefreshBuyShopLimitEvent -= RefreshStore; FuncOpen.Instance.OnFuncStateChangeEvent -= FuncStateChange; } void BeforePlayerDataInitialize() { } void ParseConfig() { var config = FuncConfigConfig.Get("OSABillboard"); rankOpenDays = ConfigParse.ParseIntArrayDict(config.Numerical1); mainLevelRankAwards = ConfigParse.ParseIntArray2Dict(config.Numerical2); heroCallRankAwards = ConfigParse.ParseIntArray2Dict(config.Numerical3); var list = StoreModel.Instance.storeTypeDict[(int)StoreFunc.OSHeroCall]; var _list = RechargeManager.Instance.GetCTGIDListByType(18); for (int i = 0; i < list.Count; i++) { var item = list[i]; osHeroCallGiftSortList.Add(item.shopId); } for (int i = 0; i < _list.Count; i++) { osHeroCallGiftSortList.Add(_list[i] + 100000000); } } // 开服排行活动是否开启 public bool IsOpened(int rankType) { if (!rankTypeToFuncID.ContainsKey(rankType)) { return false; } if (!FuncOpen.Instance.IsFuncOpen(rankTypeToFuncID[rankType])) { return false; } //功能开启里有开始天以开启为准,活动结束后延迟一天关闭展示 if (!rankOpenDays.ContainsKey(rankType)) { return false; } var openDays = rankOpenDays[rankType]; if (TimeUtility.OpenDay > openDays[1]) { return false; } return true; } public int GetEndTime(int rankType) { if (!rankOpenDays.ContainsKey(rankType)) { return 0; } var openDays = rankOpenDays[rankType]; return TimeUtility.GetRemindTimeByOpenDay(openDays[1]); } int CmpGift(int a, int b) { bool isSaleOutA = false; bool isSaleOutB = false; if (a < 100000000) { //商店 isSaleOutA = StoreModel.Instance.GetShopIDState(a) == 1; } else { RechargeManager.Instance.TryGetRechargeCount(a % 100000000, out RechargeCount countData); if (countData.totalCount >= CTGConfig.Get(a % 100000000).DailyBuyCount) { isSaleOutA = true; } } if (b < 100000000) { isSaleOutB = StoreModel.Instance.GetShopIDState(b) == 1; } else { RechargeManager.Instance.TryGetRechargeCount(b % 100000000, out RechargeCount countData); if (countData.totalCount >= CTGConfig.Get(b % 100000000).DailyBuyCount) { isSaleOutB = true; } } if (isSaleOutA != isSaleOutB) { return isSaleOutA ? 1 : -1; } return a.CompareTo(b); } public void RefreshGiftSortList() { osHeroCallGiftSortList.Sort(CmpGift); } void RefreshStore() { UpdateRedpoint(); } Redpoint osMainLevelRedpoint = new Redpoint(MainRedDot.RedPoint_OSMainLevel); Redpoint osHeroCallRedpoint = new Redpoint(MainRedDot.RedPoint_OSHeroCard); public void UpdateRedpoint() { osMainLevelRedpoint.state = !DayRemind.Instance.GetDayRemind(DayRemind.OSMainLevel) ? RedPointState.Simple : RedPointState.None; osHeroCallRedpoint.state = RedPointState.None; if (StoreModel.Instance.freeShopDict.Count == 0) return; if (StoreModel.Instance.freeShopDict.ContainsKey((int)StoreFunc.OSHeroCall)) { var shopList = StoreModel.Instance.freeShopDict[(int)StoreFunc.OSHeroCall]; for (int i = 0; i < shopList.Count; i++) { var shopID = shopList[i]; var config = StoreConfig.Get(shopID); if (StoreModel.Instance.GetShopLimitBuyCount(shopID) < config.LimitCnt) { osHeroCallRedpoint.state = RedPointState.Simple; break; } } } } private void FuncStateChange(int funcId) { switch ((FuncOpenEnum)funcId) { case FuncOpenEnum.OSMainLevl: case FuncOpenEnum.OSHeroCall: UpdateRedpoint(); break; } } }