Beispiel #1
0
        public virtual void RefreshActivity(OperationActivity data)
        {
            Items.Clear();
            bool dirty = false;
            var  list  = data.ItemList;

            for (int i = 0; i < list.Count; i++)
            {
                var item = list[i];
                DBOperActivityItem db = null;
                if (i >= mDBData.Items.Count)
                {
                    db = new DBOperActivityItem();
                    mDBData.Items.Add(db);
                    dirty = true;
                }
                else
                {
                    db = mDBData.Items[i];
                }
                var actItem = MakeItem(item, db, StartTime);

                Items.Add(actItem);
                AddChild(actItem);
            }

            if (dirty)
            {
                MarkDbDirty();
            }
        }
 public override void RefreshActivity(OperationActivity data)
 {
     base.RefreshActivity(data);
     OnSkillLevelup(Controller.mSkill.GetSkillTotalLevel());
     OnPlayerLevelup(Controller.GetLevel());
     foreach (var item in Items)
     {
         if (!item.IsActive)
         {
             continue;
         }
         if (SpecialEventType.TotalSkillsLevel == (SpecialEventType)item.Params[1])
         {
             item.Counter = (ulong)Controller.mSkill.GetSkillTotalLevel();
         }
         else if (SpecialEventType.PlayerLevel == (SpecialEventType)item.Params[1])
         {
             item.Counter = (ulong)Controller.GetLevel();
         }
         else if (SpecialEventType.ExtDataEvent == (SpecialEventType)item.Params[1])
         {
             item.Counter = (ulong)Controller.GetExData(item.Params[2]);
         }
     }
 }
Beispiel #3
0
        public override void RefreshActivity(OperationActivity data)
        {
            base.RefreshActivity(data);
            var lottery = data as OperationActivityLottery;

            ResetNeedMoney    = lottery.ResetNeedMoney;
            DrawLotteryLadder = lottery.DrawLotteryLadder;
#if DEBUG
            Debug.Assert(DrawLotteryLadder.Count < Items.Count);
#endif
        }
Beispiel #4
0
 public virtual bool Init(CharacterController controller, OperationActivity data, DBOperationActivityData db, DateTime begin, DateTime end)
 {
     Controller = controller;
     mDBData    = db;
     Id         = data.Id;
     mDBData.Id = Id;
     StartTime  = begin;
     EndTime    = end;
     Param      = data.Param;
     RefreshActivity(data);
     return(true);
 }
Beispiel #5
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);
        }
Beispiel #6
0
        public override void RefreshActivity(OperationActivity data)
        {
            base.RefreshActivity(data);
            var actRank = data as OperationActivityRank;

            if (eRechargeActivityOpenRule.NewServerAuto == data.OpenRule)
            {
                ScoreTime = DateTime.Parse(Table.GetServerName(Controller.serverId).OpenTime).AddHours(data.ScoreDelayHours).AddSeconds(30);
            }
            else if (eRechargeActivityOpenRule.LimitTime == data.OpenRule ||
                     eRechargeActivityOpenRule.Last == data.OpenRule)
            {
                ScoreTime = actRank.ScoreTime;
            }

            if (null == actRank)
            {
                return;
            }
            foreach (var actItem in Items)
            {
                actItem.Need           = 1;
                actItem.Desc           = "【" + Table.GetDictionary(100002286).Desc[0] + "】";
                actItem.mDBData.Status = 0;
            }

            if (RankType.Level == RankType)
            {
                OnRankDataChange(RankType.Level, (long)Controller.mBag.GetRes(eResourcesType.LevelRes));
            }
            else if (RankType.Money == RankType)
            {
                OnRankDataChange(RankType.Money,
                                 (long)Controller.mBag.GetRes(eResourcesType.GoldRes));
            }


            if (actRank.HasResult)
            {
                MsgRankList list = null;
                if (!actRank.DictRankData.TryGetValue(Controller.serverId, out list))
                {
                    return;
                }

                foreach (var actItem in Items)
                {
                    actItem.mDBData.Status = 0;

                    var needRankIdx = actItem.Params[0];
                    if (-1 == needRankIdx)
                    {
                        if (mDBData.Param >= actItem.Params[1] &&
                            -2 == Controller.CheckCondition(actItem.Condition))
                        {
                            actItem.mDBData.Status = 1;
                        }
                        else
                        {
                            actItem.mDBData.Status = 0;
                        }
                    }
                    else
                    {
                        if (needRankIdx >= 0 && needRankIdx < list.Items.Count)
                        {
                            var rankData = list.Items[needRankIdx];
                            actItem.Desc = string.Format("【{0}】", rankData.Name);

                            if (rankData.CharacterId == Controller.mGuid &&
                                rankData.Value >= actItem.Params[1] &&
                                -2 == Controller.CheckCondition(actItem.Condition))
                            {
                                actItem.mDBData.Status = 1;
                            }
                            else
                            {
                                actItem.mDBData.Status = 0;
                            }
                        }
                    }
                }
            }
        }