示例#1
0
        public static short _currMaxLv = GameConfigSet.CurrMaxLv.ToShort(); //玩家最大等级

        /// <summary>
        /// 将星佣兵完成任务后奖励物品名称
        /// </summary>
        /// <param name="prize"></param>
        /// <returns></returns>
        public static string PrizeItemName(PrizeInfo prize)
        {
            string name = string.Empty;
            switch (prize.Type)
            {
                case RewardType.CrystalId:
                    CrystalInfo crystal = new ShareCacheStruct<CrystalInfo>().FindKey(prize.ItemID);
                    name = crystal == null ? string.Empty : crystal.CrystalName;
                    break;
                case RewardType.Item:
                    ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(prize.ItemID);
                    name = itemInfo == null ? string.Empty : itemInfo.ItemName;
                    break;
                case RewardType.Spare:
                    SparePartInfo sparePartInfo = new ShareCacheStruct<SparePartInfo>().FindKey(prize.ItemID);
                    name = sparePartInfo == null ? string.Empty : sparePartInfo.Name;
                    break;
                case RewardType.CrystalType:
                    name = string.Format(LanguageManager.GetLang().St_Crystal,
                                         CrystalHelper.GetQualityName(prize.CrystalType.ToEnum<CrystalQualityType>()),
                                         string.Empty);
                    break;

            }
            return name;
        }
示例#2
0
        public static UserTakePrize GetUserTake(PrizeInfo prize, string userID, FestivalInfo info)
        {
            UserTakePrize userPrize = new UserTakePrize();
            userPrize.CreateDate = DateTime.Now;
            userPrize.ID = Guid.NewGuid().ToString();
            userPrize.UserID = Convert.ToInt32(userID);
            userPrize.MailContent = info.FestivalExtend.KeyWord;
            userPrize.IsTasked = false;
            userPrize.TaskDate = MathUtils.SqlMinDate;
            userPrize.ItemPackage = string.Empty;
            userPrize.SparePackage = string.Empty;
            userPrize.CrystalPackage = string.Empty;
            userPrize.EnchantPackage = string.Empty;
            userPrize.OpUserID = 10000;
            switch (prize.Type)
            {
                case RewardType.GameGoin:
                    userPrize.GameCoin = prize.Num;
                    userPrize.MailContent += string.Format(LanguageManager.GetLang().St_GameCoin, prize.Num);
                    break;
                case RewardType.Obtion:
                    userPrize.ObtainNum = prize.Num;
                    userPrize.MailContent += string.Format(LanguageManager.GetLang().St_ObtionNum, prize.Num);
                    break;
                case RewardType.ExpNum:
                    userPrize.ExpNum = prize.Num;
                    userPrize.MailContent += string.Format(LanguageManager.GetLang().St_ExpNum, prize.Num);
                    break;
                case RewardType.EnergyNum:
                    userPrize.EnergyNum = prize.Num;
                    userPrize.MailContent += string.Format(LanguageManager.GetLang().St_EnergyNum, prize.Num);
                    break;
                case RewardType.Experience:
                    break;
                case RewardType.Gold:
                    userPrize.Gold = prize.Num;
                    userPrize.MailContent += string.Format(LanguageManager.GetLang().St_GiftGoldNum, prize.Num);
                    break;
                case RewardType.Item:
                    userPrize.ItemPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(prize.ItemID);
                    if (itemInfo != null)
                    {
                        userPrize.MailContent += string.Format("{0}*{1}", itemInfo.ItemName, prize.Num);
                    }
                    break;
                case RewardType.CrystalType:
                    //List<CrystalInfo> crystalArray2 = new ShareCacheStruct<CrystalInfo>().FindAll(CrystalInfo.Index_CrystalQuality, prize.CrystalType);
                    //userPrize.CrystalPackage = string.Format("{0}={1}={2}", itemID, prize.UserLv, itemNum);
                    break;
                case RewardType.CrystalId:

                    userPrize.CrystalPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    CrystalInfo crystal = new ShareCacheStruct<CrystalInfo>().FindKey(prize.ItemID);
                    if (crystal != null)
                    {
                        userPrize.MailContent += string.Format("{0}*{1}", crystal.CrystalName, prize.Num);
                    }
                    break;
                case RewardType.Spare:
                    userPrize.SparePackage = string.Format("{0}={1}={2}", prize.ItemID, prize.Num, prize.Num);
                    SparePartInfo spare = new ShareCacheStruct<SparePartInfo>().FindKey(prize.ItemID);
                    if (spare != null)
                    {
                        userPrize.MailContent += string.Format("{0}*{1}", spare.Name, prize.Num);
                    }
                    break;
                case RewardType.Enchant:
                    userPrize.EnchantPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    EnchantInfo enchantInfo = new ShareCacheStruct<EnchantInfo>().FindKey(prize.ItemID);
                    if (enchantInfo != null)
                    {
                        userPrize.MailContent += string.Format("{0}*{1}", enchantInfo.EnchantName, prize.Num);
                    }
                    break;
                default:
                    break;
            }
            return userPrize;
        }
示例#3
0
        /// <summary>
        /// 获得奖励
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="prize"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static UserTakePrize GetUserTake(string userID, PrizeInfo prize, string content)
        {
            GameUser user = new GameDataCacheSet<GameUser>().FindKey(userID);
            if (user == null)
            {
                return null;
            }
            UserTakePrize userPrize = new UserTakePrize();
            userPrize.CreateDate = DateTime.Now;
            userPrize.ID = Guid.NewGuid().ToString();
            userPrize.UserID = Convert.ToInt32(userID);
            userPrize.MailContent = content;
            userPrize.IsTasked = false;
            userPrize.TaskDate = MathUtils.SqlMinDate;
            userPrize.ItemPackage = string.Empty;
            userPrize.SparePackage = string.Empty;
            userPrize.CrystalPackage = string.Empty;
            userPrize.EnchantPackage = string.Empty;
            userPrize.OpUserID = 10000;
            string prizeContent = string.Empty;
            switch (prize.Type)
            {
                case RewardType.GameGoin:
                    userPrize.GameCoin = prize.Num;
                    prizeContent = string.Format(LanguageManager.GetLang().St_GameCoin, prize.Num);
                    break;
                case RewardType.Obtion:
                    userPrize.ObtainNum = prize.Num;
                    prizeContent = string.Format(LanguageManager.GetLang().St_ObtionNum, prize.Num);
                    break;
                case RewardType.ExpNum:
                    userPrize.ExpNum = prize.Num;
                    prizeContent = string.Format(LanguageManager.GetLang().St_ExpNum, prize.Num);
                    break;
                case RewardType.EnergyNum:
                    userPrize.EnergyNum = prize.Num;
                    prizeContent = string.Format(LanguageManager.GetLang().St_EnergyNum, prize.Num);
                    break;
                case RewardType.Experience:
                    break;
                case RewardType.Gold:
                    userPrize.Gold = prize.Num;
                    prizeContent = string.Format(LanguageManager.GetLang().St_GiftGoldNum, prize.Num);
                    break;
                case RewardType.Item:
                    userPrize.ItemPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(prize.ItemID);
                    if (itemInfo != null)
                    {
                        prizeContent = string.Format("{0}*{1}", itemInfo.ItemName, prize.Num);
                    }
                    break;
                case RewardType.CrystalId:

                    userPrize.CrystalPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    CrystalInfo crystal = new ConfigCacheSet<CrystalInfo>().FindKey(prize.ItemID);
                    if (crystal != null)
                    {
                        prizeContent = string.Format("{0}*{1}", crystal.CrystalName, prize.Num);
                    }
                    break;
                case RewardType.Spare:
                    userPrize.SparePackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    SparePartInfo spare = new ConfigCacheSet<SparePartInfo>().FindKey(prize.ItemID);
                    if (spare != null)
                    {
                        prizeContent = string.Format("{0}*{1}", spare.Name, prize.Num);
                    }
                    break;
                case RewardType.Enchant:
                    userPrize.EnchantPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    EnchantInfo enchantInfo = new ConfigCacheSet<EnchantInfo>().FindKey(prize.ItemID);
                    if (enchantInfo != null)
                    {
                        prizeContent = string.Format("{0}*{1}", enchantInfo.EnchantName, prize.Num);
                    }
                    break;
                default:
                    break;
            }
            if (!string.IsNullOrEmpty(prizeContent))
            {
                userPrize.MailContent = string.Format(content, user.NickName, prizeContent);
            }
            return userPrize;
        }
示例#4
0
 /// <summary>
 /// 奖励物品名称,数量
 /// </summary>
 /// <param name="prize"></param>
 /// <returns></returns>
 public static string MysteryRewardName(GameUser user, PrizeInfo prize)
 {
     string prizeContent = string.Empty;
     switch (prize.Type)
     {
         case RewardType.GameGoin:
             prizeContent = string.Format(LanguageManager.GetLang().St_GameCoin, prize.Num);
             user.GameCoin = MathUtils.Addition(user.GameCoin, prize.Num);
             break;
         case RewardType.Obtion:
             prizeContent = string.Format(LanguageManager.GetLang().St_ObtionNum, prize.Num);
             user.ObtainNum = MathUtils.Addition(user.ObtainNum, prize.Num);
             break;
         case RewardType.ExpNum:
             prizeContent = string.Format(LanguageManager.GetLang().St_ExpNum, prize.Num);
             user.ExpNum = MathUtils.Addition(user.ExpNum, prize.Num);
             break;
         case RewardType.EnergyNum:
             prizeContent = string.Format(LanguageManager.GetLang().St_EnergyNum, prize.Num);
             user.EnergyNum = MathUtils.Addition(user.EnergyNum, prize.Num.ToShort());
             break;
         case RewardType.Experience:
             UserHelper.UserGeneralExp(user.UserID, prize.Num);
             break;
         case RewardType.Gold:
             prizeContent = string.Format(LanguageManager.GetLang().St_GiftGoldNum, prize.Num);
             user.GiftGold = MathUtils.Addition(user.GiftGold, prize.Num);
             break;
         case RewardType.Item:
             short itemLv = prize.UserLv > 0 ? prize.UserLv : 1.ToShort();
             int priNum = prize.Num > 0 ? prize.Num : 1;
             ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(prize.ItemID);
             if (itemInfo != null)
             {
                 UserItemHelper.AddUserItem(user.UserID, itemInfo.ItemID, priNum, itemLv);
                 prizeContent = string.Format("{0}*{1}", itemInfo.ItemName, prize.Num);
             }
             break;
         case RewardType.CrystalId:
             short cLv = prize.UserLv > 0 ? prize.UserLv : 1.ToShort();
             CrystalInfo crystal = new ConfigCacheSet<CrystalInfo>().FindKey(prize.ItemID);
             if (crystal != null)
             {
                 CrystalHelper.AppendCrystal(user.UserID, crystal.CrystalID, cLv);
                 prizeContent = string.Format("{0}*{1}", crystal.CrystalName, prize.Num);
             }
             break;
         case RewardType.Spare:
             break;
         case RewardType.Enchant:
             break;
         default:
             break;
     }
     return prizeContent;
 }
示例#5
0
 /// <summary>
 /// 竞技场奖励
 /// </summary>
 /// <param name="userInfo"></param>
 /// <param name="prizeInfo"></param>
 public static string SportVictoryReward(GameUser userInfo, PrizeInfo prizeInfo)
 {
     string content = string.Empty;
     if (prizeInfo.Type == RewardType.GameGoin)
     {
         userInfo.GameCoin = MathUtils.Addition(userInfo.GameCoin, prizeInfo.Num, int.MaxValue);
         //userInfo.Update();
         content = string.Format(LanguageManager.GetLang().St_GameCoin, prizeInfo.Num) + ",";
     }
     else if (prizeInfo.Type == RewardType.Obtion)
     {
         userInfo.ObtainNum = MathUtils.Addition(userInfo.ObtainNum, prizeInfo.Num, int.MaxValue);
         //userInfo.Update();
         content = content + string.Format(LanguageManager.GetLang().St_ObtionNum, prizeInfo.Num) + ",";
     }
     else if (prizeInfo.Type == RewardType.EnergyNum)
     {
         userInfo.EnergyNum = MathUtils.Addition(userInfo.EnergyNum, (short)prizeInfo.Num, short.MaxValue);
         //userInfo.Update();
         content = content + string.Format(LanguageManager.GetLang().St_EnergyNum, prizeInfo.Num) + ",";
     }
     else if (prizeInfo.Type == RewardType.ExpNum)
     {
         userInfo.ExpNum = MathUtils.Addition(userInfo.ExpNum, prizeInfo.Num, int.MaxValue);
         //userInfo.Update();
         content = content + string.Format(LanguageManager.GetLang().St_ExpNum, prizeInfo.Num) + ",";
     }
     else if (prizeInfo.Type == RewardType.Gold)
     {
         userInfo.ItemGold = MathUtils.Addition(userInfo.ItemGold, prizeInfo.Num, int.MaxValue);
         //userInfo.Update();
         content = content + string.Format(LanguageManager.GetLang().St_GiftGoldNum, prizeInfo.Num) + ",";
     }
     else if (prizeInfo.Type == RewardType.Experience)
     {
         UserHelper.UserGeneralExp(userInfo.UserID, prizeInfo.Num);
         content = content + string.Format(LanguageManager.GetLang().St_Experience, prizeInfo.Num) + ",";
     }
     else if (prizeInfo.Type == RewardType.Item)
     {
         UserItemHelper.AddUserItem(userInfo.UserID, prizeInfo.ItemID, prizeInfo.Num);
         ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(prizeInfo.ItemID);
         if (itemInfo != null)
         {
             content = content + string.Format(LanguageManager.GetLang().St_Item, itemInfo.ItemName,prizeInfo.UserLv, prizeInfo.Num) + ",";
         }
     }
     else if (prizeInfo.Type == RewardType.CrystalType)
     {
         List<CrystalInfo> crystalArray2 = new ShareCacheStruct<CrystalInfo>().FindAll(m => m.CrystalQuality == prizeInfo.CrystalType);
         if (crystalArray2.Count > 0)
         {
             int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count);
             CrystalInfo crystal = new ShareCacheStruct<CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID);
             if (crystal != null)
             {
                 UserHelper.CrystalAppend(userInfo.UserID, crystal.CrystalID, 2);
                 content = content + string.Format(LanguageManager.GetLang().St_Crystal, CrystalHelper.GetQualityName(prizeInfo.CrystalType), crystal.CrystalName) + ",";
             }
         }
     }
     else if (prizeInfo.Type == RewardType.CrystalId)
     {
         UserHelper.CrystalAppend(userInfo.UserID, prizeInfo.ItemID, 2);
         CrystalInfo info = new ShareCacheStruct<CrystalInfo>().FindKey(prizeInfo.ItemID);
         if (info != null)
         {
             content = content + string.Format(LanguageManager.GetLang().St_Crystal, CrystalHelper.GetQualityName(info.CrystalQuality), info.CrystalName) + ",";
         }
     }
     return content.Substring(0, content.Length - 1);
 }
示例#6
0
 public void SendChat(PrizeInfo prize, string NickName, string ItemName)
 {
     if (prize.Desc != null && prize.Desc != string.Empty)
     {
         new TjxChatService().SystemSend(ChatType.World, string.Format(prize.Desc,
                                         NickName, ItemName));
     }
 }