Example #1
0
        /// <summary>
        /// 给奖励
        /// </summary>
        public override bool GiveAward(GameClient client, Int32 NeedYuanBao)
        {
            if (!InAwardTime())
            {
                return(false);
            }

            string strFlag = RoleParamName.WeekEndInputFlag;
            String WeekEndInputRandData = Global.GetRoleParamByName(client, strFlag);

            //
            string[] InputRandData = WeekEndInputRandData.Split('#');
            if (InputRandData.Length < 2)
            {
                return(false);
            }

            // 奖品数据 "WhitchOne$RewardID$id,id,id,id|WhitchOne$RewardID$id,id,id,id|WhitchOne$RewardID$id,id,id,id"
            string[] AwardArray = InputRandData[1].Split('|');
            if (AwardArray.Length <= 0)
            {
                return(false);
            }

            // 根据元宝限制找到对应的AwardID给奖励
            for (int n = 0; n < AwardArray.Length; ++n)
            {
                string   awarditem = AwardArray[n];
                string[] award     = awarditem.Split('$');

                int AwardID = Convert.ToInt32(award[1]);
                WeekEndInputTypeData InputType = null;
                InputTypeDict.TryGetValue(AwardID, out InputType);
                if (null == InputType || InputType.MinZuanShi != NeedYuanBao)
                {
                    continue;
                }

                List <WeekEndInputAwardData> AwardList = null;
                AwardItemDict.TryGetValue(AwardID, out AwardList);
                if (null != AwardList)
                {
                    string[] arrayid = award[2].Split(',');
                    for (int i = 0; i < arrayid.Length; ++i)
                    {
                        int id = Convert.ToInt32(arrayid[i]);
                        if (id > 0 && id <= AwardList.Count)
                        {
                            GiveAward(client, AwardList[id - 1]); // 给奖励
                        }
                    }
                }
            }

            return(true);
        }
Example #2
0
        public int GetNeedGoodsSpace(GameClient client, int NeedYuanBao)
        {
            int result;

            if (!this.InAwardTime())
            {
                result = 0;
            }
            else
            {
                string   strFlag = "WeekEndInputFlag";
                string   WeekEndInputRandData = Global.GetRoleParamByName(client, strFlag);
                string[] InputRandData        = WeekEndInputRandData.Split(new char[]
                {
                    '#'
                });
                if (InputRandData.Length < 2)
                {
                    result = 0;
                }
                else
                {
                    string[] AwardArray = InputRandData[1].Split(new char[]
                    {
                        '|'
                    });
                    if (AwardArray.Length <= 0)
                    {
                        result = 0;
                    }
                    else
                    {
                        foreach (string awarditem in AwardArray)
                        {
                            string[] award = awarditem.Split(new char[]
                            {
                                '$'
                            });
                            int AwardID = Convert.ToInt32(award[1]);
                            WeekEndInputTypeData InputType = null;
                            this.InputTypeDict.TryGetValue(AwardID, out InputType);
                            if (InputType != null && InputType.MinZuanShi == NeedYuanBao)
                            {
                                return(InputType.Num);
                            }
                        }
                        result = 0;
                    }
                }
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// 获得指定档次的奖励需要的背包空间
        /// </summary>
        public int GetNeedGoodsSpace(GameClient client, Int32 NeedYuanBao)
        {
            if (!InAwardTime())
            {
                return(0);
            }

            string strFlag = RoleParamName.WeekEndInputFlag;
            String WeekEndInputRandData = Global.GetRoleParamByName(client, strFlag);

            //
            string[] InputRandData = WeekEndInputRandData.Split('#');
            if (InputRandData.Length < 2)
            {
                return(0);
            }

            // 奖品数据 "WhitchOne$RewardID$id,id,id,id|WhitchOne$RewardID$id,id,id,id|WhitchOne$RewardID$id,id,id,id"
            string[] AwardArray = InputRandData[1].Split('|');
            if (AwardArray.Length <= 0)
            {
                return(0);
            }

            // 根据元宝限制找到对应的AwardID给奖励
            for (int n = 0; n < AwardArray.Length; ++n)
            {
                string   awarditem = AwardArray[n];
                string[] award     = awarditem.Split('$');

                int AwardID = Convert.ToInt32(award[1]);
                WeekEndInputTypeData InputType = null;
                InputTypeDict.TryGetValue(AwardID, out InputType);
                if (null != InputType && InputType.MinZuanShi == NeedYuanBao)
                {
                    return(InputType.Num);
                }
            }

            return(0);
        }
Example #4
0
 public bool Init()
 {
     try
     {
         string ZhouMoChongZhiTime = GameManager.systemParamsList.GetParamValueByName("ZhouMoChongZhiTime");
         if (!string.IsNullOrEmpty(ZhouMoChongZhiTime))
         {
             if (!this.ParseActivityTime(ZhouMoChongZhiTime))
             {
                 return(false);
             }
         }
         string   fileName = Global.IsolateResPath("Config/Gifts/ZhouMoChongZhiType.xml");
         XElement xmlType  = GeneralCachingXmlMgr.GetXElement(fileName);
         if (null == xmlType)
         {
             return(false);
         }
         IEnumerable <XElement> xmlItems = xmlType.Elements();
         foreach (XElement xmlItem in xmlItems)
         {
             if (null != xmlItem)
             {
                 WeekEndInputTypeData myInputType = new WeekEndInputTypeData();
                 int id = (int)Global.GetSafeAttributeLong(xmlItem, "ID");
                 myInputType.MinZhuanSheng = Global.GMax(0, (int)Global.GetSafeAttributeLong(xmlItem, "MinZhuanSheng"));
                 myInputType.MinLevel      = Global.GMax(0, (int)Global.GetSafeAttributeLong(xmlItem, "MinLevel"));
                 myInputType.MaxZhuanSheng = Global.GMax(0, (int)Global.GetSafeAttributeLong(xmlItem, "MaxZhuanSheng"));
                 myInputType.MaxLevel      = Global.GMax(0, (int)Global.GetSafeAttributeLong(xmlItem, "MaxLevel"));
                 myInputType.MinZuanShi    = Global.GMax(0, (int)Global.GetSafeAttributeLong(xmlItem, "MinZuanShi"));
                 myInputType.Num           = Global.GMax(0, (int)Global.GetSafeAttributeLong(xmlItem, "Num"));
                 this.InputTypeDict[id]    = myInputType;
             }
         }
         fileName = Global.IsolateResPath("Config/Gifts/ZhouMoChongZhi.xml");
         XElement xmlAward = GeneralCachingXmlMgr.GetXElement(fileName);
         if (null == xmlAward)
         {
             return(false);
         }
         IEnumerable <XElement> xmlItemsAward = xmlAward.Elements();
         foreach (XElement xmlRandAwardList in xmlItemsAward)
         {
             if (null != xmlRandAwardList)
             {
                 List <WeekEndInputAwardData> myRandAwardList = new List <WeekEndInputAwardData>();
                 int id = (int)Global.GetSafeAttributeLong(xmlRandAwardList, "ID");
                 IEnumerable <XElement> xmlRandAwards = xmlRandAwardList.Elements();
                 foreach (XElement xmlRandAward in xmlRandAwards)
                 {
                     WeekEndInputAwardData myRandAward = new WeekEndInputAwardData();
                     myRandAward.id           = (int)Global.GetSafeAttributeLong(xmlRandAward, "ID");
                     myRandAward.RandBeginNum = Global.GMax(0, (int)Global.GetSafeAttributeLong(xmlRandAward, "BeginNum"));
                     myRandAward.RandEndNum   = Global.GMax(0, (int)Global.GetSafeAttributeLong(xmlRandAward, "EndNum"));
                     myRandAward.RandNumMinus = myRandAward.RandEndNum - myRandAward.RandBeginNum + 1;
                     string   goodsIDs = Global.GetSafeAttributeStr(xmlRandAward, "Goods");
                     string[] fields   = goodsIDs.Split(new char[]
                     {
                         '|'
                     });
                     if (fields.Length <= 0)
                     {
                         LogManager.WriteLog(LogTypes.Warning, string.Format("解析大型周末充值活动配置文件中的物品配置项1失败", new object[0]), null, true);
                     }
                     else
                     {
                         myRandAward.GoodsDataList = HuodongCachingMgr.ParseGoodsDataList(fields, "大型节日周末充值配置1");
                     }
                     myRandAwardList.Add(myRandAward);
                 }
                 this.AwardItemDict[id] = myRandAwardList;
             }
         }
         this.ActivityType = 27;
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Fatal, string.Format("{0}解析出现异常, {1}", "ZhouMoChongZhiType.xml|ZhouMoChongZhi.xml", ex.Message), null, true);
         return(false);
     }
     return(true);
 }
Example #5
0
        public override bool GiveAward(GameClient client, int NeedYuanBao)
        {
            bool result;

            if (!this.InAwardTime())
            {
                result = false;
            }
            else
            {
                string   strFlag = "WeekEndInputFlag";
                string   WeekEndInputRandData = Global.GetRoleParamByName(client, strFlag);
                string[] InputRandData        = WeekEndInputRandData.Split(new char[]
                {
                    '#'
                });
                if (InputRandData.Length < 2)
                {
                    result = false;
                }
                else
                {
                    string[] AwardArray = InputRandData[1].Split(new char[]
                    {
                        '|'
                    });
                    if (AwardArray.Length <= 0)
                    {
                        result = false;
                    }
                    else
                    {
                        foreach (string awarditem in AwardArray)
                        {
                            string[] award = awarditem.Split(new char[]
                            {
                                '$'
                            });
                            int AwardID = Convert.ToInt32(award[1]);
                            WeekEndInputTypeData InputType = null;
                            this.InputTypeDict.TryGetValue(AwardID, out InputType);
                            if (InputType != null && InputType.MinZuanShi == NeedYuanBao)
                            {
                                List <WeekEndInputAwardData> AwardList = null;
                                this.AwardItemDict.TryGetValue(AwardID, out AwardList);
                                if (null != AwardList)
                                {
                                    string[] arrayid = award[2].Split(new char[]
                                    {
                                        ','
                                    });
                                    for (int j = 0; j < arrayid.Length; j++)
                                    {
                                        int id = Convert.ToInt32(arrayid[j]);
                                        if (id > 0 && id <= AwardList.Count)
                                        {
                                            base.GiveAward(client, AwardList[id - 1]);
                                        }
                                    }
                                }
                            }
                        }
                        result = true;
                    }
                }
            }
            return(result);
        }