Esempio n. 1
0
 private short GetPlotStatus(UserPlotInfo userPlot, PlotType plotType)
 {
     if (userPlot != null)
     {
         if (plotType == PlotType.Normal)
         {
             var plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(userPlot.PlotID);
             if (plotInfo.PrePlotID > 0)
             {
                 var preUserPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, plotInfo.PrePlotID);
                 if (preUserPlot == null || preUserPlot.PlotStatus != PlotStatus.Completed)
                 {
                     return((short)PlotStatus.Locked);
                 }
             }
         }
         else
         {
             if (plotType == PlotType.Elite)
             {
                 var plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(userPlot.PlotID);
                 if (plotInfo.PrePlotID > 0 && plotInfo.JYPrePlotID > 0)
                 {
                     var preUserPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, plotInfo.JYPrePlotID);
                     if (preUserPlot == null || preUserPlot.PlotStatus != PlotStatus.Completed)
                     {
                         return((short)PlotStatus.Locked);
                     }
                 }
             }
         }
         return((short)userPlot.PlotStatus);
     }
     return((short)PlotStatus.Locked);
 }
Esempio n. 2
0
        protected override void ProcessCmd(string[] args)
        {
            int plotID = args.Length > 0 ? args[0].Trim().ToInt() : 0;

            var package = UserPlotPackage.Get(UserID);

            if (package == null)
            {
                return;
            }
            var userplotInfo = UserPlotHelper.GetUserPlotInfo(UserID, plotID);

            if (userplotInfo == null)
            {
                userplotInfo = new UserPlotInfo();

                userplotInfo.PlotID       = plotID;
                userplotInfo.PlotStatus   = PlotStatus.NoComplete;
                userplotInfo.CompleteDate = DateTime.Now;
                userplotInfo.CreateDate   = DateTime.Now;
            }
            else
            {
                userplotInfo.PlotStatus = PlotStatus.NoComplete;
            }
            package.SaveItem(userplotInfo);
        }
Esempio n. 3
0
        protected override void ProcessCmd(string[] args)
        {
            int plotID = args.Length > 0 ? args[0].Trim().ToInt() : 0;
            var package = UserPlotPackage.Get(UserID);
            if (package == null)
            {
                return;
            }
            var userplotInfo = UserPlotHelper.GetUserPlotInfo(UserID, plotID);
            if (userplotInfo == null)
            {
                userplotInfo = new UserPlotInfo();

                userplotInfo.PlotID = plotID;
                userplotInfo.PlotStatus = PlotStatus.Completed;
                userplotInfo.CompleteDate = DateTime.Now;
                userplotInfo.CreateDate = DateTime.Now;
            }
            else
            {
                userplotInfo.PlotStatus = PlotStatus.Completed;
                userplotInfo.CompleteDate = DateTime.Now;
            }
            package.SaveItem(userplotInfo);
        }
Esempio n. 4
0
        /// <summary>
        /// 获取一个副本
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="plotID"></param>
        /// <returns></returns>
        public static UserPlotInfo GetUserPlotInfo(string userID, int plotID)
        {
            UserPlotInfo userPlotInfo = null;
            var          package      = UserPlotPackage.Get(userID);

            if (package != null)
            {
                userPlotInfo = package.PlotPackage.Find(s => s.PlotID == plotID);
            }
            return(userPlotInfo);
        }
Esempio n. 5
0
        public override void BuildPacket()
        {
            var cacheSetItem = new ConfigCacheSet <ItemBaseInfo>();

            PushIntoStack(_cityInfoList.Count);
            foreach (var city in _cityInfoList)
            {
                List <PlotInfo> plotList = _cacheSetPlot.FindAll(s => s.CityID == city.CityID && s.PlotType == plotType);

                DataStruct dsItem = new DataStruct();
                dsItem.PushIntoStack(plotList.Count);
                foreach (PlotInfo item in plotList)
                {
                    UserPlotInfo userPlot   = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, item.PlotID);
                    int          isKill     = PlotHelper.IsKill(ContextUser.UserID, item.PlotID, cityID) ? 1 : 0;
                    DataStruct   dsItemPlot = new DataStruct();
                    dsItemPlot.PushIntoStack(item.PlotID);
                    dsItemPlot.PushIntoStack(item.PlotSeqNo.ToShort());
                    dsItemPlot.PushIntoStack(item.PlotName.ToNotNullString());
                    dsItemPlot.PushIntoStack(item.BossHeadID.ToNotNullString());
                    dsItemPlot.PushIntoStack(GetPlotStatus(userPlot, plotType));
                    dsItemPlot.PushIntoStack(userPlot == null ? 1 : (int)userPlot.StarScore);
                    dsItemPlot.PushIntoStack(isKill);
                    dsItemPlot.PushIntoStack(item.HonourNum);
                    dsItemPlot.PushIntoStack(item.GameCoin);
                    dsItemPlot.PushIntoStack(item.PlotDesc);
                    dsItemPlot.PushIntoStack(item.PlotLv);
                    dsItemPlot.PushIntoStack(ConfigEnvSet.GetInt("Plot.BattleEnergyNum"));
                    dsItemPlot.PushIntoStack(PlotHelper.GetPlotChallengeNum(UserId.ToString(), item.PlotID));
                    dsItemPlot.PushIntoStack(item.ChallengeNum);
                    dsItemPlot.PushIntoStack(userPlot == null ? 0 : userPlot.PlotNum);
                    dsItem.PushIntoStack(dsItemPlot);
                    var itemArray = item.ItemRank.Split(',');
                    dsItemPlot.PushIntoStack(itemArray.Length);
                    foreach (var s in itemArray)
                    {
                        var        sArray     = s.Split('=');
                        var        itemInfo   = cacheSetItem.FindKey(sArray.Length > 0 ? sArray[0].ToInt() : 0);
                        DataStruct dsItemInfo = new DataStruct();
                        dsItemInfo.PushIntoStack(itemInfo != null ? itemInfo.ItemName : string.Empty);
                        dsItemInfo.PushIntoStack(sArray.Length > 1 ? sArray[1].ToInt() : 0);
                        dsItemPlot.PushIntoStack(dsItemInfo);
                    }
                }

                dsItem.PushIntoStack(city.CityID);
                dsItem.PushIntoStack(city.CityName.ToNotNullString());

                PushIntoStack(dsItem);
            }
            PushIntoStack(resetNum);
            PushIntoStack(_backpackType);
        }
Esempio n. 6
0
 /// <summary>
 /// 副本是否开启
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="userPlot"></param>
 /// <returns></returns>
 public static short GetPlotStatus(string userID, UserPlotInfo userPlot)
 {
     if (userPlot != null)
     {
         PlotInfo plotInfo1 = new ShareCacheStruct<PlotInfo>().FindKey(userPlot.PlotID);
         if (plotInfo1 != null && plotInfo1.PrePlotID > 0)
         {
             UserPlotInfo preUserPlot = GetUserPlotInfo(userID, plotInfo1.PrePlotID);
             if (preUserPlot == null || preUserPlot.PlotStatus != PlotStatus.Completed)
             {
                 return (short)PlotStatus.Locked;
             }
         }
         return (short)userPlot.PlotStatus;
     }
     return (short)PlotStatus.Locked;
 }
Esempio n. 7
0
 /// <summary>
 /// 副本是否开启
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="userPlot"></param>
 /// <returns></returns>
 public static short GetPlotStatus(string userID, UserPlotInfo userPlot)
 {
     if (userPlot != null)
     {
         PlotInfo plotInfo1 = new ShareCacheStruct <PlotInfo>().FindKey(userPlot.PlotID);
         if (plotInfo1 != null && plotInfo1.PrePlotID > 0)
         {
             UserPlotInfo preUserPlot = GetUserPlotInfo(userID, plotInfo1.PrePlotID);
             if (preUserPlot == null || preUserPlot.PlotStatus != PlotStatus.Completed)
             {
                 return((short)PlotStatus.Locked);
             }
         }
         return((short)userPlot.PlotStatus);
     }
     return((short)PlotStatus.Locked);
 }
Esempio n. 8
0
        public static void EnablePlot(string userId, int plotId)
        {
            var packge = UserPlotPackage.Get(userId);
            if (packge == null)
            {
                return;
            }
            var userPlot = UserPlotHelper.GetUserPlotInfo(userId, plotId);

            if (userPlot == null)
            {
                userPlot = new UserPlotInfo();
                userPlot.PlotID = plotId;
                userPlot.PlotStatus = PlotStatus.NoComplete;
                userPlot.CompleteDate = DateTime.Now;
                packge.SaveItem(userPlot);
                if (userPlot.PlotType == PlotType.Kalpa)
                {
                    PlotInfo plotInfo = new ShareCacheStruct<PlotInfo>().FindKey(plotId);
                    GameUser userInfo = new PersonalCacheStruct<GameUser>().FindKey(userId);
                    if (plotInfo == null || userInfo == null)
                    {
                        return;
                    }
                    if (userInfo.UserExtend == null)
                    {
                        userInfo.UserExtend = new GameUserExtend();
                    }
                    userInfo.UserExtend.UpdateNotify(obj =>
                    {
                        userInfo.UserExtend.LayerNum = plotInfo.LayerNum;
                        userInfo.UserExtend.HurdleNum = plotInfo.PlotSeqNo;
                        return true;
                    });
                }
            }
        }
Esempio n. 9
0
        public void SaveItem(UserPlotInfo item)
        {
            if (item == null || item.PlotID == 0)
            {
                return;
            }
            var tempItem = PlotPackage.Find(s => s.PlotID == item.PlotID);

            if (tempItem == null)
            {
                PlotPackage.Add(item);
            }
            else
            {
                tempItem.UpdateNotify(obj =>
                {
                    tempItem.PlotID          = item.PlotID;
                    tempItem.PlotStatus      = item.PlotStatus;
                    tempItem.ScoreNum        = item.ScoreNum;
                    tempItem.AttackScore     = item.AttackScore;
                    tempItem.DefenseScore    = item.DefenseScore;
                    tempItem.StarScore       = item.StarScore;
                    tempItem.ExpNum          = item.ExpNum;
                    tempItem.Experience      = item.Experience;
                    tempItem.PennyNum        = item.PennyNum;
                    tempItem.GoldNum         = item.GoldNum;
                    tempItem.ItemID          = item.ItemID;
                    tempItem.CompleteDate    = item.CompleteDate;
                    tempItem.RefleshDate     = item.RefleshDate;
                    tempItem.CreateDate      = item.CreateDate;
                    tempItem.BlessPennyNum   = item.BlessPennyNum;
                    tempItem.BlessExperience = item.BlessExperience;
                    tempItem.EnchantID       = item.EnchantID;
                    return(true);
                });
            }
        }
Esempio n. 10
0
 /// <summary>
 /// 英雄副本开启
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="plotID"></param>
 public static void EnableHeroPlot(string userID, int plotID)
 {
     var packge = UserPlotPackage.Get(userID);
     if (packge == null)
     {
         return;
     }
     var userPlot = UserPlotHelper.GetUserPlotInfo(userID, plotID);
     if (userPlot != null)
     {
         PlotInfo[] plotInfoArray = new ConfigCacheSet<PlotInfo>().FindAll(m => m.PlotType == PlotType.HeroPlot && m.PrePlotID == plotID).ToArray();
         foreach (PlotInfo info in plotInfoArray)
         {
             var uplot = UserPlotHelper.GetUserPlotInfo(userID, info.PlotID);
             if (uplot == null)
             {
                 uplot = new UserPlotInfo();
                 uplot.PlotID = info.PlotID;
                 uplot.PlotStatus = PlotStatus.NoComplete;
                 uplot.CreateDate = DateTime.Now;
                 packge.SaveItem(uplot);
             }
         }
     }
 }
Esempio n. 11
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. 12
0
        /// <summary>
        /// 扫荡副本
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="itemProbability"></param>
        /// <param name="itemRank"></param>
        /// <returns></returns>
        private static CacheList<PrizeItemInfo> GetPrizeItems(string userID, decimal itemProbability, string itemRank, int plotID, UserPlotInfo userPlot)
        {
            List<UniversalInfo> universalInfoList = new List<UniversalInfo>();
            var itemList = new CacheList<PrizeItemInfo>();

            string[] items = itemRank.Trim().Split(new[] { ',' });
            int count = items.Length + 1;
            int[] precent = new int[count];
            int precentNum = 0;
            for (int i = 0; i < count; i++)
            {
                if (i != (count - 1))
                {
                    var itemInfo = items[i].Split('=');
                    decimal prize = itemInfo[2].ToDecimal();
                    precent[i] = (prize * 1000).ToInt();
                    precentNum = MathUtils.Addition(precentNum, precent[i]);
                }
                else
                {
                    precent[i] = (1000 - precentNum);
                }
            }

            int index = RandomUtils.GetHitIndexByTH(precent);
            if (index != (count - 1))
            {
                int itemId = 0;
                int num = 0;
                if (items.Length > 1)
                {

                    itemId = items[index].Split('=')[0].ToInt();
                    num = items[index].Split('=')[1].ToInt();
                }
                else
                {
                    itemId = items[0].Split('=')[0].ToInt();
                    num = items[0].Split('=')[1].ToInt();
                }

                var itemBase = new ConfigCacheSet<ItemBaseInfo>().FindKey(itemId);
                if (itemBase != null)
                {
                    PrizeItemInfo prizeItem = itemList.Find(m => m.ItemID == itemId);
                    if (prizeItem == null)
                    {
                        prizeItem = new PrizeItemInfo
                        {
                            Type = 0,
                            ItemID = itemId,
                            Num = num
                        };
                        itemList.Add(prizeItem);
                    }
                    else
                    {
                        prizeItem.Num += num;
                    }
                }

            }
            GameUser userInfo = new GameDataCacheSet<GameUser>().FindKey(userID);
            foreach (var itemInfo in itemList)
            {

                UserItemHelper.AddUserItem(userID, itemInfo.ItemID, itemInfo.Num, universalInfoList);
                if (userInfo != null)
                {
                    CacheList<PrizeItemInfo> prizeItemInfos = new CacheList<PrizeItemInfo>();
                    prizeItemInfos.Add(new PrizeItemInfo() { Type = 0, ItemID = itemInfo.ItemID, Num = itemInfo.Num });

                    if (prizeItemInfos.Count > 0)
                    {
                        userInfo.UserExtend.UpdateNotify(obj =>
                            {
                                userInfo.UserExtend.ItemList = prizeItemInfos;
                                return true;
                            });
                        //userInfo.Update();
                    }
                }
            }
            NoviceHelper.PlotFestivalList(userInfo, plotID); //活动集合

            if (universalInfoList.Count > 0)
            {
                foreach (var item in universalInfoList)
                {
                    if (userPlot.ItemList != null)
                    {
                        userPlot.ItemList.Add(item);
                    }
                }
            }
            return itemList;
        }
 public void SaveItem(UserPlotInfo item)
 {
     if (item == null || item.PlotID == 0) return;
     var tempItem = PlotPackage.Find(s => s.PlotID == item.PlotID);
     if (tempItem == null)
     {
         PlotPackage.Add(item);
     }
     else
     {
         tempItem.UpdateNotify(obj =>
         {
             tempItem.PlotID = item.PlotID;
             tempItem.PlotStatus = item.PlotStatus;
             tempItem.ScoreNum = item.ScoreNum;
             tempItem.AttackScore = item.AttackScore;
             tempItem.DefenseScore = item.DefenseScore;
             tempItem.StarScore = item.StarScore;
             tempItem.ExpNum = item.ExpNum;
             tempItem.Experience = item.Experience;
             tempItem.PennyNum = item.PennyNum;
             tempItem.GoldNum = item.GoldNum;
             tempItem.ItemID = item.ItemID;
             tempItem.CompleteDate = item.CompleteDate;
             tempItem.RefleshDate = item.RefleshDate;
             tempItem.CreateDate = item.CreateDate;
             tempItem.BlessPennyNum = item.BlessPennyNum;
             tempItem.BlessExperience = item.BlessExperience;
             tempItem.EnchantID = item.EnchantID;
             return true;
         });
     }
 }
Esempio n. 14
0
        /// <summary>
        /// 通關副本掉落物品
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="itemProbability"></param>
        /// <param name="itemRank"></param>
        /// <returns></returns>
        private static CacheList<PrizeItemInfo> GetKalpaPrizeItems(string userID, decimal itemProbability, string itemRank, int plotID, UserPlotInfo userPlot)
        {
            var itemList = new CacheList<PrizeItemInfo>();
            PlotInfo plotInfo = new ShareCacheStruct<PlotInfo>().FindKey(plotID);
            if (plotInfo == null)
            {
                return itemList;
            }

            string[] items = itemRank.Trim().Split(new[] { ',' });
            int count = items.Length + 1;
            int[] precent = new int[count];
            int precentNum = 0;
            for (int i = 0; i < count; i++)
            {
                if (i != (count - 1))
                {
                    var itemInfo = items[i].Split('=');
                    decimal prize = itemInfo[2].ToDecimal();
                    precent[i] = (prize * 1000).ToInt();
                    precentNum = MathUtils.Addition(precentNum, precent[i]);
                }
                else
                {
                    precent[i] = (1000 - precentNum);
                }
            }

            int index = RandomUtils.GetHitIndexByTH(precent);
            if (plotInfo.PlotType != PlotType.Kalpa && index != (count - 1))
            {
                if (items.Length == 0)
                {
                    return itemList;
                }
                string[] itemArray = items[index].Split('=');
                if (itemArray.Length == 2)
                {
                    int itemId = itemArray[0].ToInt();
                    if (new ShareCacheStruct<ItemBaseInfo>().FindKey(itemId) != null)
                    {
                        PrizeItemInfo itemInfo = itemList.Find(m => m.ItemID == itemId);
                        if (itemInfo == null)
                        {
                            itemInfo = new PrizeItemInfo
                                           {
                                               Type = 0,
                                               ItemID = itemId,
                                               Num = itemArray[1].ToInt()
                                           };
                            itemList.Add(itemInfo);
                        }
                        else
                        {
                            itemInfo.Num += itemArray[1].ToInt();
                        }
                    }
                }
            }
            List<UniversalInfo> universalInfoList = new List<UniversalInfo>();
            GameUser userInfo = new PersonalCacheStruct<GameUser>().FindKey(userID);
            foreach (var itemInfo in itemList)
            {
                UserItemHelper.AddUserItem(userID, itemInfo.ItemID, itemInfo.Num, universalInfoList);
                if (userInfo != null)
                {
                    CacheList<PrizeItemInfo> prizeItemInfos = new CacheList<PrizeItemInfo>();
                    prizeItemInfos.Add(new PrizeItemInfo() { Type = 0, ItemID = itemInfo.ItemID, Num = itemInfo.Num });

                    if (prizeItemInfos.Count > 0)
                    {
                        userInfo.UserExtend.UpdateNotify(obj =>
                        {
                            userInfo.UserExtend.ItemList = prizeItemInfos;
                            return true;
                        });
                        //userInfo.Update();
                    }
                }
            }

            if (universalInfoList.Count > 0 && userPlot != null)
            {
                universalInfoList.ForEach(universalInfo =>
                {
                    userPlot.ItemList.Add(universalInfo);
                });
            }
            NoviceHelper.PlotFestivalList(userInfo, plotID); //活动集合
            GetKalpaplotEnchant(userInfo, itemList, plotID); //副本掉落附魔符
            return itemList;
        }
Esempio n. 15
0
        public override bool TakeAction()
        {
            PlotInfo plotInfo = new ShareCacheStruct <PlotInfo>().FindKey(PlotID);

            if (plotInfo != null)
            {
                plotName = plotInfo.PlotName;
            }
            var cacheSetGeneralEscalate = new ShareCacheStruct <GeneralEscalateInfo>();

            GeneralEscalateHelper.AddUserLv(ContextUser, 0);
            int lv = ContextUser.UserLv;

            lv = lv < 0 ? 1 : lv + 1;
            var generalEscalate =
                cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == lv);

            if (generalEscalate != null)
            {
                maxHonourNum = generalEscalate.UpExperience;
            }
            var lastGeneralEscalate = cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == (lv - 1));

            if (lastGeneralEscalate != null)
            {
                lastMaxHonourNum = lastGeneralEscalate.UpExperience;
            }

            embattleList = new PersonalCacheStruct <UserEmbattle>().FindAll(ContextUser.UserID, m => m.MagicID == ContextUser.UseMagicID);
            embattleList.QuickSort((x, y) => x.GeneralID.CompareTo(y.GeneralID));
            List <UniversalInfo> universalList = new List <UniversalInfo>();

            userPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, PlotID);
            //var cacheSetPlotInfo = new ShareCacheStruct<PlotInfo>();
            //var cacheSetItem = new ShareCacheStruct<ItemBaseInfo>();
            //var plotInfo = cacheSetPlotInfo.FindKey(PlotID);

            if (userPlot != null && userPlot.ItemList.Count > 0)
            {
                universalList.AddRange(userPlot.ItemList);
                //if (plotInfo != null && userPlot.PlotStatus == PlotStatus.Completed && plotInfo.ItemRank != "" && plotInfo.ItemRank != null)
                //{
                //    var itemArray = plotInfo.ItemRank.Split(',');
                //    foreach (var s in itemArray)
                //    {
                //        int itemId = s.Split('=')[0].ToInt();
                //        var item = cacheSetItem.FindKey(itemId);
                //        if (item != null)
                //        {
                //            universalList.Add(new UniversalInfo() { Name = item.ItemName, HeadID = item.HeadID, Num = s.Split('=')[1].ToInt() });
                //        }
                //    }

                //}
                //if (userPlot.ItemID > 0)
                //{
                //    itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(userPlot.ItemID);
                //    if (itemInfo != null)
                //    {
                //        universalList.Add(new UniversalInfo() { Name = itemInfo.ItemName, HeadID = itemInfo.HeadID, Num = 1 });
                //    }
                //}
                //if (userPlot.EnchantID > 0)
                //{
                //    enchant = new ShareCacheStruct<EnchantInfo>().FindKey(userPlot.EnchantID);

                //    if (enchant != null)
                //    {
                //        universalList.Add(new UniversalInfo() { Name = enchant.EnchantName, HeadID = enchant.HeadID, Num = 1 });
                //    }
                //}
                userPlot.ItemList.Clear();
            }
            universalArray = universalList.ToArray();


            return(true);
        }
Esempio n. 16
0
 private short GetPlotStatus(UserPlotInfo userPlot, PlotType plotType)
 {
     if (userPlot != null)
     {
         if (plotType == PlotType.Normal)
         {
             var plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(userPlot.PlotID);
             if (plotInfo.PrePlotID > 0)
             {
                 var preUserPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, plotInfo.PrePlotID);
                 if (preUserPlot == null || preUserPlot.PlotStatus != PlotStatus.Completed)
                 {
                     return (short)PlotStatus.Locked;
                 }
             }
         }
         else
         {
             if (plotType == PlotType.Elite)
             {
                 var plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(userPlot.PlotID);
                 if (plotInfo.PrePlotID > 0 && plotInfo.JYPrePlotID > 0)
                 {
                     var preUserPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, plotInfo.JYPrePlotID);
                     if (preUserPlot == null || preUserPlot.PlotStatus != PlotStatus.Completed)
                     {
                         return (short)PlotStatus.Locked;
                     }
                 }
             }
         }
         return (short)userPlot.PlotStatus;
     }
     return (short)PlotStatus.Locked;
 }
Esempio n. 17
0
        public override bool TakeAction()
        {
            PlotInfo plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(PlotID);
            if (plotInfo != null)
            {
                plotName = plotInfo.PlotName;
            }
            var cacheSetGeneralEscalate = new ConfigCacheSet<GeneralEscalateInfo>();
            GeneralEscalateHelper.AddUserLv(ContextUser, 0);
            int lv = ContextUser.UserLv;
            lv = lv < 0 ? 1 : lv + 1;
            var generalEscalate =
                cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == lv);
            if (generalEscalate != null)
            {
                maxHonourNum = generalEscalate.UpExperience;
            }
            var lastGeneralEscalate = cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == (lv-1));
            if (lastGeneralEscalate!=null)
            {
                lastMaxHonourNum = lastGeneralEscalate.UpExperience;
            }

            embattleList = new GameDataCacheSet<UserEmbattle>().FindAll(ContextUser.UserID, m => m.MagicID == ContextUser.UseMagicID);
            embattleList.QuickSort((x, y) => x.GeneralID.CompareTo(y.GeneralID));
            List<UniversalInfo> universalList = new List<UniversalInfo>();
            userPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, PlotID);
            //var cacheSetPlotInfo = new ConfigCacheSet<PlotInfo>();
            //var cacheSetItem = new ConfigCacheSet<ItemBaseInfo>();
            //var plotInfo = cacheSetPlotInfo.FindKey(PlotID);

            if (userPlot != null && userPlot.ItemList.Count > 0)
            {
                universalList.AddRange(userPlot.ItemList);
                //if (plotInfo != null && userPlot.PlotStatus == PlotStatus.Completed && plotInfo.ItemRank != "" && plotInfo.ItemRank != null)
                //{
                //    var itemArray = plotInfo.ItemRank.Split(',');
                //    foreach (var s in itemArray)
                //    {
                //        int itemId = s.Split('=')[0].ToInt();
                //        var item = cacheSetItem.FindKey(itemId);
                //        if (item != null)
                //        {
                //            universalList.Add(new UniversalInfo() { Name = item.ItemName, HeadID = item.HeadID, Num = s.Split('=')[1].ToInt() });
                //        }
                //    }

                //}
                //if (userPlot.ItemID > 0)
                //{
                //    itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(userPlot.ItemID);
                //    if (itemInfo != null)
                //    {
                //        universalList.Add(new UniversalInfo() { Name = itemInfo.ItemName, HeadID = itemInfo.HeadID, Num = 1 });
                //    }
                //}
                //if (userPlot.EnchantID > 0)
                //{
                //    enchant = new ConfigCacheSet<EnchantInfo>().FindKey(userPlot.EnchantID);

                //    if (enchant != null)
                //    {
                //        universalList.Add(new UniversalInfo() { Name = enchant.EnchantName, HeadID = enchant.HeadID, Num = 1 });
                //    }
                //}
                userPlot.ItemList.Clear();
            }
            universalArray = universalList.ToArray();

           
            return true;
        }