Ejemplo n.º 1
0
        public override bool TakeAction()
        {
            UserQueue userQueue = null;
            int       energyNum;
            int       coleTime  = GetSweepColdTime(out energyNum);
            short     surEnergy = MathUtils.Addition(ContextUser.EnergyNum, ContextUser.SurplusEnergy, short.MaxValue);

            if ((ContextUser.EnergyNum == 0 && ContextUser.SurplusEnergy == 0) || surEnergy < energyNum)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
                return(false);
            }
            int goldNum = GetGoldNum(out userQueue);

            if (goldNum == 0)
            {
                return(false);
            }
            if (ops == 1)
            {
                //提示晶石操作
                ErrorCode = ops;
                ErrorInfo = string.Format(LanguageManager.GetLang().St4008_Tip, goldNum);
            }
            else if (ops == 2)
            {
                //使用晶石确认操作
                int userGoldNum = ContextUser.GoldNum;
                if (userGoldNum < goldNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                //晶石扫荡
                if (userQueue != null)
                {
                    DoAccelerateQueue(goldNum, userQueue.DoRefresh(), userQueue.GetTiming(), userQueue.TotalColdTime);
                    //加速完清除队列
                    var queueCacheSet = new PersonalCacheStruct <UserQueue>();
                    queueCacheSet.Delete(userQueue);
                    ContextUser.ResetSweepPool(0);
                    //ContextUser.Update();
                }
                else
                {
                    //清除扫荡池
                    var sweepCacheSet = new PersonalCacheStruct <UserSweepPool>();
                    List <UserSweepPool> sweepPoolList = sweepCacheSet.FindAll(ContextUser.UserID);
                    foreach (UserSweepPool sweepPool in sweepPoolList)
                    {
                        if (sweepPool != null)
                        {
                            sweepCacheSet.Delete(sweepPool);
                        }
                    }
                    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);
                    }
                    DoAccelerateQueue(goldNum, coleTime, 0, coleTime);
                }
                DateTime startDate = userQueue != null ? userQueue.Timing : DateTime.Now;
                UserLogHelper.AppenRaidsLog(ContextUser.UserID, 2, startDate, DateTime.Now, (short)GetSweepEnergy(out energyNum), goldNum);
            }
            else
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
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);
        }