Example #1
0
        public override int CompareTo(BaseEntity item)
        {
            UserSweepPool other  = item as UserSweepPool;
            int           result = 0;

            if (this == null && other == null)
            {
                return(0);
            }
            else if (this != null && other == null)
            {
                return(1);
            }
            else if (this == null && other != null)
            {
                return(-1);
            }

            result = this.UserID.CompareTo(other.UserID);
            if (result == 0)
            {
                if (this.TurnsNum < other.TurnsNum)
                {
                    return(-1);
                }
                else if (this.TurnsNum > other.TurnsNum)
                {
                    return(1);
                }
                else
                {
                    if (this.BattleNum < other.BattleNum)
                    {
                        return(-1);
                    }
                    else if (this.BattleNum > other.BattleNum)
                    {
                        return(1);
                    }
                }
            }
            return(result);
        }
Example #2
0
        /// <summary>
        /// 副本扫荡奖励
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="plotID"></param>
        /// <param name="turnsNum"></param>
        /// <param name="battleNum"></param>
        /// <param name="npcCount"></param>
        internal static void DoPlotSweepPrize(string userID, int plotID, int turnsNum, int battleNum, int npcCount)
        {
            GameUser user = new GameDataCacheSet<GameUser>().FindKey(userID);
            if (user == null)
            {
                return;
            }

            int experience = 0;
            var npcList = new ConfigCacheSet<PlotNPCInfo>().FindAll(m => m.PlotID == plotID && m.NpcSeqNo == battleNum);
            if (npcList.Count == 0) return;
            PlotNPCInfo npcInfo = npcList[0];
            experience += npcInfo.Experience;
            var cacheSet = new GameDataCacheSet<UserSweepPool>();
            UserSweepPool sweepPool = cacheSet.FindKey(userID, turnsNum, battleNum);
            if (sweepPool == null)
            {
                sweepPool = new UserSweepPool
                {
                    UserID = userID,
                    CreateDate = DateTime.Now
                };
            }
            sweepPool.PlotID = plotID;
            sweepPool.TurnsNum = turnsNum;
            sweepPool.BattleNum = battleNum;
            sweepPool.Experience = npcInfo.Experience;
            sweepPool.ExpNum = npcInfo.ExpNum;
            sweepPool.GameCoin = npcInfo.GameCoin;
            sweepPool.Gold = npcInfo.GetRandomGold();
            sweepPool.PrizeItems = GetPlotMonsterItems(userID, npcInfo.PlotNpcID);
            sweepPool.IsSend = false;
            if (cacheSet.FindKey(userID, turnsNum, battleNum) == null)
            {
                cacheSet.Add(sweepPool, GameEnvironment.CacheUserPeriod);
            }
            //else
            //{
            //    sweepPool.Update();
            //}

            user.ExpNum = MathUtils.Addition(user.ExpNum, sweepPool.ExpNum, int.MaxValue);
            user.GameCoin = MathUtils.Addition(user.GameCoin, sweepPool.GameCoin + sweepPool.BlessPennyNum, int.MaxValue);
            user.ItemGold = MathUtils.Addition(user.ItemGold, sweepPool.Gold, int.MaxValue);

            if (battleNum == npcCount)
            {
                PlotInfo plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(plotID);

                experience += plotInfo.Experience;
                //通关奖励
                int tempNum = 10;
                //var cacheSet = new GameDataCacheSet<UserSweepPool>();
                if (cacheSet.FindKey(userID, turnsNum, tempNum) == null)
                {
                    sweepPool = new UserSweepPool
                                    {
                                        UserID = userID,
                                        CreateDate = DateTime.Now
                                    };
                }
                sweepPool.PlotID = plotID;
                sweepPool.TurnsNum = turnsNum;
                sweepPool.BattleNum = tempNum;
                sweepPool.Experience = plotInfo.Experience;
                sweepPool.ExpNum = plotInfo.ExpNum;
                sweepPool.GameCoin = plotInfo.GameCoin;
                sweepPool.Gold = plotInfo.GetRandomGold();
                sweepPool.PrizeItems = GetPrizeItems(userID, plotInfo.ItemProbability, plotInfo.ItemRank, plotInfo.PlotID, null);
                sweepPool.IsSend = false;

                //祝福加金币

                if (UserHelper.GainBlessing(user, 0) > 0)
                {
                    UserHelper.GainBlessing(user, 1);
                    sweepPool.BlessPennyNum = (int)Math.Floor(plotInfo.GameCoin * new GuildMember().BlessingCionPercent);
                }
                if (!string.IsNullOrEmpty(user.MercenariesID))
                {
                    //公会技能加成
                    sweepPool.Experience = MathUtils.RoundCustom(sweepPool.Experience * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.Experience)).ToInt();
                    sweepPool.ExpNum = MathUtils.RoundCustom(sweepPool.ExpNum * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.ExpNum)).ToInt();
                    sweepPool.GameCoin = MathUtils.RoundCustom(sweepPool.GameCoin * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.CoinNum)).ToInt();
                }
                if (cacheSet.FindKey(userID, turnsNum, tempNum) == null)
                {
                    cacheSet.Add(sweepPool, GameEnvironment.CacheUserPeriod);
                }

                user.ExpNum = MathUtils.Addition(user.ExpNum, sweepPool.ExpNum, int.MaxValue);
                user.GameCoin = MathUtils.Addition(user.GameCoin, sweepPool.GameCoin, int.MaxValue);
                user.ItemGold = MathUtils.Addition(user.ItemGold, sweepPool.Gold, int.MaxValue);

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

            }

            //user.Update();
            //佣兵经验
            //UserHelper.UserGeneralExp(user.UserID, experience);
            TaskHelper.KillPlotMonster(userID, plotID, npcList[0].PlotNpcID);
            TrumpAbilityAttack.CombatTrumpLift(userID);
        }