Esempio n. 1
0
        /// <summary>
        /// 副本奖励,如果通关下发通关奖励
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="plotNpcInfo"></param>
        /// <param name="userPlotCombat"></param>
        internal static void DoPlotPrize(string userID, PlotNPCInfo plotNpcInfo, UserPlotCombat userPlotCombat, int npcGeneralNum, out int honourNum)
        {
            honourNum = 0;
            int experience = 0;
            PlotInfo plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(plotNpcInfo.PlotID);
            var package = UserPlotPackage.Get(userID);
            if (plotInfo == null || plotNpcInfo == null || userPlotCombat == null || package == null)
            {
                return;
            }

            GameUser user = new GameDataCacheSet<GameUser>().FindKey(userID);

            if (user != null)
            {

                experience += plotNpcInfo.Experience;
                userPlotCombat.Experience = plotNpcInfo.Experience;
                if (!string.IsNullOrEmpty(user.MercenariesID))
                {
                    //公会技能加成
                    userPlotCombat.Experience = MathUtils.RoundCustom(experience * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.Experience)).ToInt();
                    experience = userPlotCombat.Experience;
                }
                var cacheSetGeneral = new GameDataCacheSet<UserGeneral>();
                var userMagic = new GameDataCacheSet<UserMagic>().Find(user.UserID, s => s.IsEnabled);
                int userMagicID = userMagic == null ? 0 : userMagic.MagicID;
                var userEmbattleList = new GameDataCacheSet<UserEmbattle>().FindAll(userID, s => s.MagicID == userMagicID && s.GeneralID > 0);
                int generalNum = 0;
                userEmbattleList.ForEach(userEmbattle =>
                {
                    var userGeneral = cacheSetGeneral.FindKey(userID, userEmbattle.GeneralID);
                    generalNum = userGeneral != null && userGeneral.LifeNum > 0
                                     ? MathUtils.Addition(generalNum, 1)
                                     : generalNum;
                });
                user.GeneralAllCount = MathUtils.Addition(user.GeneralAllCount, userPlotCombat.GeneralNum);
                user.GeneralKillCount = MathUtils.Addition(user.GeneralKillCount,
                                                           (userPlotCombat.GeneralNum - generalNum));
                //怪物掉落物品)
                if (plotNpcInfo.IsBoss)
                {

                    if (plotInfo.PlotType == PlotType.Normal && user.PlotProgress < plotInfo.PlotID)
                    {
                        user.PlotProgress = plotInfo.PlotID;
                    }

                    //日常任务-通关副本
                    TaskHelper.TriggerDailyTask(userID, 4005);

                    DateTime currDate = DateTime.Now;
                    //通关奖励

                    var userPlot = UserPlotHelper.GetUserPlotInfo(userID, plotNpcInfo.PlotID);
                    if (userPlot == null)
                    {
                        userPlot = new UserPlotInfo();
                        userPlot.PlotID = plotNpcInfo.PlotID;
                        userPlot.CreateDate = currDate;
                        package.SaveItem(userPlot);
                    }

                    NoviceHelper.PlotFestivalList(user, plotInfo.PlotID); //活动集合
                    List<UserPlotCombat> preUserPlotList = new GameDataCacheSet<UserPlotCombat>().FindAll(userID, m => !m.PlotNpcID.Equals(userPlotCombat.PlotNpcID) && m.PlotID == plotNpcInfo.PlotID);
                    preUserPlotList.Add(userPlotCombat);
                    List<UserPlotCombat> plotCombatList = preUserPlotList;
                    short starScore;
                    PlotSuccessType plotSuccessType = PlotSuccessType.No;
                    userPlot.ScoreNum = GetPlotScoreNum(plotCombatList, out starScore);

                    userPlot.PlotStatus = PlotStatus.Completed;
                    userPlot.AttackScore = 0;
                    userPlot.DefenseScore = 0;
                    userPlot.ItemID = 0;
                    userPlot.EnchantID = 0;

                    userPlot.PlotSuccessType = plotSuccessType;
                    //获得星星等级
                    if (userPlotCombat.IsWin)
                    {
                        double pren = 0;
                        GetStar(user, generalNum, out starScore, out plotSuccessType, out  pren);
                        userPlot.StarScore = starScore;
                        userPlot.PlotSuccessType = plotSuccessType;
                        //获得荣誉值
                        honourNum = plotInfo.HonourNum;

                        userPlot.PlotNum = MathUtils.Addition(userPlot.PlotNum, 1);
                        if (GetPlotChallengeNum(userID, plotNpcInfo.PlotID) == 1)
                        {
                            if (starScore >= 3)
                            {
                                if (plotInfo.PlotType==PlotType.Elite)  // 如果是精英副本
                                {
                                    if (userPlot.FirstWin==false)  // 如果是首次获得3星
                                    {
                                        userPlot.FirstWin = true;
                                        userPlot.ExpNum = (int)(plotInfo.ExpNum * 2);
                                        userPlot.PennyNum = (int)(plotInfo.GameCoin * 2);
                                    }
                                    else
                                    {
                                        userPlot.ExpNum = plotInfo.ExpNum;
                                        userPlot.PennyNum = plotInfo.GameCoin;
                                    }
                                }
                                else
                                {
                                    userPlot.ExpNum = (int)(plotInfo.ExpNum * 2);
                                    userPlot.PennyNum = (int)(plotInfo.GameCoin * 2);
                                }
                            }
                            else
                            {
                                userPlot.ExpNum = plotInfo.ExpNum;
                                userPlot.PennyNum = plotInfo.GameCoin;
                            }
                            honourNum = honourNum * starScore;
                        }
                        else
                        {
                            userPlot.ExpNum = plotInfo.ExpNum;
                            userPlot.PennyNum = plotInfo.GameCoin;
                        }
                        userPlot.HonourNum = honourNum;
                        GeneralEscalateHelper.AddUserLv(user, honourNum);
                    }
                    else
                    {
                        PlotFailureType plotFailureType;
                        GetFailure(npcGeneralNum, out plotFailureType);
                        userPlot.PlotFailureType = plotFailureType;

                    }

                    // userPlot.ExpNum = plotInfo.ExpNum;
                    userPlot.GoldNum = plotInfo.GetRandomGold();
                    if (!string.IsNullOrEmpty(user.MercenariesID))
                    {
                        //公会技能加成
                        userPlot.Experience = MathUtils.RoundCustom(userPlot.Experience * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.Experience)).ToInt();
                        userPlot.ExpNum = MathUtils.RoundCustom(userPlot.ExpNum * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.ExpNum)).ToInt();
                        userPlot.PennyNum = MathUtils.RoundCustom(userPlot.PennyNum * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.CoinNum)).ToInt();
                    }
                    CacheList<PrizeItemInfo> itemList = new CacheList<PrizeItemInfo>();
                    string itemName = string.Empty;
                    if (plotInfo.PlotType != PlotType.Kalpa)
                    {
                        var copyList = GetPrizeItems(userID, plotInfo.ItemProbability, plotInfo.ItemRank, plotInfo.PlotID, userPlot);
                        copyList.Foreach(item =>
                        {
                            if (item.Type == 0)
                            {
                                itemList.Add(item);
                            }
                            return true;
                        });

                        if (itemList.Count > 0)
                        {
                            userPlot.ItemID = itemList[0].ItemID;
                            var item = new ConfigCacheSet<ItemBaseInfo>().FindKey(userPlot.ItemID);
                            itemName = item != null ? item.ItemName : string.Empty;
                        }
                    }
                    if (!string.IsNullOrEmpty(plotInfo.EnchantID) && plotInfo.EnchantProbability > 0)
                    {
                        var copyList = GetKalpaPrizeItems(userID, plotInfo.ItemProbability, plotInfo.ItemRank, plotInfo.PlotID, userPlot);
                        copyList.Foreach(item =>
                        {
                            if (item.Type == 2)
                            {
                                itemList.Add(item);
                                if (plotInfo.PlotType != PlotType.Kalpa)
                                {
                                    userPlot.EnchantID = item.ItemID;
                                    EnchantAddUser(user, item.ItemID);
                                }
                            }
                            return true;
                        });

                    }

                    if (plotInfo.PlotType == PlotType.Elite)
                    {
                        //精英副本奖励发聊天<label color='0,255,0' >{0}</label><label>{0}</label>
                        string content = string.Format(LanguageManager.GetLang().St_PlotRewardNotice, user.NickName, plotNpcInfo.NpcName,
                           itemName);
                        new TjxChatService().SystemSend(ChatType.World, content);
                    }
                    //祝福加金币
                    if (UserHelper.GainBlessing(user, 0) > 0)
                    {
                        UserHelper.GainBlessing(user, 1);
                        userPlot.BlessPennyNum = (int)Math.Floor(userPlot.PennyNum * new GuildMember().BlessingCionPercent);
                        userPlot.PennyNum = MathUtils.Addition(userPlot.PennyNum, userPlot.BlessPennyNum);
                        user.GameCoin = MathUtils.Addition(user.GameCoin, userPlot.PennyNum, int.MaxValue);
                    }

                    if (userPlot.CompleteDate <= MathUtils.SqlMinDate)
                    {
                        userPlot.CompleteDate = currDate;
                    }
                    userPlot.RefleshDate = currDate;
                    //experience = userPlot.Experience;
                    //userPlotCombat.Experience = experience;
                    experience += userPlot.Experience + userPlot.BlessExperience;
                    user.GameCoin = MathUtils.Addition(user.GameCoin, userPlot.PennyNum, int.MaxValue);
                    user.ExpNum = MathUtils.Addition(user.ExpNum, userPlot.ExpNum, int.MaxValue);
                    user.ItemGold = MathUtils.Addition(user.ItemGold, userPlot.GoldNum, int.MaxValue);
                    //user.Update();

                    //奖励日志
                    UserPlotPrizeLog prizeLog = new UserPlotPrizeLog
                    {
                        PrizeLogID = Guid.NewGuid().ToString(),
                        ScoreNum = userPlot.ScoreNum,
                        StarScore = userPlot.StarScore,
                        PrizeItem = itemList,
                        Experience = userPlot.Experience,
                        ExpNum = userPlot.ExpNum,
                        GameCoin = userPlot.PennyNum,
                        PlotID = userPlot.PlotID,
                        UserID = userID,
                        CreateDate = DateTime.Now
                    };
                    var sender = DataSyncManager.GetDataSender();
                    sender.Send(prizeLog);
                    //重置评价
                    foreach (UserPlotCombat plotCombat in plotCombatList)
                    {
                        //只有一个NPC时更新不了
                        //if (plotCombatList.Count > 1 && plotCombat.Equals(userPlotCombat)) continue;

                        plotCombat.GeneralNum = 0;
                        plotCombat.GeneralOverNum = 0;
                        plotCombat.OverNum = 0;
                        //plotCombat.Update();

                    }
                    //通关副本 副本ID清空
                    if (user.UserExtend != null)
                    {
                        user.UserExtend.UpdateNotify(obj =>
                        {
                            user.UserExtend.PlotStatusID = 0;
                            user.UserExtend.PlotNpcID = 0;
                            user.UserExtend.MercenarySeq = 0;
                            return true;
                        });
                    }
                    package.SaveItem(userPlot);
                    user.GeneralAllCount = 0;
                    user.GeneralKillCount = 0;
                    if (plotInfo.PlotType == PlotType.Normal)
                    {
                        int multiple = FestivalHelper.DuplicateDropDouble(user.UserID);
                        if (multiple > 1)
                        {
                            FestivalHelper.DuplicateDropDoubleRestrain(user.UserID);
                        }
                    }
                }

                //佣兵经验
                AddExprerience(user, experience);

            }
        }
Esempio n. 2
0
 /// <summary>
 /// 天地劫获取灵件
 /// </summary>
 /// <param name="userInfo"></param>
 /// <param name="itemList"></param>
 /// <param name="npcInfo"></param>
 /// <param name="chatService"></param>
 private static void GetKalpaplotSparePart(GameUser userInfo, CacheList<PrizeItemInfo> itemList, PlotNPCInfo npcInfo, TjxChatService chatService)
 {
     if (npcInfo != null && RandomUtils.IsHit(npcInfo.SparePartProbability))
     {
         SparePartInfo partInfo = new ConfigCacheSet<SparePartInfo>().FindKey(npcInfo.SparePartID);
         if (partInfo != null && SparePartInfo.IsExist(npcInfo.SparePartID))
         {
             UserSparePart sparePart = UserSparePart.GetRandom(npcInfo.SparePartID);
             if (sparePart != null)
             {
                 PrizeItemInfo itemInfo = itemList.Find(m => m.ItemID == npcInfo.SparePartID);
                 if (itemInfo == null)
                 {
                     itemInfo = new PrizeItemInfo
                     {
                         Type = 1,
                         ItemID = npcInfo.SparePartID,
                         Num = 1
                     };
                     itemList.Add(itemInfo);
                 }
                 else
                 {
                     itemInfo.Num += 1;
                 }
                 if (UserHelper.AddSparePart(userInfo, sparePart))
                 {
                     //userInfo.Update();
                 }
                 else
                 {
                     //掉落灵件
                     chatService.SystemSendWhisper(userInfo, string.Format(LanguageManager.GetLang().St4303_SparePartFalling, partInfo.Name));
                 }
             }
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 天地劫挑战次数
        /// </summary>
        /// <param name="plotNPCInfo"></param>
        private void KalpaDailyRestrain(PlotNPCInfo plotNPCInfo)
        {
            UserDailyRestrain userRestrain = new PersonalCacheStruct<UserDailyRestrain>().FindKey(Uid);
            if (userRestrain == null)
            {
                userRestrain = new UserDailyRestrain() { UserID = Uid, FunPlot = new CacheList<FunPlot>() };
            }
            if (userRestrain.UserExtend == null)
            {
                userRestrain.UserExtend = new DailyUserExtend();
                userRestrain.UserExtend.KalpaPlot = new CacheList<FunPlot>();
            }
            int plotNum = 0;
            FunPlot funPlot = userRestrain.UserExtend.KalpaPlot.Find(m => m.PlotID == plotNPCInfo.PlotID);
            if (funPlot == null)
            {
                plotNum = 1;
            }
            else
            {
                plotNum = MathUtils.Addition(funPlot.Num, 1, int.MaxValue);
                userRestrain.UserExtend.UpdateNotify(obj =>
                    {
                        userRestrain.UserExtend.KalpaPlot.Remove(funPlot);
                        return true;
                    });
            }
            funPlot = new FunPlot
            {
                PlotID = plotNPCInfo.PlotID,
                Num = plotNum
            };
            userRestrain.UserExtend.UpdateNotify(obj =>
                {
                    userRestrain.UserExtend.KalpaPlot.Add(funPlot);
                    return true;
                });

        }
Esempio n. 4
0
        /// <summary>
        /// 精英副本挑战次数
        /// </summary>
        /// <param name="plotNPCInfo"></param>
        private void EliteDailyRestrain(PlotNPCInfo plotNPCInfo)
        {
            UserDailyRestrain userRestrain = new PersonalCacheStruct<UserDailyRestrain>().FindKey(Uid);
            if (userRestrain == null)
            {
                userRestrain = new UserDailyRestrain() { UserID = Uid, FunPlot = new CacheList<FunPlot>() };
            }

            int plotNum = 0;
            FunPlot funPlot = null;
            if (userRestrain.FunPlot.Count > 0)
            {
                funPlot = userRestrain.FunPlot.Find(m => m.PlotID == plotNPCInfo.PlotID);
            }
            if (funPlot == null)
            {
                plotNum = 1;
            }
            else
            {
                plotNum = MathUtils.Addition(funPlot.Num, 1, int.MaxValue);
                userRestrain.FunPlot.Remove(funPlot);
            }
            funPlot = new FunPlot
                          {
                              PlotID = plotNPCInfo.PlotID,
                              Num = plotNum
                          };
            userRestrain.FunPlot.Add(funPlot);

        }
Esempio n. 5
0
        /// <summary>
        /// 天地劫挑战次数
        /// </summary>
        /// <param name="plotNPCInfo"></param>
        private void KalpaDailyRestrain(PlotNPCInfo plotNPCInfo)
        {
            var cacheSet = new GameDataCacheSet<UserDailyRestrain>();
            UserDailyRestrain userRestrain = cacheSet.FindKey(Uid);
            if (userRestrain == null)
            {
                userRestrain = new UserDailyRestrain() { UserID = Uid };
                cacheSet.Add(userRestrain);
                userRestrain = cacheSet.FindKey(Uid);
            }
            if (userRestrain.UserExtend == null)
            {
                userRestrain.UserExtend = new DailyUserExtend();
                //userRestrain.UserExtend.KalpaPlot = new List<FunPlot>();
            }
            int plotNum = 0;
            FunPlot funPlot = userRestrain.UserExtend.KalpaPlot.Find(m => m.PlotID == plotNPCInfo.PlotID);
            if (funPlot == null)
            {
                plotNum = 1;
                funPlot = new FunPlot
                {
                    PlotID = plotNPCInfo.PlotID,
                    Num = plotNum
                };
                userRestrain.UserExtend.UpdateNotify(obj =>
                    {
                        userRestrain.UserExtend.KalpaPlot.Add(funPlot);
                        return true;
                    });

            }
        }
Esempio n. 6
0
 private bool IsPlotOut(PlotNPCInfo npcInfo)
 {
     if (npcInfo == null) return true;
     var userPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, npcInfo.PlotID);
     if (userPlot != null && UserHelper.IsKill(ContextUser, userPlot.PlotID))
     {
         int layerNum = ContextUser.UserExtend.LayerNum;
         int nextLayerNum = MathUtils.Addition(layerNum, 1);
         if (new ConfigCacheSet<PlotInfo>().FindAll(m => m.LayerNum == nextLayerNum && m.PlotType == PlotType.Kalpa).Count == 0)
         {
             int nextHurdleNum = MathUtils.Addition(ContextUser.UserExtend.HurdleNum, 1);
             //是否有下一关
             return new ConfigCacheSet<PlotInfo>().FindAll(m => m.LayerNum == layerNum && m.PlotSeqNo == nextHurdleNum && m.PlotType == PlotType.Kalpa).Count == 0;
         }
     }
     return false;
 }