示例#1
0
        /// <summary>
        /// 刷新副本奖励
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="plotID"></param>
        public static bool RefleshPrize(string userID, int plotID)
        {
            int turnsNum = 0;
            int battleNum = 0;

            List<UserQueue> queueList = new PersonalCacheStruct<UserQueue>().FindAll(userID, m => m.QueueType == QueueType.SaoDang);
            if (queueList.Count == 0)
            {
                return false;
            }
            UserQueue saodangQueue = queueList[0];
            var npcList = new ShareCacheStruct<PlotNPCInfo>().FindAll(m => m.PlotID == plotID);
            int npcCount = npcList.Count;
            GameUser gameUser = new PersonalCacheStruct<GameUser>().FindKey(userID);

            while (HasSweep(userID, plotID, saodangQueue.GetTiming(), npcCount, out turnsNum, out battleNum))
            {
                int tempbattleNum = 0;
                if (gameUser.SweepPool.TurnsNum > 0)
                {
                    tempbattleNum = (gameUser.SweepPool.TurnsNum - 1) * npcCount + gameUser.SweepPool.BattleNum;
                }
                tempbattleNum += 1;
                turnsNum = GetTurnsNum(npcCount, tempbattleNum);
                battleNum = GetTimesNum(npcCount, tempbattleNum);
                DoPlotSweepPrize(userID, plotID, turnsNum, battleNum, npcCount);
                if (gameUser.SweepPool.TurnsNum < turnsNum)
                {
                    if (gameUser.SurplusEnergy > 0)
                    {
                        //每轮扣一次精力
                        gameUser.SurplusEnergy = MathUtils.Subtraction(gameUser.SurplusEnergy, PlotInfo.BattleEnergyNum, (short)0);
                    }
                    else
                    {
                        //每轮扣一次精力
                        gameUser.EnergyNum = MathUtils.Subtraction(gameUser.EnergyNum, PlotInfo.BattleEnergyNum, (short)0);
                    }
                }

                gameUser.SweepPool.UpdateNotify(obj =>
                {
                    gameUser.SweepPool.PlotID = plotID;
                    gameUser.SweepPool.TurnsNum = turnsNum;
                    gameUser.SweepPool.BattleNum = battleNum;
                    return true;
                });
                //gameUser.Update();

            }
            if (saodangQueue.DoRefresh() == 0)
            {
                if (gameUser.UserStatus != UserStatus.Normal)
                {
                    var cacheSet = new PersonalCacheStruct<UserQueue>();
                    cacheSet.Delete(saodangQueue);

                    gameUser.UserStatus = UserStatus.Normal;
                    gameUser.ResetSweepPool(0);
                    //gameUser.Update();
                }
            }

            return true;
        }