コード例 #1
0
        private PlayerOperationActivityItem MakeItem(OperationActivityItem item, DBOperActivityItem db, DateTime time)
        {
            var ret = new PlayerOperationActivityItem();

            ret.mDBData    = db;
            ret.Id         = item.Id;
            ret.Need       = (ulong)item.Params[0];
            ret.TotalTimes = item.TotalTimes;
            ret.Condition  = item.Condition;
            if (-1 == item.OpenDelayDays)
            {
                ret.Begin       = DateTime.MinValue;
                ret.RewardBegin = ret.Begin;
                ret.End         = DateTime.MaxValue;
            }
            else
            {
                ret.Begin       = time.Date.AddDays(item.OpenDelayDays);
                ret.RewardBegin = time.Date.AddDays(item.RewardOpenDelay);
                if (ret.Begin > ret.RewardBegin)
                {
                    ret.RewardBegin = ret.Begin;
                }
                ret.End = ret.Begin.AddDays(item.LastDays);
            }

            ret.Params    = item.Params;
            ret.StrParams = item.StrParams;
            var idx = Controller.GetRole();

            if (idx >= 0 && idx < item.Rewards.Count())
            {
                ret.Rewards = item.Rewards[idx];
            }


            return(ret);
        }
コード例 #2
0
        public bool Load()
        {
            Cleanup();
            Table.ForeachOperationActivity((tb) =>
            {
                var openRule = (eRechargeActivityOpenRule)tb.openTimeRule;
                if (eRechargeActivityOpenRule.None == openRule)
                {
                    return(true);
                }

                OperationActivity act = null;
                var type = (OperationActivityType)tb.activityType;
                if (OperationActivityType.Guide == type)
                {
                    act = new OperationActivityGuide();
                }
                else if (OperationActivityType.Recharge == type)
                {
                    act = new OperationActivityRecharge();
                }
                else if (OperationActivityType.SpecialEvent == type)
                {
                    act = new OperationActivitySpecialEvent();
                }
                else if (OperationActivityType.Investment == type)
                {
                    act = new OperationActivityInvestment();
                }
                else if (OperationActivityType.Rank == type)
                {
                    var rankAct      = new OperationActivityRank();
                    rankAct.RankType = (RankType)tb.activitySonType;
                    act = rankAct;
                }
                else if (OperationActivityType.Lottery == type)
                {
                    var actLottery               = new OperationActivityLottery();
                    actLottery.ResetNeedMoney    = tb.Param[0];
                    actLottery.DrawLotteryLadder = tb.StrParam;
                    act = actLottery;
                }
                else
                {
                    Logger.Fatal("unknown type tb.activityType");
                    return(true);
                }

                if ((OperationActivityUIType)tb.UIType == OperationActivityUIType.Table)
                {
                    act.IsTitle = true;
                }

                Table.ForeachYunYing((tbYunYing) =>
                {
                    if (1 != tbYunYing.IsOpen || tb.Id != tbYunYing.ParentType)
                    {
                        return(true);
                    }

                    var item  = new OperationActivityItem();
                    item.Id   = tbYunYing.Id;
                    item.Name = tbYunYing.Name;
                    //item.Desc = tbYunYing.Desc;
                    item.Params    = tbYunYing.Param;
                    item.StrParams = tbYunYing.StrParam;
                    item.Condition = tbYunYing.ConditionId;
                    //item.Begin = DateTime.MinValue;
                    //item.End = DateTime.MaxValue;
                    item.OpenDelayDays   = tbYunYing.XiangDuiOpenServerTime;
                    item.RewardOpenDelay = tbYunYing.RewardOpenTime;
                    item.LastDays        = tbYunYing.LastTime;
                    item.TotalTimes      = tbYunYing.LingQuTimes;

                    item.Rewards[0] = ParseRewardItem(tbYunYing.JiangLiJob1);
                    item.Rewards[1] = ParseRewardItem(tbYunYing.JiangLiJob2);
                    item.Rewards[2] = ParseRewardItem(tbYunYing.JiangLiJob3);

                    act.ItemList.Add(item);

                    return(true);
                });

                if (0 == act.ItemList.Count && !act.IsTitle)
                {
                    return(true);
                }

                act.Id       = tb.Id;
                act.OpenRule = openRule;
                if (eRechargeActivityOpenRule.None == act.OpenRule)
                {                //关闭
                    return(true);
                }
                else if (eRechargeActivityOpenRule.Last == act.OpenRule)
                {                //持续活动
                    act.StartTime = DateTime.Now;
                    act.EndTime   = DateTime.MaxValue;
                    if (OperationActivityType.Rank == type)
                    {
                        act.ScoreTime = DateTime.Parse(tb.LastTime);
                    }
                }
                else if (eRechargeActivityOpenRule.LimitTime == act.OpenRule)
                {                //固定时间活动
                    act.StartTime = DateTime.Parse(tb.openTime);
                    act.EndTime   = DateTime.Parse(tb.closeTime);
                    if (OperationActivityType.Rank == type)
                    {
                        act.ScoreTime = DateTime.Parse(tb.LastTime);
                    }
                }
                else if (eRechargeActivityOpenRule.NewServerAuto == act.OpenRule)
                {                //新开服
                    act.DelayHours      = int.Parse(tb.openTime);
                    act.LastHours       = int.Parse(tb.closeTime);
                    act.ScoreDelayHours = int.Parse(tb.LastTime);
                }

                //act.CleanUpTime = DateTime.Parse(tb.CleanUpTime);
                act.ServerList = new List <int>();
                act.ServerList.AddRange(tb.activityServer);
                act.Param = tb.Param;


                act.Init();
                DictActivity.Add(act.Id, act);
                return(true);
            });

            return(true);
        }