Пример #1
0
        /// <summary>
        /// 竞技场公告
        /// </summary>
        public static void SprostSystemChat(UserRank rank, UserRank toRank)
        {
            if (rank == null || toRank == null)
            {
                return;
            }
            int topId = rank.RankId;
            int totopID = toRank.RankId;
            int winNum = 0;
            int winMaxNum = 0;
            string content = string.Empty;
            string winMaxUserID = string.Empty;
            var chatService = new TjxChatService();
            if (topId == 1 && topId > totopID)
            {
                content = string.Format(LanguageManager.GetLang().St5107_JingJiChangOneRank, rank.NickName, toRank.NickName);
                chatService.SystemSend(ChatType.World, content);
            }
            GameUser gameUser = UserCacheGlobal.LoadOffline(rank.UserID);
            if (gameUser != null)
            {
                IList<SportsCombat> userSportsCombats = gameUser.GetSportsCombat();

                if (userSportsCombats.Count > 0)
                {
                    if (totopID == 1 && userSportsCombats[userSportsCombats.Count - 1].IsWin)
                    {
                        content = string.Format(LanguageManager.GetLang().St5107_JingJiChangOneRank, toRank.NickName,
                                                rank.NickName);
                        chatService.SystemSend(ChatType.World, content);
                    }
                    winNum = userSportsCombats[userSportsCombats.Count - 1].WinNum;
                }
                //连胜第一名
                winMaxUserID = ServerEnvSet.Get(ServerEnvKey.SportFirstUser, "");
                winMaxNum = ServerEnvSet.Get(ServerEnvKey.SportFirstWinNum, 0).ToInt();

                Ranking<UserRank> ranking = RankingFactory.Get<UserRank>(CombatRanking.RankingKey);
                UserRank rankInfo = ranking.Find(s => s.UserID == winMaxUserID);
                //打破全服最高连胜的发通知
                if (winNum > winMaxNum)
                {
                    ServerEnvSet.Set(ServerEnvKey.SportFirstUser, rank.UserID);
                    ServerEnvSet.Set(ServerEnvKey.SportFirstWinNum, winNum);
                    if (rankInfo != null && rank.UserID != winMaxUserID && !string.IsNullOrEmpty(winMaxUserID))
                    {
                        content = string.Format(LanguageManager.GetLang().St5107_ZuiGaoLianSha, rank.NickName,
                                                rankInfo.NickName);
                        chatService.SystemSend(ChatType.World, content);
                    }
                    else if (winMaxNum > 5)
                    {
                        content = string.Format(LanguageManager.GetLang().St5107_JingJiChangWinNum, rank.NickName,
                                                winNum);
                        chatService.SystemSend(ChatType.World, content);
                    }
                }
                //int upRankID = MathUtils.Subtraction(totopID, topId, 0);
                //if (upRankID > 20)
                //{
                //    UserRank urankInfo = ranking.Find(s => s.UserID == rank.UserID);
                //    if (urankInfo != null && !string.IsNullOrEmpty(urankInfo.UserID))
                //    {
                //        content = string.Format(LanguageManager.GetLang().St5107_JingJiChangMoreNum, rank.NickName,
                //                                upRankID);
                //        chatService.SystemSend(ChatType.World, content);
                //    }
                //}
            }
        }
Пример #2
0
        /// <summary>
        /// 奖励物品
        /// </summary>
        /// <param name="prize"></param>
        /// <returns></returns>
        public static void ChestGainTreasureInfo(GameUser user, DialInfo dialInfo, int count)
        {
            var treasure = new TreasureInfo();
            treasure.UserID = user.UserID;
            treasure.Type = dialInfo.RewardType;
            treasure.ItemID = dialInfo.ItemID;
            treasure.Num = dialInfo.ItemNum;
            treasure.ItemLv = 1;
            UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(user.UserID);
            if (userDial == null)
            {
                userDial = new UserDial();
            }
            userDial.GroupID = 0;
            userDial.RefreshDate = DateTime.Now;
            userDial.Treasure.Add(treasure);
            if (count == 0)
            {
                userDial.PrizeInfo = treasure;
                userDial.HeadID = dialInfo.HeadID;
            }
            if (GameConfigSet.Treasure > 0 && userDial.Treasure.Count > GameConfigSet.Treasure)
            {
                for (int i = 0; i < userDial.Treasure.Count - GameConfigSet.Treasure; i++)
                {
                    userDial.Treasure.Remove(userDial.Treasure[i]);
                }
            }

            if (dialInfo.IsShow)
            {
                var cacheSet = new ShareCacheStruct<ServerEnvSet>();
                var serverEnvSet = cacheSet.FindKey(ServerEnvKey.UserTreasure);
                if (serverEnvSet == null)
                {
                    serverEnvSet = new ServerEnvSet();
                    serverEnvSet.EnvKey = ServerEnvKey.UserTreasure;
                    cacheSet.Add(serverEnvSet, GameEnvironment.CacheGlobalPeriod);
                }
                var treasureInfoList = ServerEnvSetTreasure(treasure);
                serverEnvSet.EnvValue = JsonUtils.Serialize(treasureInfoList);
            }

            if (dialInfo.IsBroadcast && !string.IsNullOrEmpty(dialInfo.BroadContent))
            {
                TjxChatService chatService = new TjxChatService();
                chatService.SystemSend(ChatType.World, string.Format(dialInfo.BroadContent, user.NickName));

            }
            if (dialInfo.RewardType == RewardType.Again || dialInfo.RewardType == RewardType.Mood || dialInfo.RewardType == RewardType.Recharge)
            {
                if (dialInfo.RewardType == RewardType.Recharge)
                {
                    userDial.ReturnRatio = treasure.Num;
                }
                return;
            }
            ChestGetUserTake(treasure, user);
        }
Пример #3
0
        public override bool TakeAction()
        {
            UserHelper.GetUserLightOpen(ContextUser.UserID);
            short opType = 0;
            int huntingID2 = 0;
            if (huntingID < 1005)
            {
                huntingID2 = MathUtils.Addition(huntingID, 1, int.MaxValue);
            }
            else
            {
                huntingID2 = 1001; //huntingID;
            }
            UserHelper.ChechDailyRestrain(ContextUser.UserID);

            if (!CrystalHelper.CheckAllowCrystall(ContextUser))
            {
                ErrorCode = 1000;
                ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull;
                return false;
            }
            else
            {
                if (!CrystalHelper.CheckAllowCrystall(ContextUser))
                {
                    ErrorCode = errorNum;
                    ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull;
                    return false;
                }
            }

            ProbabilityInfo probabilityInfo = null;
            if (ops == 1)
            {
                #region
                opType = 1;
                UserDailyRestrain userRestrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(ContextUser.UserID);
                probabilityInfo = new ConfigCacheSet<ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率
                if (probabilityInfo == null)
                {
                    return false;
                }
                ProbabilityInfo probability1 = new ConfigCacheSet<ProbabilityInfo>().FindKey(huntingID2);
                if (userRestrain != null && userRestrain.Funtion2 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date)
                {
                    if (probabilityInfo.Price > ContextUser.GameCoin)
                    {
                        ErrorCode = errorNum;
                        ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                        return false;
                    }
                }
                //暑期第三弹
                if (huntingID2 == 1001 && !NoviceHelper.IsGianCrystalPack(ContextUser))
                {
                    ErrorCode = errorNum;
                    ErrorInfo = LanguageManager.GetLang().St1305_BeiBaoBackpackFull;
                    return false;
                }
                var lightCacheSet = new GameDataCacheSet<UserLight>();
                if (huntingID != 1001)
                {
                    UserLight userLight1 = lightCacheSet.FindKey(ContextUser.UserID, huntingID);
                    if (userLight1.IsLight == 2)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        return false;
                    }

                    if (userLight1.IsLight == 1)
                    {
                        userLight1.IsLight = 2;
                        //userLight1.Update();
                    }
                }
                UserLight userLight = new GameDataCacheSet<UserLight>().FindKey(ContextUser.UserID, huntingID2);
                if (RandomUtils.IsHit(probability1.Light))
                {
                    ErrorCode = ErrorCode;
                    ErrorInfo = probability1.HuntingName;

                    if (userLight != null)
                    {
                        userLight.IsLight = 1;
                        //userLight.Update();
                    }
                    else
                    {
                        userLight = new UserLight()
                        {
                            UserID = ContextUser.UserID,
                            HuntingID = huntingID2,
                            IsLight = 1
                        };
                        lightCacheSet.Add(userLight);
                    }
                }

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

                lightArray = new GameDataCacheSet<UserLight>().FindAll(ContextUser.UserID);
                #endregion
            }
            else if (ops == 2)
            {
                #region
                opType = 2;
                if (ContextUser.VipLv < 5)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_VipNotEnough;
                    return false;
                }

                probabilityInfo = new ConfigCacheSet<ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率
                if (probabilityInfo == null)
                {
                    return false;
                }

                if (ContextUser.GoldNum < probabilityInfo.Price)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return false;
                }
                UserLight uLightInfo = new GameDataCacheSet<UserLight>().FindKey(ContextUser.UserID, probabilityInfo.GoldHunting);
                if (uLightInfo != null && uLightInfo.IsLight == 1)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1305_HuntingIDLight;
                    return false;
                }
                else if (uLightInfo != null && (uLightInfo.IsLight == 2 || uLightInfo.IsLight == 0))
                {
                    uLightInfo.IsLight = 1;
                }
                else
                {
                    uLightInfo = new UserLight()
                    {
                        UserID = ContextUser.UserID,
                        HuntingID = probabilityInfo.GoldHunting,
                        IsLight = 1
                    };
                    new GameDataCacheSet<UserLight>().Add(uLightInfo);
                }

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, probabilityInfo.Price, int.MaxValue);
                lightArray = new GameDataCacheSet<UserLight>().FindAll(ContextUser.UserID);
                #endregion
            }

            //每种品质的概率
            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 ConfigCacheSet<CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= ContextUser.UserLv);
            if (crystalArray2.Count > 0)
            {
                int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count);
                crystal = new ConfigCacheSet<CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID);
                if (crystal != null && crystal.CrystalQuality == CrystalQualityType.Gray)
                {
                    //wuzf修改 8-15 灰色放在临时背包不存DB
                    CrystalHelper.AppendGrayCrystal(ContextUser, crystal.CrystalID);
                }
                else if (crystal != null)
                {
                    var package = UserCrystalPackage.Get(Uid);

                    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(ContextUser.UserID, opType, crystal.CrystalID, probabilityInfo.Price, probabilityInfo.Price, null, 1, 0);
                    //高品质聊天通知);
                    if (crystal.CrystalQuality >= CrystalQualityType.Yellow)
                    {
                        var cacheChat = new TjxChatService();
                        string content = string.Format(LanguageManager.GetLang().St1305_HighQualityNotice,
                            ContextUser.NickName,
                           CrystalHelper.GetQualityName(crystal.CrystalQuality),
                            crystal.CrystalName
                            );
                        cacheChat.SystemSend(ChatType.World, content);
                    }
                }
            }

            //日常任务-猎命
            TaskHelper.TriggerDailyTask(Uid, 4009);
            return true;
        }
Пример #4
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 GameDataCacheSet<UserDailyRestrain>().FindKey(user.UserID);
            var probabilityInfo = new ConfigCacheSet<ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率
            if (probabilityInfo == null)
            {
                return errStr;
            }
            ProbabilityInfo probability1 = new ConfigCacheSet<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 GameDataCacheSet<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 GameDataCacheSet<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 ConfigCacheSet<CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= user.UserLv);
            if (crystalArray2.Count > 0)
            {
                int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count);
                var crystal = new ConfigCacheSet<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
        }
Пример #5
0
 /// <summary>
 /// 通关精英副本获得奖励
 /// </summary>
 /// <param name="user"></param>
 public static void ElitePlotFestivalList(GameUser user)
 {
     var festivalInfosArray = new ShareCacheStruct<FestivalInfo>().FindAll(m => m.FestivalType == FestivalType.EliteCount);
     var chatService = new TjxChatService();
     foreach (FestivalInfo info in festivalInfosArray)
     {
         if (IsFestivalOpen(info.FestivalID))
         {
             if (info.TaskConfig != null)
             {
                 FestivalRestrainNum(user.UserID, info.FestivalID);
                 int maxNum = 0;
                 var configInfos = info.TaskConfig;
                 foreach (TaskConfigInfo configInfo in configInfos)
                 {
                     maxNum = MathUtils.Addition(maxNum, 1);
                     var plotInfosArray = new ShareCacheStruct<PlotInfo>().FindAll(m => configInfo.CityID.IndexOf(m.CityID.ToString()) >= 0 && m.PlotType == configInfo.PlotType);
                     if (IsEliteClearance(user.UserID, info.FestivalID, plotInfosArray, maxNum))
                     {
                         ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(configInfo.item);
                         if (itemInfo != null)
                         {
                             UserItemHelper.AddUserItem(user.UserID, configInfo.item, configInfo.Num);
                             GetFestivalRestrain(info, user, maxNum, info.FestivalID);
                             chatService.SystemSend(ChatType.World, string.Format(configInfo.Desc, user.NickName, itemInfo.ItemName));
                         }
                     }
                 }
             }
         }
     }
 }
Пример #6
0
 /// <summary>
 /// 普通副本类型活动(获得遗失的月饼配方)
 /// </summary>
 /// <param name="user"></param>
 public static void NormalCountReceive(GameUser user)
 {
     int dailyNum = 0;
     var chatService = new TjxChatService();
     var festivalInfosArray = new ShareCacheStruct<FestivalInfo>().FindAll(m => m.FestivalType == FestivalType.NormalCount);
     foreach (FestivalInfo info in festivalInfosArray)
     {
         if (IsFestivalOpen(info.FestivalID))
         {
             FestivalRestrainNum(user.UserID, info.FestivalID);
             FestivalRestrain festivalRestrain = new PersonalCacheStruct<FestivalRestrain>().FindKey(user.UserID, info.FestivalID);
             if (festivalRestrain != null && festivalRestrain.RefreashDate.Date == DateTime.Now.Date)
             {
                 dailyNum = festivalRestrain.RestrainNum;
             }
             if (info.RestrainNum > dailyNum && info.TaskConfig != null)
             {
                 List<TaskConfigInfo> configInfos = info.TaskConfig.ToList();
                 foreach (TaskConfigInfo configInfo in configInfos)
                 {
                     if (RandomUtils.IsHit(configInfo.probability))
                     {
                         UserItemHelper.AddUserItem(user.UserID, configInfo.item, configInfo.Num);
                         if (info.FestivalExtend != null)
                         {
                             chatService.SystemSend(ChatType.World, string.Format(info.FestivalExtend.Desc, user.NickName));
                         }
                         if (festivalRestrain != null)
                         {
                             festivalRestrain.RestrainNum = MathUtils.Addition(festivalRestrain.RestrainNum, 1);
                             //festivalRestrain.Update();
                         }
                         else
                         {
                             var cacheSet = new PersonalCacheStruct<FestivalRestrain>();
                             festivalRestrain = new FestivalRestrain()
                             {
                                 FestivalID = info.FestivalID,
                                 UserID = user.UserID,
                                 RestrainNum = 1,
                                 RefreashDate = DateTime.Now
                             };
                             cacheSet.Add(festivalRestrain);
                         }
                     }
                 }
             }
         }
     }
 }
Пример #7
0
 /// <summary>
 /// 七夕节活动
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="plotID"></param>
 private static bool TanabataFestival(string userID, int plotID)
 {
     var chatService = new TjxChatService();
     GameUser userInfo = new PersonalCacheStruct<GameUser>().FindKey(userID);
     PlotInfo plotInfo = new ShareCacheStruct<PlotInfo>().FindKey(plotID);
     if (plotInfo != null)
     {
         if (RandomUtils.IsHit(plotInfo.FestivalProbability))
         {
             List<FestivalReward> rewardsArray = plotInfo.FestivalReward.ToList();
             double[] probability = new double[rewardsArray.Count];
             for (int i = 0; i < rewardsArray.Count; i++)
             {
                 probability[i] = rewardsArray[i].Probability;
             }
             int index2 = RandomUtils.GetHitIndex(probability);
             int itemID = rewardsArray[index2].Item;
             UserItemHelper.AddUserItem(userID, itemID, 1);
             ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(itemID);
             if (userInfo != null && itemInfo != null)
             {
                 string content = string.Empty;
                 if (itemID == 5023 || itemID == 5024)
                 {
                     content = string.Format(LanguageManager.GetLang().St_Tanabata, itemInfo.ItemName);
                     chatService.SystemSendWhisper(userInfo, content);
                     return true;
                 }
                 else if (itemID == 5022)
                 {
                     content = string.Format(LanguageManager.GetLang().St_UserNameTanabata, userInfo.NickName, itemInfo.ItemName);
                     chatService.SystemSend(ChatType.World, content);
                     return true;
                 }
             }
         }
     }
     return false;
 }
Пример #8
0
 /// <summary>
 /// 端午节通关获得物品
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="plotID"></param>
 public static void GetFestivalReward(string userID, int plotID)
 {
     int festivalID = 0;// 1001;
     var chatService = new TjxChatService();
     FestivalInfo festival = new ShareCacheStruct<FestivalInfo>().FindKey(festivalID);
     if (festival != null)
     {
         GameUser userInfo = new PersonalCacheStruct<GameUser>().FindKey(userID);
         PlotInfo plotInfo = new ShareCacheStruct<PlotInfo>().FindKey(plotID);
         if (plotInfo != null)
         {
             if (IsFestivalOpen(festivalID))
             {
                 if (RandomUtils.IsHit(plotInfo.FestivalProbability))
                 {
                     List<FestivalReward> rewardsArray = plotInfo.FestivalReward.ToList();
                     double[] probability = new double[rewardsArray.Count];
                     for (int i = 0; i < rewardsArray.Count; i++)
                     {
                         probability[i] = rewardsArray[i].Probability;
                     }
                     int index2 = RandomUtils.GetHitIndex(probability);
                     int itemID = rewardsArray[index2].Item;
                     UserItemHelper.AddUserItem(userID, itemID, 1);
                     ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(itemID);
                     if (userInfo != null && itemInfo != null)
                     {
                         string content = string.Empty;
                         if (itemID == 5005)
                         {
                             content = string.Format(LanguageManager.GetLang().St_DragonBoatPuTongZongzi, itemInfo.ItemName);
                             chatService.SystemSendWhisper(userInfo, content);
                         }
                         else if (itemID == 5006)
                         {
                             content = string.Format(LanguageManager.GetLang().St_DragonBoatPuTongZongzi, itemInfo.ItemName);
                             chatService.SystemSendWhisper(userInfo, content);
                         }
                         else if (itemID == 5007)
                         {
                             content = string.Format(LanguageManager.GetLang().St_DragonBoatZongzi, userInfo.NickName);
                             chatService.SystemSend(ChatType.World, content);
                         }
                     }
                 }
             }
         }
     }
 }
Пример #9
0
        /// <summary>
        /// 处理击杀奖励
        /// </summary>
        private void DoKillPrize(GameUser user)
        {
            BossActivePrize bossPrize = GameActive.BossPrize;
            if (bossPrize == null)
            {
                return;
            }
            TjxChatService chatService = new TjxChatService();

            var rankingList = RefreshRanking();
            ServerEnvSet.Set(ServerEnvKey.FirstHalfBoss, rankingList.ToJson());
            int length = rankingList.Count > bossPrize.TopObtain ? bossPrize.TopObtain : rankingList.Count;
            //处理排名奖励
            for (int i = 0; i < length; i++)
            {
                string prizeItemMsg = string.Empty;
                GameUser tempUser = new PersonalCacheStruct<GameUser>().FindKey(rankingList[i].UserId);
                tempUser.GameCoin = MathUtils.Addition(tempUser.GameCoin, bossPrize.TopObtainNum, int.MaxValue);
                //前3名奖励
                if (i == 0)
                {
                    DoTopThreePrize(i + 1, tempUser, bossPrize.Rank1, bossPrize.Items, out prizeItemMsg);
                }
                else if (i == 1)
                {
                    DoTopThreePrize(i + 1, tempUser, bossPrize.Rank2, bossPrize.Items, out prizeItemMsg);

                }
                else if (i == 2)
                {
                    DoTopThreePrize(i + 1, tempUser, bossPrize.Rank3, bossPrize.Items, out prizeItemMsg);
                }
                //tempUser.Update();

                if (!string.IsNullOrEmpty(prizeItemMsg)) prizeItemMsg = "," + prizeItemMsg;

                chatService.SystemSend(ChatType.World, string.Format(LanguageManager.GetLang().St5405_CombatRankmReward,
                    tempUser.NickName,
                    (i + 1),
                    bossPrize.TopObtainNum,
                    prizeItemMsg));
                TraceLog.ReleaseWriteDebug(string.Format(LanguageManager.GetLang().St5405_CombatRankmReward,
                    tempUser.NickName,
                    (i + 1),
                    bossPrize.TopObtainNum,
                    prizeItemMsg));
                // CountryCombat.Contribution(tempUser.UserID, bossPrize.TopObtainNum); //公会贡献
            }
        }