示例#1
0
        /// <summary>
        /// 奖励物品时是否背包已满
        /// </summary>
        /// <param name="user"></param>
        /// <param name="prizeContent"></param>
        /// <returns></returns>
        public static bool IsPrizeItemName(GameUser user, out string prizeContent)
        {
            prizeContent = string.Empty;
            if (!CrystalHelper.CheckAllowCrystall(user))
            {
                prizeContent = LanguageManager.GetLang().St1305_FateBackpackFull;
                return(false);
            }

            if (UserItemHelper.CheckItemOut(user, ItemStatus.BeiBao))
            {
                prizeContent = LanguageManager.GetLang().St1606_GridNumNotEnough;
                return(false);
            }

            if (UserHelper.IsSpareGridNum(user, 0))
            {
                prizeContent = LanguageManager.GetLang().St1213_GridNumFull;
                return(false);
            }

            if (EnchantHelper.IsEnchantPackage(user.UserID))
            {
                prizeContent = LanguageManager.GetLang().St1259_EnchantGridNumFull;
                return(false);
            }
            return(true);
        }
示例#2
0
        /// <summary>
        /// 奖励命运水晶
        /// </summary>
        public static void GetUserCrystal(GameUser user, CrystalQualityType qualityType)
        {
            List <CrystalInfo> crystalArray2 = new ConfigCacheSet <CrystalInfo>().FindAll(m => m.CrystalQuality == qualityType);

            if (crystalArray2.Count > 0)
            {
                int         randomNum = RandomUtils.GetRandom(0, crystalArray2.Count);
                CrystalInfo crystal   = new ConfigCacheSet <CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID);
                UserHelper.CrystalAppend(user.UserID, crystal.CrystalID, 2);
                string chatcontent = string.Empty;
                if (crystal.CrystalQuality == CrystalQualityType.Orange)
                {
                    chatcontent = LanguageManager.GetLang().St1305_GainQualityNotice;
                }
                else
                {
                    chatcontent = LanguageManager.GetLang().St1305_HighQualityNotice;
                }
                string content = string.Format(chatcontent,
                                               user.NickName,
                                               CrystalHelper.GetQualityName(crystal.CrystalQuality),
                                               crystal.CrystalName
                                               );
                new TjxChatService().SystemSend(ChatType.World, content);
            }
        }
示例#3
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 ConfigCacheSet <CrystalInfo>().FindKey(prize.ItemID);
                name = crystal == null ? string.Empty : crystal.CrystalName;
                break;

            case RewardType.Item:
                ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(prize.ItemID);
                name = itemInfo == null ? string.Empty : itemInfo.ItemName;
                break;

            case RewardType.Spare:
                SparePartInfo sparePartInfo = new ConfigCacheSet <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);
        }
示例#4
0
        /// <summary>
        /// 奖励配置
        /// </summary>
        /// <param name="user"></param>
        public static void ChestGetUserTake(TreasureInfo prize, GameUser user)
        {
            switch (prize.Type)
            {
            case RewardType.GameGoin:
                user.GameCoin = MathUtils.Addition(user.GameCoin, prize.Num.ToInt());
                break;

            case RewardType.Obtion:
                user.ObtainNum = MathUtils.Addition(user.ObtainNum, prize.Num.ToInt());
                break;

            case RewardType.ExpNum:
                user.ExpNum = MathUtils.Addition(user.ExpNum, prize.Num.ToInt());
                break;

            case RewardType.EnergyNum:
                user.EnergyNum = MathUtils.Addition(user.EnergyNum, prize.Num.ToShort());
                break;

            case RewardType.Experience:
                break;

            case RewardType.Gold:
                user.GiftGold = MathUtils.Addition(user.GiftGold, prize.Num.ToInt());
                break;

            case RewardType.Item:
                if (!UserAbilityHelper.UseUserItem(user.UserID, prize.ItemID))
                {
                    UserItemHelper.AddUserItem(user.UserID, prize.ItemID, prize.Num.ToInt());
                }
                break;

            case RewardType.CrystalId:
                short crystalLv = prize.ItemLv > 0 ? prize.ItemLv : 1.ToShort();
                CrystalHelper.AppendCrystal(user.UserID, prize.ItemID, crystalLv);
                break;

            case RewardType.Spare:
                AppendSpare(user, prize.ItemID);
                break;

            case RewardType.Enchant:
                short enchantLv = prize.ItemLv > 0 ? prize.ItemLv : 1.ToShort();
                EnchantHelper.AppendEnchat(user.UserID, prize.ItemID, enchantLv);
                break;

            default:
                break;
            }
        }
示例#5
0
        /// <summary>
        /// 玩家获得奖励
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="prizeList"></param>
        /// <returns></returns>
        public static string GetPrizeUserTake(GameUser userInfo, List <PrizeInfo> prizeList)
        {
            string prizeContent = string.Empty;

            foreach (var prize in prizeList)
            {
                switch (prize.Type)
                {
                case RewardType.GameGoin:
                    userInfo.GameCoin = MathUtils.Addition(userInfo.GameCoin, prize.Num);
                    prizeContent     += string.Format(LanguageManager.GetLang().St_GameCoin, prize.Num) + ",";
                    break;

                case RewardType.ExpNum:
                    userInfo.ExpNum = MathUtils.Addition(userInfo.ExpNum, prize.Num);
                    prizeContent   += string.Format(LanguageManager.GetLang().St_ExpNum, prize.Num) + ",";
                    break;

                case RewardType.EnergyNum:
                    userInfo.EnergyNum = MathUtils.Addition(userInfo.EnergyNum, prize.Num.ToShort());
                    prizeContent      += string.Format(LanguageManager.GetLang().St_EnergyNum, prize.Num) + ",";
                    break;

                case RewardType.HonourNum:
                    GeneralEscalateHelper.AddUserLv(userInfo, prize.Num);
                    prizeContent += string.Format(LanguageManager.GetLang().St_HonourNum, prize.Num) + ",";
                    break;

                case RewardType.Experience:
                    UserHelper.UserGeneralExp(userInfo.UserID, prize.Num);
                    prizeContent += string.Format(LanguageManager.GetLang().St_Experience, prize.Num) + ",";
                    break;

                case RewardType.Gold:
                    userInfo.GiftGold = MathUtils.Addition(userInfo.GiftGold, prize.Num);
                    prizeContent     += string.Format(LanguageManager.GetLang().St_GiftGoldNum, 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 ShareCacheStruct <ItemBaseInfo>().FindKey(prize.ItemID);
                    if (itemInfo != null)
                    {
                        UserItemHelper.AddUserItem(userInfo.UserID, itemInfo.ItemID, priNum, itemLv);
                        prizeContent += string.Format("{0}*{1}", itemInfo.ItemName, priNum) + ",";
                    }
                    break;

                case RewardType.CrystalType:
                    List <CrystalInfo> crystalArray = new ShareCacheStruct <CrystalInfo>().FindAll(s => s.CrystalQuality == prize.CrystalType);
                    if (crystalArray.Count > 0)
                    {
                        int         index1      = RandomUtils.GetRandom(0, crystalArray.Count);
                        CrystalInfo crystalInfo = crystalArray[index1];
                        short       crystalLv   = prize.UserLv > 0 ? prize.UserLv : 1.ToShort();
                        CrystalHelper.AppendCrystal(userInfo.UserID, crystalInfo.CrystalID, crystalLv);
                    }
                    break;

                case RewardType.CrystalId:
                    short       cLv     = prize.UserLv > 0 ? prize.UserLv : 1.ToShort();
                    CrystalInfo crystal = new ShareCacheStruct <CrystalInfo>().FindKey(prize.ItemID);
                    if (crystal != null)
                    {
                        CrystalHelper.AppendCrystal(userInfo.UserID, crystal.CrystalID, cLv);
                        prizeContent += string.Format("{0}*{1}", crystal.CrystalName, prize.Num) + ",";
                    }
                    break;

                case RewardType.Spare:
                    break;

                case RewardType.Enchant:
                    break;

                case RewardType.PayGold:
                    userInfo.PayGold = MathUtils.Addition(userInfo.PayGold, prize.Num);
                    prizeContent    += string.Format(LanguageManager.GetLang().St_PayGoldNum, prize.Num) + ",";
                    break;

                default:
                    break;
                }
            }
            return(prizeContent);
        }
示例#6
0
        public static string HuntingLife(GameUser user, out string errStr)
        {
            #region
            errStr = string.Empty;
            int huntingID  = UserLightLit(user.UserID);
            int huntingID2 = UserNextLight(user.UserID, huntingID);
            UserDailyRestrain userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(user.UserID);
            var probabilityInfo            = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率
            if (probabilityInfo == null)
            {
                return(errStr);
            }
            ProbabilityInfo probability1 = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID2);
            if (userRestrain != null && userRestrain.Funtion2 >= VipHelper.GetVipUseNum(user.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date)
            {
                if (probabilityInfo.Price > user.GameCoin)
                {
                    errStr = LanguageManager.GetLang().St_GameCoinNotEnough;
                    return(errStr);
                }
            }
            //暑期第三弹
            if (huntingID2 == 1001 && !NoviceHelper.IsGianCrystalPack(user))
            {
                errStr = LanguageManager.GetLang().St1305_BeiBaoBackpackFull;
                return(errStr);
            }
            var lightCacheSet = new PersonalCacheStruct <UserLight>();
            if (huntingID != 1001)
            {
                UserLight userLight1 = lightCacheSet.FindKey(user.UserID, huntingID);
                if (userLight1.IsLight == 2)
                {
                    return(string.Empty);
                }
                if (userLight1.IsLight == 1)
                {
                    userLight1.IsLight = 2;
                }
            }
            UserLight userLight = new PersonalCacheStruct <UserLight>().FindKey(user.UserID, huntingID2);
            if (RandomUtils.IsHit(probability1.Light))
            {
                if (userLight != null)
                {
                    userLight.IsLight = 1;
                    if (userLight.HuntingID == 1005)
                    {
                        errStr = LanguageManager.GetLang().St1305_HuntingIDLight;
                    }
                }
                else
                {
                    userLight = new UserLight()
                    {
                        UserID    = user.UserID,
                        HuntingID = huntingID2,
                        IsLight   = 1
                    };
                    lightCacheSet.Add(userLight);
                }
            }

            if (userRestrain != null)
            {
                if (userRestrain.Funtion2 >= VipHelper.GetVipUseNum(user.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date)
                {
                    user.GameCoin = MathUtils.Subtraction(user.GameCoin, probabilityInfo.Price, 0);
                }
                else
                {
                    userRestrain.Funtion2 = MathUtils.Addition(userRestrain.Funtion2, 1, int.MaxValue);
                }
            }
            else
            {
                user.GameCoin = MathUtils.Subtraction(user.GameCoin, probabilityInfo.Price, 0);
            }

            //每种品质的概率
            double[]           probabilityArray2 = { (double)probabilityInfo.Gray, (double)probabilityInfo.Green, (double)probabilityInfo.Blue, (double)probabilityInfo.Purple, (double)probabilityInfo.Yellow, (double)probabilityInfo.Red };
            int                index2            = RandomUtils.GetHitIndex(probabilityArray2);
            CrystalQualityType qualityType       = (CrystalQualityType)Enum.Parse(typeof(CrystalQualityType), (index2 + 1).ToString());
            List <CrystalInfo> crystalArray2     = new ShareCacheStruct <CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= user.UserLv);
            if (crystalArray2.Count > 0)
            {
                int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count);
                var crystal   = new ShareCacheStruct <CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID);
                if (crystal != null && crystal.CrystalQuality == CrystalQualityType.Gray)
                {
                    //wuzf修改 8-15 灰色放在临时背包不存DB
                    CrystalHelper.AppendGrayCrystal(user, crystal.CrystalID);
                }
                else if (crystal != null)
                {
                    var package = UserCrystalPackage.Get(user.UserID);

                    UserCrystalInfo userCrystal = new UserCrystalInfo()
                    {
                        UserCrystalID = Guid.NewGuid().ToString(),
                        CrystalID     = crystal.CrystalID,
                        CrystalLv     = 1,
                        CurrExprience = 0,
                        GeneralID     = 0,
                        IsSale        = 1,
                        CreateDate    = DateTime.Now
                    };
                    package.SaveCrystal(userCrystal);
                    UserLogHelper.AppenCtystalLog(user.UserID, 5, crystal.CrystalID, probabilityInfo.Price, 0, null, 1, 0);
                    //高品质聊天通知);
                    if (crystal.CrystalQuality >= CrystalQualityType.Yellow)
                    {
                        var    cacheChat = new TjxChatService();
                        string content   = string.Format(LanguageManager.GetLang().St1305_HighQualityNotice,
                                                         user.NickName,
                                                         CrystalHelper.GetQualityName(crystal.CrystalQuality),
                                                         crystal.CrystalName
                                                         );
                        cacheChat.SystemSend(ChatType.World, content);
                    }
                }
            }
            return(errStr);

            #endregion
        }
示例#7
0
        /// <summary>
        /// 获得物品
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="prize"></param>
        /// <returns></returns>
        public bool DoPrize(GameUser userInfo, List <PrizeInfo> prizeList)
        {
            try
            {
                bool        isDeduct = false;
                CrystalInfo crystal  = new CrystalInfo();
                content = LanguageManager.GetLang().St_SummerThreeGameCoinNotice.Substring(0, 5);
                foreach (PrizeInfo prize in prizeList)
                {
                    int num = prize.Num;
                    switch (prize.Type)
                    {
                    case RewardType.GameGoin:
                        userInfo.GameCoin = MathUtils.Addition(userInfo.GameCoin, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeGameCoinNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_GameCoin, num) + ",";
                        }
                        break;

                    case RewardType.Obtion:
                        userInfo.ObtainNum = MathUtils.Addition(userInfo.ObtainNum, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeObtionNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_ObtionNum, num) + ",";
                        }
                        break;

                    case RewardType.ExpNum:
                        userInfo.ExpNum = MathUtils.Addition(userInfo.ExpNum, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeExpNumNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_ExpNum, num) + ",";
                        }
                        break;

                    case RewardType.EnergyNum:
                        userInfo.EnergyNum = MathUtils.Addition(userInfo.EnergyNum, (short)num, short.MaxValue);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeEnergyNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_EnergyNum, num) + ",";
                        }
                        break;

                    case RewardType.Experience:
                        UserHelper.UserGeneralExp(userInfo.UserID, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeExperienceNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_Experience, num) + ",";
                        }
                        break;

                    case RewardType.Gold:
                        userInfo.ItemGold = MathUtils.Addition(userInfo.ItemGold, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeGoldNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_GiftGoldNum, num) + ",";
                        }
                        break;

                    case RewardType.Item:
                        if (UserHelper.IsBeiBaoFull(userInfo))
                        {
                            content = LanguageManager.GetLang().St1107_GridNumFull;
                            return(false);
                        }
                        UserItemHelper.AddUserItem(userInfo.UserID, prize.ItemID, num);
                        ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(prize.ItemID);
                        if (itemInfo != null)
                        {
                            if (content.Length == 0)
                            {
                                content = string.Format(LanguageManager.GetLang().St_SummerThreeItemNotice, num);
                            }
                            else
                            {
                                content += string.Format("{0}*{1}", itemInfo.ItemName, num) + ",";
                            }
                        }
                        break;

                    case RewardType.CrystalType:
                        if (!UserCrystalInfo.CheckFull(userInfo.UserID, 0))
                        {
                            content = LanguageManager.GetLang().St1307_FateBackpackFull;
                            return(false);
                        }
                        List <CrystalInfo> crystalArray2 = new ConfigCacheSet <CrystalInfo>().FindAll(m => m.CrystalQuality == prize.CrystalType);
                        if (crystalArray2.Count > 0)
                        {
                            int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count);
                            int crystalID = crystalArray2[randomNum].CrystalID;
                            UserHelper.CrystalAppend(userInfo.UserID, crystalID, 2);
                            CrystalHelper.SendChat(crystalArray2[randomNum].CrystalID, userInfo);
                            crystal = new ConfigCacheSet <CrystalInfo>().FindKey(crystalID);
                            if (crystal != null)
                            {
                                content += string.Format(LanguageManager.GetLang().St_Crystal, CrystalHelper.GetQualityName(crystal.CrystalQuality), crystal.CrystalName) + ",";
                            }
                        }
                        else
                        {
                            TraceLog.WriteError("配置出错");
                            return(false);
                        }
                        break;

                    case RewardType.CrystalId:
                        if (!UserCrystalInfo.CheckFull(userInfo.UserID, 0))
                        {
                            content = LanguageManager.GetLang().St1307_FateBackpackFull;
                            return(false);
                        }
                        UserHelper.CrystalAppend(userInfo.UserID, prize.ItemID, 2);
                        CrystalHelper.SendChat(prize.ItemID, userInfo);
                        crystal = new ConfigCacheSet <CrystalInfo>().FindKey(prize.ItemID);
                        if (crystal != null)
                        {
                            content += string.Format(LanguageManager.GetLang().St_Crystal, CrystalHelper.GetQualityName(crystal.CrystalQuality), crystal.CrystalName) + ",";
                        }
                        break;

                    case RewardType.Spare:
                        int currNum = userInfo.SparePartList.FindAll(m => string.IsNullOrEmpty(m.UserItemID)).Count;
                        if (currNum >= userInfo.UserExtend.SparePartGridNum)
                        {
                            content = LanguageManager.GetLang().St1213_GridNumFull;
                            return(false);
                        }
                        UserSparePart sparePart = UserSparePart.GetRandom(prize.ItemID);
                        SparePartInfo partInfo  = new ConfigCacheSet <SparePartInfo>().FindKey(prize.ItemID);
                        if (partInfo != null && sparePart != null && UserHelper.AddSparePart(userInfo, sparePart))
                        {
                            SendChat(prize, userInfo.NickName, partInfo.Name);
                        }
                        content = string.Empty;
                        break;

                    default:
                        break;
                    }
                    if (prize.Reward == 3 && !string.IsNullOrEmpty(prize.Desc))
                    {
                        content = prize.Desc;
                    }
                    //原因:开启礼包消耗的物品
                    if (prize.DemandItem > 0 && !isDeduct)
                    {
                        UserItemHelper.UseUserItem(userInfo.UserID, prize.DemandItem, prize.DemandNum);
                        isDeduct = true;
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                content = "使用礼包出错!";
                TraceLog.WriteError("使用礼包出错!", ex);
            }
            return(false);
        }
示例#8
0
        /// <summary>
        /// 奖励配置
        /// </summary>
        /// <param name="user"></param>
        /// <param name="status">状态值为1时,下发图片</param>
        public static string GetUserTake(List <PrizeInfo> prizeInfoList, string userID, int status = 0)
        {
            string           HeadID    = string.Empty;
            int              quality   = 0;
            List <PrizeInfo> prizeList = new List <PrizeInfo>();
            var              prize     = prizeInfoList[0];
            string           content   = string.Empty;

            switch (prize.Reward)
            {
            //随机
            case 1:
                if (prizeInfoList.Count > 0)
                {
                    int randomNum = RandomUtils.GetRandom(0, prizeInfoList.Count);
                    prizeList.Add(prizeInfoList[randomNum]);
                }

                break;

            //概率
            case 2:
                int   count   = prizeInfoList.Count;
                int[] precent = new int[count];
                for (int i = 0; i < count; i++)
                {
                    var prize2 = prizeInfoList[i];
                    precent[i] = (prize2.Probability * 1000).ToInt();
                }
                int index = RandomUtils.GetHitIndexByTH(precent);
                prizeList.Add(prizeInfoList[index]);
                break;

            //全部
            case 3:
                prizeList.AddRange(prizeInfoList);
                break;
            }
            prizeList.ForEach(prizeInfo =>
            {
                var cacheSetUser = new PersonalCacheStruct <GameUser>();
                var user         = cacheSetUser.FindKey(userID);

                if (user != null)
                {
                    switch (prizeInfo.Type)
                    {
                    case RewardType.GameGoin:
                        //content += string.Format(LanguageManager.GetLang().St_GameCoin, prizeInfo.Num) + ",";
                        //user.GameCoin = MathUtils.Addition(user.GameCoin, prizeInfo.Num);
                        HeadID = prizeInfo.HeadID;
                        // 1: 乘玩家等级
                        if (prizeInfo.IsMultiplyUserLv == 1)
                        {
                            int coinNumber = 0;
                            // 获取当前玩家等级
                            if (user.UserLv >= 1 && user.UserLv <= 100)
                            {
                                coinNumber = prizeInfo.Num * user.UserLv;
                            }

                            else if (user.UserLv < 1)
                            {
                                coinNumber = prizeInfo.Num * 1;
                            }
                            else
                            {
                                coinNumber = prizeInfo.Num * 100;
                            }
                            content      += string.Format(LanguageManager.GetLang().St_GameCoin, coinNumber) + ",";
                            user.GameCoin = MathUtils.Addition(user.GameCoin, coinNumber);
                        }
                        else
                        {
                            content      += string.Format(LanguageManager.GetLang().St_GameCoin, prizeInfo.Num) + ",";
                            user.GameCoin = MathUtils.Addition(user.GameCoin, prizeInfo.Num);
                        }
                        break;

                    case RewardType.Gold:
                        HeadID        = prizeInfo.HeadID;
                        content      += string.Format(LanguageManager.GetLang().St_GiftGoldNum, prizeInfo.Num) + ",";
                        user.GiftGold = MathUtils.Addition(user.GiftGold, prizeInfo.Num);
                        break;

                    case RewardType.EnergyNum:
                        content       += string.Format(LanguageManager.GetLang().St_EnergyNum, prizeInfo.Num) + ",";
                        user.EnergyNum = MathUtils.Addition(user.EnergyNum, prizeInfo.Num).ToShort();
                        break;

                    case RewardType.ExpNum:
                        content    += string.Format(LanguageManager.GetLang().St_ExpNum, prizeInfo.Num) + ",";
                        user.ExpNum = MathUtils.Addition(user.ExpNum, prizeInfo.Num);
                        break;

                    case RewardType.Experience:
                        content += string.Format(LanguageManager.GetLang().St_Experience, prizeInfo.Num) + ",";
                        GeneralEscalateHelper.AddUserLv(user, prizeInfo.Num);
                        break;

                    case RewardType.CrystalId:
                        var crystalInfo = new ShareCacheStruct <CrystalInfo>().FindKey(prizeInfo.ItemID);
                        if (crystalInfo != null)
                        {
                            //content += string.Format(LanguageManager.GetLang().St_Crystal, crystalInfo.CrystalName) + ",";
                            content += crystalInfo.CrystalName + ",";
                            CrystalHelper.AppendCrystal(user.UserID, crystalInfo.CrystalID, prizeInfo.UserLv);
                        }
                        break;

                    case RewardType.Item:
                        var itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(prizeInfo.ItemID);
                        if (itemInfo != null)
                        {
                            //content += string.Format(LanguageManager.GetLang().St_Item, itemInfo.ItemName,  prizeInfo.Num) + ",";
                            //UserItemHelper.AddUserItem(user.UserID, prizeInfo.ItemID, prizeInfo.Num, prizeInfo.UserLv);
                            if (status == 1)
                            {
                                HeadID   = prizeInfo.HeadID;
                                content += string.Format(LanguageManager.GetLang().St_ItemReward, itemInfo.ItemName, prizeInfo.Num) + ",";
                                UserItemHelper.AddUserItem(user.UserID, prizeInfo.ItemID, prizeInfo.Num, prizeInfo.UserLv);
                            }
                            else
                            {
                                content += string.Format(LanguageManager.GetLang().St_Item, itemInfo.ItemName, prizeInfo.UserLv, prizeInfo.Num) + ",";
                                UserItemHelper.AddUserItem(user.UserID, prizeInfo.ItemID, prizeInfo.Num, prizeInfo.UserLv);
                            }
                        }
                        break;

                    case RewardType.MonsterCard:
                        //  获取 JSON 中的怪物记录
                        var monsterCard = prizeInfoList.Find(s => s.Type == RewardType.MonsterCard);

                        var userPlotInfo = new PersonalCacheStruct <UserPlotPackage>().FindKey(user.UserID);
                        if (userPlotInfo != null)
                        {
                            List <PlotNPCInfo> plotNpcInfoList = new List <PlotNPCInfo>();
                            var userPlotPackageList            = userPlotInfo.PlotPackage.FindAll(x => x.PlotStatus == PlotStatus.Completed);
                            // PlotID
                            if (userPlotPackageList.Count > 0)
                            {
                                userPlotPackageList.ForEach(userPlot =>
                                {
                                    var plotNPCInfo = new ShareCacheStruct <PlotNPCInfo>().Find(x => x.PlotID == userPlot.PlotID);
                                    if (plotNPCInfo != null)
                                    {
                                        plotNpcInfoList.Add(plotNPCInfo);
                                    }
                                });
                                if (plotNpcInfoList.Count > 0)
                                {
                                    int index     = RandomUtils.GetRandom(0, plotNpcInfoList.Count);
                                    int plotNpcID = plotNpcInfoList[index].PlotNpcID;

                                    var plotEmbattleInfo = new ShareCacheStruct <PlotEmbattleInfo>().Find(x => x.PlotNpcID == plotNpcID);

                                    if (plotEmbattleInfo != null)
                                    {
                                        var monsterInfo = new ShareCacheStruct <MonsterInfo>().FindKey(plotEmbattleInfo.MonsterID);
                                        if (monsterInfo != null)
                                        {
                                            var itemMonster = new ShareCacheStruct <ItemBaseInfo>().FindKey(monsterInfo.ItemID);
                                            HeadID          = itemMonster.HeadID;

                                            content += string.Format(LanguageManager.GetLang().St_MonsterCard, itemMonster.ItemName,
                                                                     prizeInfo.Num) + ",";
                                            UserItemHelper.AddUserItem(user.UserID, monsterInfo.ItemID, prizeInfo.Num, prizeInfo.UserLv);
                                        }
                                    }
                                }
                            }
                            #region 注释
                            //else
                            //{
                            //    // 副本没有通关默认奖励为第一种金币奖励
                            //    HeadID = prize.HeadID;
                            //    int coinNumber = prize.Num;  // 第一条记录中金币数
                            //    // 获取当前玩家等级
                            //    if (user.UserLv >= 1 && user.UserLv <= 100)
                            //    {
                            //        coinNumber = coinNumber * user.UserLv;
                            //    }

                            //    else if (user.UserLv < 1)
                            //    {
                            //        coinNumber = coinNumber * 1;
                            //    }
                            //    else
                            //    {
                            //        coinNumber = coinNumber * 100;
                            //    }
                            //    content += string.Format(LanguageManager.GetLang().St_GameCoin, coinNumber) + ",";
                            //    user.GameCoin = MathUtils.Addition(user.GameCoin, coinNumber);
                            //}
                            #endregion
                        }

                        break;

                    case RewardType.GeneralSoul:
                        var generalInfoList = new ShareCacheStruct <GeneralInfo>().FindAll(x => x.GeneralQuality == prizeInfo.GeneralQuality);
                        if (generalInfoList != null)
                        {
                            if (generalInfoList.Count > 0)
                            {
                                int index = RandomUtils.GetRandom(0, generalInfoList.Count);
                                GeneralInfo generalInfo = generalInfoList[index];
                                HeadID   = generalInfo.HeadID;
                                quality  = generalInfo.GeneralQuality.ToInt();
                                content += string.Format(LanguageManager.GetLang().St_GeneralSoul,
                                                         generalInfo.GeneralName, prizeInfo.Num) + ",";
                                UserItemHelper.AddGeneralSoul(user.UserID, generalInfo.SoulID, prizeInfo.Num);
                            }
                        }
                        break;

                    case RewardType.Ability:
                        // 查找绿色技能列表
                        var abilityInfoList = new ShareCacheStruct <AbilityInfo>().FindAll(x => x.AbilityQuality == prizeInfo.AbilityQuality);
                        if (abilityInfoList != null)
                        {
                            if (abilityInfoList.Count > 0)
                            {
                                int index = RandomUtils.GetRandom(0, abilityInfoList.Count);
                                AbilityInfo abilityInfo = abilityInfoList[index];
                                HeadID   = abilityInfo.HeadID;
                                quality  = abilityInfo.AbilityQuality;
                                content += string.Format(LanguageManager.GetLang().St_Ability, abilityInfo.AbilityName, prizeInfo.Num) + ",";
                                UserAbilityHelper.AddUserAbility(abilityInfo.AbilityID, Convert.ToInt32(user.UserID), 0, 0);
                            }
                        }
                        break;
                    }
                }
                // 状态值为1时下发图片
                if (status == 1)
                {
                    #region  如果奖励为空,则默认奖励金币

                    string[] rewardInfo = content.TrimEnd(',').Split('*');
                    if (String.IsNullOrEmpty(rewardInfo[0]))
                    {
                        // 默认奖励为第一种金币奖励
                        HeadID         = prize.HeadID;
                        int coinNumber = prize.Num;  // 第一条记录中金币数
                        // 获取当前玩家等级
                        if (user.UserLv >= 1 && user.UserLv <= 100)
                        {
                            coinNumber = coinNumber * user.UserLv;
                        }

                        else if (user.UserLv < 1)
                        {
                            coinNumber = coinNumber * 1;
                        }
                        else
                        {
                            coinNumber = coinNumber * 100;
                        }
                        content      += string.Format(LanguageManager.GetLang().St_GameCoin, coinNumber) + ",";
                        user.GameCoin = MathUtils.Addition(user.GameCoin, coinNumber);
                    }

                    #endregion
                    content = content.TrimEnd(',') + "*" + HeadID + "*" + quality + ",";
                }
            });
            content = content.TrimEnd(',');

            return(content);
        }
示例#9
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 ShareCacheStruct <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 ShareCacheStruct <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);
        }