Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="energyNum">精力</param>
        /// <returns>倒计时间</returns>
        private int GetSweepColdTime(out int energyNum)
        {
            energyNum = 0;
            int coldTime = 0;
            List <PlotNPCInfo> npcList = new ShareCacheStruct <PlotNPCInfo>().FindAll(m => m.PlotID == plotID);
            int plotNpcNum             = npcList.Count;
            int battleNum;

            if (SweepOps == 1)
            {
                energyNum = (int)MathUtils.Addition(ContextUser.EnergyNum, ContextUser.SurplusEnergy, short.MaxValue);
                //energyNum = ContextUser.EnergyNum > 200 ? 200 : ContextUser.EnergyNum;
                energyNum = energyNum > 200 ? 200 : energyNum;
                battleNum = (energyNum / PlotInfo.BattleEnergyNum) * plotNpcNum;
                coldTime  = battleNum * PlotInfo.BattleSpeedNum;
            }
            else if (SweepOps == 2)
            {
                coldTime  = 1800;
                battleNum = PlotHelper.GetBattleNum(coldTime);
                energyNum = PlotHelper.GetTurnsNum(plotNpcNum, battleNum) * PlotInfo.BattleEnergyNum;
            }
            else if (SweepOps == 3)
            {
                coldTime  = 3600;
                battleNum = PlotHelper.GetBattleNum(coldTime);
                energyNum = PlotHelper.GetTurnsNum(plotNpcNum, battleNum) * PlotInfo.BattleEnergyNum;
            }

            return(coldTime);
        }
Beispiel #2
0
        private void DoAccelerateQueue(int goldNum, int coldTime, int timing, int totalTime)
        {
            //获取加速后的所需的精力
            int npcCount  = new ShareCacheStruct <PlotNPCInfo>().FindAll(m => m.PlotID == plotID).Count;
            int battleNum = PlotHelper.GetBattleNum(coldTime);
            int turnsNum  = PlotHelper.GetTurnsNum(npcCount, battleNum);
            int energyNum = turnsNum * PlotInfo.BattleEnergyNum;

            ContextUser.RemoveEnergyNum((short)energyNum);
            ContextUser.UseGold    = MathUtils.Addition(ContextUser.UseGold, goldNum, int.MaxValue);
            ContextUser.UserStatus = UserStatus.Normal;
            //ContextUser.Update();

            int totalTurnsNum = PlotHelper.GetTurnsNum(npcCount, PlotHelper.GetBattleNum(totalTime));
            int tempNum       = PlotHelper.GetBattleNum(timing);
            int sweepCount    = PlotHelper.GetTurnsNum(npcCount, tempNum);
            int timesNum      = PlotHelper.GetTimesNum(npcCount, tempNum);

            sweepCount = sweepCount == 0 ? 1 : sweepCount;

            for (int i = sweepCount; i <= totalTurnsNum; i++)
            {
                int j = 1;
                if (i == sweepCount)
                {
                    j = timesNum;
                }
                for (; j <= npcCount; j++)
                {
                    //TrumpAbilityAttack.CombatTrumpLift(ContextUser.UserID);
                    PlotHelper.DoPlotSweepPrize(ContextUser.UserID, plotID, i, j, npcCount);
                }
            }
        }
Beispiel #3
0
        public override bool TakeAction()
        {
            List <PlotNPCInfo> plotNPCInfoList = new ConfigCacheSet <PlotNPCInfo>().FindAll(m => m.PlotID == plotID);

            npcCount = (short)plotNPCInfoList.Count;
            var cacheSet = new GameDataCacheSet <UserQueue>();
            List <UserQueue> userQueueList = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang);

            if (userQueueList.Count > 0)
            {
                UserQueue userQueue = userQueueList[0];
                coldTime = userQueue.DoRefresh();
                if (coldTime == 0)
                {
                    cacheSet.Delete(userQueue);
                    ContextUser.ResetSweepPool(0);
                    ContextUser.UserStatus = UserStatus.Normal;
                    //ContextUser.Update();
                }
                int tempNum = PlotHelper.GetBattleNum(userQueue.GetTiming()) + 1;
                if (npcCount > 0)
                {
                    turnsNum = PlotHelper.GetTurnsNum(npcCount, tempNum);
                    timesNum = PlotHelper.GetTimesNum(npcCount, tempNum);
                }
                //PlotHelper.CheckSweepCount(npcCount, userQueue.GetTiming(), out turnsNum, out battleNum);

                //if (battleNum >= npcCount)
                //{
                //    turnsNum = turnsNum + 1;
                //}
                //else
                //{
                //    battleNum = battleNum + 1;
                //}
            }
            userItemCount = (short)UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao).Count;
            plotInfo      = new ConfigCacheSet <PlotInfo>().FindKey(plotID);
            if (plotInfo == null)
            {
                return(false);
            }
            foreach (PlotNPCInfo npcInfo in plotNPCInfoList)
            {
                if (npcInfo == null)
                {
                    continue;
                }
                List <PlotEmbattleInfo> embattleInfoList = new ConfigCacheSet <PlotEmbattleInfo>().FindAll(m => m.PlotNpcID == npcInfo.PlotNpcID);
                foreach (PlotEmbattleInfo embattleInfo in embattleInfoList)
                {
                    if (monsterDict.ContainsKey(embattleInfo.MonsterID))
                    {
                        if (monsterNumDict.ContainsKey(embattleInfo.MonsterID))
                        {
                            monsterNumDict[embattleInfo.MonsterID] = monsterNumDict[embattleInfo.MonsterID] + 1;
                        }
                    }
                    else
                    {
                        MonsterInfo monsterInfo = new ConfigCacheSet <MonsterInfo>().FindKey(embattleInfo.MonsterID);
                        if (monsterInfo != null)
                        {
                            monsterDict.Add(embattleInfo.MonsterID, monsterInfo);
                            monsterNumDict.Add(embattleInfo.MonsterID, 1);
                        }
                    }
                }
            }
            return(true);
        }
Beispiel #4
0
        public override bool TakeAction()
        {
            List <UserQueue> queueList = new PersonalCacheStruct <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang);

            if (queueList.Count > 0)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St4007_Saodanging;
                return(false);
            }
            var itemList = UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao);

            if (itemList.Count >= ContextUser.GridNum)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St4007_BeiBaoTimeOut;
                return(false);
            }
            List <PlotNPCInfo> npcList = new ShareCacheStruct <PlotNPCInfo>().FindAll(m => m.PlotID == plotID);
            //战斗次数
            int plotNpcNum = npcList.Count;
            int energyNum  = 0;
            int battleNum;

            if (ops == 1)
            {
                //用尽精力,玩家可扫荡轮数
                energyNum = ContextUser.EnergyNum > 200 ? 200 : ContextUser.EnergyNum.ToInt();
                int userTurnsNum = (int)Math.Floor((double)energyNum / PlotInfo.BattleEnergyNum);
                battleNum = userTurnsNum * plotNpcNum;
                coldTime  = battleNum * PlotInfo.BattleSpeedNum;
            }
            else if (ops == 2)
            {
                //30分钟
                coldTime  = Time_30;
                battleNum = PlotHelper.GetBattleNum(Time_30);
                energyNum = PlotHelper.GetTurnsNum(plotNpcNum, battleNum) * PlotInfo.BattleEnergyNum;
            }
            else if (ops == 3)
            {
                //60分钟
                coldTime  = Time_60;
                battleNum = PlotHelper.GetBattleNum(Time_60);
                energyNum = PlotHelper.GetTurnsNum(plotNpcNum, battleNum) * PlotInfo.BattleEnergyNum;
            }
            else
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            if (ContextUser.EnergyNum == 0 || ContextUser.EnergyNum < energyNum)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
                return(false);
            }
            //清除扫荡池
            var sweepCacheSet = new PersonalCacheStruct <UserSweepPool>();
            List <UserSweepPool> sweepPoolList = sweepCacheSet.FindAll(ContextUser.UserID);

            foreach (UserSweepPool sweepPool in sweepPoolList)
            {
                if (sweepPool != null)
                {
                    sweepCacheSet.Delete(sweepPool);
                }
            }

            if (coldTime > 0)
            {
                //在开始战斗时扣一次玩家精力,无战斗离开返还
                ContextUser.ResetSweepPool(plotID);
                //开始扫荡暂不扣精力
                //ContextUser.RemoveEnergyNum(PlotInfo.BattleEnergyNum);
                ContextUser.UserStatus = UserStatus.SaoDang;
                //ContextUser.Update();

                //放入队列中
                UserQueue userQueue = new UserQueue()
                {
                    QueueID       = Guid.NewGuid().ToString(),
                    UserID        = ContextUser.UserID,
                    QueueType     = QueueType.SaoDang,
                    QueueName     = QueueType.SaoDang.ToString(),
                    TotalColdTime = coldTime,
                    Timing        = DateTime.Now,
                    ColdTime      = coldTime,
                    IsSuspend     = false
                };
                new PersonalCacheStruct <UserQueue>().Add(userQueue);
            }
            return(true);
        }