123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 |
- using ET;
- using System.Collections.Generic;
- namespace GFGGame
- {
- public class ActivityDataManager : SingletonBase<ActivityDataManager>
- {
- public void Clear()
- {
- luckyBoxActBonusState.Clear();
- allPlayTimes = 0;
- lastActLuckyBoxId = 0;
- lastActLimitChargeId = 0;
- luckyActTsyBonusState.Clear();
- allTsyPlayTimes = 0;
- lastActLimitTsyId = 0;
- limitStlycActBonusState.Clear();
- allLimitStlycTimes = 0;
- lastActLimitStlycId = 0;
- NewYearLoginInfoDic.Clear();
- }
- /**********************************************************活动*************************************************/
- /// <summary>
- /// 获取指定类型活动当前开启的活动id
- /// </summary>
- /// <returns></returns>
- public int GetCurOpenActiveByType(int type)
- {
- ActivityInfo info = ActivityGlobalDataManager.Instance.GetActivityInfoOneByType(type);
- return (info == null) ? 0 : info.ActivityId;
- }
- /**********************************************************活动弹窗*************************************************/
- public int todayActivityTips = 0;
- public int todayMonthlyCardTips = 0;
- /**********************************************************限时累充*************************************************/
- public int lastActLimitChargeId = 0;
- private int _actLimitChargeId = 0;
- /**********************************************************限时累充*************************************************/
- public bool IsGetNewPlayerReward = false;
- /// <summary>
- /// 当前限时累充活动id
- /// </summary>
- /// <value></value>
- public int actLimitChargeId { get { return _actLimitChargeId; } set { _actLimitChargeId = value; } }
- /**********************************************************限时抽奖活动*********************************************/
- public int lastActLuckyBoxId = 0;
- public int lastActLimitTsyId = 0;
- public int lastActLimitStlycId = 0;
- private int _actLuckyBoxId = 0;
- private int _actLuckyTsyId = 0;
- private int _actLimitStlycId = 0;
- /// <summary>
- /// 当前抽奖活动id
- /// </summary>
- /// <value></value>
- public int actLuckyBoxId { get { return _actLuckyBoxId; } set { _actLuckyBoxId = value; } }
- /// <summary>
- /// 抽奖总次数
- /// </summary>
- /// <value></value>
- public long allPlayTimes { get; set; }
- /// <summary>
- /// 限时抽奖必掉次数
- /// </summary>
- /// <value></value>
- public int lastDrawCount { get; set; }
- /// <summary>
- /// </summary>
- /// <typeparam name="int">奖励key,这里对应抽奖次数</typeparam>
- /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
- /// <returns></returns>
- public Dictionary<int, int> luckyBoxActBonusState = new Dictionary<int, int>();
- /// <summary>
- /// 当前天市垣抽奖活动id
- /// </summary>
- /// <value></value>
- public int actLimitTsyId { get { return _actLuckyTsyId; } set { _actLuckyTsyId = value; } }
- /// <summary>
- /// 天市垣抽奖总次数
- /// </summary>
- /// <value></value>
- public long allTsyPlayTimes { get; set; }
- /// <summary>
- /// 限时天市垣抽奖必掉次数
- /// </summary>
- /// <value></value>
- public int lastTsyDrawCount { get; set; }
- /// <summary>
- /// </summary>
- /// <typeparam name="int">奖励key,这里对应天市垣抽奖次数</typeparam>
- /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
- /// <returns></returns>
- public Dictionary<int, int> luckyActTsyBonusState = new Dictionary<int, int>();
- /// <summary>
- /// 当前隋唐洛阳城活动id
- /// </summary>
- /// <value></value>
- public int actLimitStlycId { get { return _actLimitStlycId; } set { _actLimitStlycId = value; } }
- /// <summary>
- /// 开服活动抽奖总次数
- /// </summary>
- /// <value></value>
- public long allLimitStlycTimes { get; set; }
- /// <summary>
- /// 开服抽奖必掉次数
- /// </summary>
- /// <value></value>
- public int lastStlycDrawCount { get; set; }
- /// <summary>
- /// </summary>
- /// <typeparam name="int">奖励key,这里对应抽奖次数</typeparam>
- /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
- /// <returns></returns>
- public Dictionary<int, int> limitStlycActBonusState = new Dictionary<int, int>();
- public List<ActivityLuckybonusCfg> SortActivityLuckybonusCfg(List<ActivityLuckybonusCfg> list,int typeId)
- {
- list.Sort((ActivityLuckybonusCfg a, ActivityLuckybonusCfg b) =>
- {
- long allPlayTimes = 0;
- int stateA = 0;
- int stateB = 0;
- if (typeId == ConstLimitTimeActivityType.ActLimitLuckyBox) {
- allPlayTimes = ActivityDataManager.Instance.allPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
- stateA = ActivityDataManager.Instance.luckyBoxActBonusState.ContainsKey(a.num) ? 1 : -1;
- stateB = ActivityDataManager.Instance.luckyBoxActBonusState.ContainsKey(b.num) ? 1 : -1;
- }
- else if(typeId == ConstLimitTimeActivityType.ActLimitTsy)
- {
- allPlayTimes = ActivityDataManager.Instance.allTsyPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
- stateA = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(a.num) ? 1 : -1;
- stateB = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(b.num) ? 1 : -1;
- }
- else if (typeId == ConstLimitTimeActivityType.ActLimitStlyc)
- {
- allPlayTimes = ActivityDataManager.Instance.allTsyPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
- stateA = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(a.num) ? 1 : -1;
- stateB = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(b.num) ? 1 : -1;
- }
- if (allPlayTimes >= a.num && allPlayTimes < b.num && stateA < 0) return -1;
- if (allPlayTimes >= b.num && allPlayTimes < a.num && stateB < 0) return 1;
- if (stateA >= 0 && stateB < 0) return 1;
- if (stateB >= 0 && stateA < 0) return -1;
- return a.num - b.num;
- });
- return list;
- }
- /**********************************************************每日登录*************************************************/
- private int _sevenDayLoginLoginId = 1;
- /// <summary>
- /// 七日登录 当日奖励id
- /// </summary>
- /// <value></value>
- public int sevenDayLoginLoginId
- {
- get { return _sevenDayLoginLoginId; }
- set { _sevenDayLoginLoginId = value; }
- }
- private int _sevenDayLoginBonusStatus = 0;
- /// <summary>
- /// 七日登录 当前奖励状态
- /// </summary>
- /// <value></value>
- public int sevenDayLoginBonusStatus
- {
- get { return _sevenDayLoginBonusStatus; }
- set { _sevenDayLoginBonusStatus = value; }
- }
- /******************************************************************************************************************/
- /**********************************************************每日登录修改*************************************************/
- public List<int> sevenDayLoginLoginIdList = new List<int>();
- /// <summary>
- /// 七日登录 当日奖励id
- /// </summary>
- /// <value></value>
- public List<int> sevenDayLoginBonusStatusList = new List<int>();
- /// <summary>
- /// 七日登录 当前奖励状态
- /// </summary>
- /// <value></value>
- ///
- public bool CanGetSevenDayBonus()
- {
- foreach(int a in sevenDayLoginBonusStatusList)
- {
- if (a == 1) return true;
- }
- return false;
- }
- public bool AllSevenDayBonusGot()
- {
- foreach (int a in sevenDayLoginBonusStatusList)
- {
- if (a != 2) return false;
- }
- return true;
- }
- public bool HaveGetSevenDayBonus()
- {
- foreach (int a in sevenDayLoginBonusStatusList)
- {
- if (a == 0) return true;
- }
- return false;
- }
- //判断最后可领取的奖励索引
- public int NowSevenDayBonusDay(bool day = false)
- {
- if(AllSevenDayBonusGot())
- {
- return 8;
- }
- int a = 0;
- int flog = -1;
- if (day)
- {
- for (int j = 0; j < sevenDayLoginBonusStatusList.Count; j++)
- {
- a = sevenDayLoginBonusStatusList[j];
- if (a == 1)
- {
- flog = j;
- return flog;
- }
- }
- }
- else
- {
- for (int j = 0; j < sevenDayLoginBonusStatusList.Count; j++)
- {
- a = sevenDayLoginBonusStatusList[j];
- if (a == 2) flog = j;
- }
- }
- return flog;
- }
- /******************************************************************************************************************/
- private int _firstChargeBonusStatus = 0;
- /// <summary>
- /// 首冲奖励 当前奖励状态,ConstBonusStatus 0不可领,1可领,2已领
- /// </summary>
- /// <value></value>
- public int firstChargeBonusStatus
- {
- get
- {
- var status = GameGlobal.myNumericComponent.GetAsInt(ET.NumericType.FirstRechargeBonusStatus);
- if (status == ConstBonusStatus.GOT)
- {
- return ConstBonusStatus.GOT;
- }
- if (GameGlobal.myNumericComponent.GetAsLong(ET.NumericType.FirstRechargeTotal) > 0)
- {
- return ConstBonusStatus.CAN_GET;
- }
- return ConstBonusStatus.CAN_NOT_GET;
- }
- }
- //招财进宝活动
- public List<int> ActivityZCJBList = new List<int>();
- public int activityZCJBId = 61101;
- public bool CheckZCJBRed()
- {
- List<ActivityDressCfg> zcjbCfgList = new List<ActivityDressCfg>();
- int activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(17);
- zcjbCfgList = ActivityDressCfgArray.Instance.GetCfgsByactivityId(activityId);
- if (zcjbCfgList == null || zcjbCfgList.Count == 0)
- {
- return false;
- }
- ItemData numItem;
- long num;
- if(BagDataManager.Instance.GetBagData().TryGetValue(zcjbCfgList[0].comsumeArr[0][0], out numItem))
- {
- num = numItem.num;
- }
- else
- {
- num = 0;
- }
- for (int i = 0; i < zcjbCfgList.Count; i++)
- {
- if (i == ActivityDataManager.Instance.ActivityZCJBList.Count)
- {
- if (num >= zcjbCfgList[i].comsumeArr[0][1])
- {
- return true;
- }
- }
- }
- return false;
- }
- /**********************************************************每日登录修改*************************************************/
- /// <summary>
- /// 新年签到 登录第几天列表 奖励状态列表
- /// </summary>
- /// <value></value>
- public Dictionary<int,int> NewYearLoginInfoDic = new Dictionary<int, int>();
- public bool CanGetNewYearLoginRed()
- {
- //foreach (var a in NewYearLoginInfoDic)
- //{
- // if (a.Value == 1) return true;
- //}
- return false;
- }
- //返回直购时间内打折扣的套装id
- private int GetCheckDiscountSuitId()
- {
- return 0;
- }
- public Dictionary<long, long> TipsStatusDic = new Dictionary<long, long>();
- //珍珠赠礼是否弹窗
- public bool CheckPearRebateTips(int id)
- {
- bool flog = true;
- ActivityOpenCfg activityCfg = ActivityOpenCfgArray.Instance.GetCfg(id);
- for(int i =0;i< activityCfg.paramsArr.Length;i++)
- {
- ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(activityCfg.paramsArr[i]);
- int buyNum = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
- if (shopCfg.maxBuyNum == 0 || buyNum < shopCfg.maxBuyNum)
- {
- flog = false;
-
- }
- }
- if(!flog)
- {
- if (ActivityGlobalDataManager.Instance.IsActivityOpen(id))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- //根据创角时间判断活动是否开启
- public bool CheckActivityByRoleTime(int id)
- {
- return ActivityGlobalDataManager.Instance.IsActivityOpen(id);
- //ActivityOpenCfg item = ActivityOpenCfgArray.Instance.GetCfg(id);
- //if (item == null || item.CreatTime == 0)
- //{
- // return false;
- //}
- ////创角时间
- //long time = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole().CreateTime;
- //long laterTime = (TimeHelper.ServerNow() - time) / 1000 / 60;
- //if (laterTime >= item.CreatTime && laterTime < (item.CreatTime + item.OpenLastTime))
- //{
- // return true;
- //}
- //return false;
- }
- public long GetActivityTime(int id)
- {
- ActivityOpenCfg _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(id);
- int endTime = (_activityCfg.AfterCreatRoleTime * 24 * 60) + _activityCfg.OpenLastTime;
- endTime = endTime * 60;
- long time = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole().CreateTime;
- long laterTime = (TimeHelper.ServerNow() - time)/1000;
- long curTime = (endTime - laterTime)* 1000;
- return curTime;
- }
- public bool isExtendTime(int day)
- {
- int id = ActivityDataManager.Instance.GetCurOpenActiveByType(17);
- ActivityOpenCfg activityCfg = ActivityOpenCfgArray.Instance.GetCfg(id);
- if (activityCfg != null)
- {
- long endTime = TimeUtil.DateTimeToTimestamp(activityCfg.endTime);
- long ExtendTime = (day * 24 * 60 * 60 * 1000);
- long currentTime = TimeHelper.ServerNow();
- if (currentTime > endTime)
- {
- if ((currentTime - endTime) <= ExtendTime)
- {
- return true;
- }
- }
- }
- return false;
- }
- /***************************转盘活动*******************************/
- public int TurnTableActivityType = 102;
- public int TurnTableTimes = 300;
- public int TipsDropId = 0;
- public int StartDropId = 40000002;
- //奖励状态
- public Dictionary<int, int> TurnRewardStateDic = new Dictionary<int, int>();
- //抽奖结果
- public Dictionary<int, List<ItemInfoProto>> threeTurnResult = new Dictionary<int, List<ItemInfoProto>>() {};
- public List<ItemInfoProto> TurnRewardList = new List<ItemInfoProto>();
- public List<ItemInfoProto> TurnSpecialRewardList = new List<ItemInfoProto>();
- public bool TurnTableRewardRed()
- {
- foreach(var item in TurnRewardStateDic)
- {
- if(item.Value == 1)
- {
- return true;
- }
- }
- return false;
- }
- /*****************************************************************/
- }
- }
|