Exemplo n.º 1
0
        public mrMap GetDroneMapper()
        {
            var geoMapPlotterHelper = gameObject.AddComponent <GeoMapPlotHelper>();
            var columnsByName       = CsvUtils.GetColumnsByIndex <float>(CsvResourcePath, LatitudeIndex, LongitudeIndex, AltitudeIndex);
            var count  = columnsByName[AltitudeIndex].Count;
            var colors = Enumerable.Range(0, count).Select(i => new Color(138, 43, 226)).ToList();

            var locationStrings = Enumerable.Range(0, count).Select(i =>
                                                                    columnsByName[LongitudeIndex][i].ToString("n4") + ", " + columnsByName[LatitudeIndex][i].ToString("n4")
                                                                    ).ToList();

            var data = new GeoMapPlotHelper.GeoMapData(
                Title,
                Longitude,
                Latitude,
                Zoom,
                GeoMapPlotHelper.GeoDefaultPlotScale,
                locationStrings,
                columnsByName[AltitudeIndex],
                colors,
                SpawnScale,
                HeightScaleMax,
                HeightScaleMin,
                PlotHelper.GetPlotHolder()
                );

            return(geoMapPlotterHelper.GetMrMap(data));
        }
Exemplo n.º 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);
                }
            }
        }
        public mrMap GetCarletonMapper()
        {
            var geoMapPlotterHelper = gameObject.AddComponent <GeoMapPlotHelper>();

            var colors = Enumerable.Range(0, _locationStrings.Count).Select(i =>
                                                                            new Color(Random.value, Random.value, Random.value)
                                                                            ).ToList();

            var data = new GeoMapPlotHelper.GeoMapData(
                Title,
                Longitude,
                Latitude,
                Zoom,
                GeoMapPlotHelper.GeoDefaultPlotScale,
                _locationStrings,
                _locationValues,
                colors,
                SpawnScale,
                HeightScaleMax,
                HeightScaleMin,
                PlotHelper.GetPlotHolder()
                );

            return(geoMapPlotterHelper.GetMrMap(data));
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public SummaryViewModel(IQueryDispatcher queryDispatcher, TransactionsProvider provider, StockSummaryViewModel stockSummary) : base(queryDispatcher, provider)
        {
            StocksSummaryViewModel       = stockSummary;
            BalanceModel                 = PlotHelper.CreatePlotModel();
            BalanceModel.IsLegendVisible = false;
            FlowsModel = PlotHelper.CreatePlotModel();
            FlowsModel.IsLegendVisible       = false;
            YearBalanceModel                 = PlotHelper.CreatePlotModel();
            YearBalanceModel.IsLegendVisible = false;

            BalanceModel.Axes.Add(new DateTimeAxis {
                Position = AxisPosition.Bottom, IntervalType = DateTimeIntervalType.Months
            });
            FlowsModel.Axes.Add(new DateTimeAxis {
                Position = AxisPosition.Bottom, IntervalType = DateTimeIntervalType.Months
            });
            YearBalanceModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, IsAxisVisible = false
            });
            YearBalanceModel.Axes.Add(new DateTimeAxis {
                Position = AxisPosition.Bottom, IntervalType = DateTimeIntervalType.Years
            });

            Update();
        }
        public TraderBotResultsPlotViewModel(PlotHelper drawer)
        {
            Drawer             = drawer;
            this.PlotViewModel = new PlotModel {
                Title = Drawer.Title
            };


            CreateAxes();
            Candles = new CandleStickSeries();
            Candles.TrackerFormatString = "{0}\n{1}: {2}\nHigh: {3:0.########}\nLow: {4:0.########}\nOpen: {5:0.########}\nClose: {6:0.########}";

            Volumes = new VolumeSeries()
            {
                PositiveHollow = false,
                VolumeStyle    = VolumeStyle.Stacked,
                YAxisKey       = Volume_Yaxis.Key,
            };



            PlotViewModel.KeyDown += PlotViewModel_KeyDown;
            timer = new System.Timers.Timer()
            {
                Interval  = 100,
                AutoReset = true,
            };
            timer.Elapsed += UpdateOnTimerTick;
            timer.Start();
        }
Exemplo n.º 7
0
        private void PlotGeographicMapFile(string fileName, string csv, List <string> headers)
        {
            var   columnsByIndex      = CsvUtils.GetContentColumnsByIndex <float>(csv, GeoMapLongitude, GeoMapLatitude, GeoMapValue, GeoMapR, GeoMapG, GeoMapB);
            var   geoMapPlotterHelper = gameObject.AddComponent <GeoMapPlotHelper>();
            var   numLocations        = columnsByIndex[GeoMapLongitude].Count;
            int   halfIndex           = numLocations / 2;
            float longitude;
            float latitude;

            var colors = Enumerable.Range(0, numLocations).Select(i =>
                                                                  new Color(columnsByIndex[GeoMapR][i], columnsByIndex[GeoMapG][i], columnsByIndex[GeoMapB][i])
                                                                  ).ToList();


            var sortedLongitudes = new List <float>(columnsByIndex[GeoMapLongitude]);
            var sortedLatitudes  = new List <float>(columnsByIndex[GeoMapLatitude]);

            if ((numLocations % 2) == 0)
            {
                longitude = (sortedLongitudes.ElementAt(halfIndex) +
                             sortedLongitudes.ElementAt(halfIndex - 1)) / 2;
                latitude = (sortedLatitudes.ElementAt(halfIndex) +
                            sortedLatitudes.ElementAt(halfIndex - 1)) / 2;
            }
            else
            {
                longitude = sortedLongitudes.ElementAt(halfIndex);
                latitude  = sortedLatitudes.ElementAt(halfIndex);
            }

            var locationStrings = Enumerable.Range(0, numLocations).Select(i =>
                                                                           columnsByIndex[GeoMapLongitude][i].ToString("n4") + ", " + columnsByIndex[GeoMapLatitude][i].ToString("n4")
                                                                           ).ToList();

            var data = new GeoMapPlotHelper.GeoMapData(
                fileName,
                longitude,
                latitude,
                16,
                GeoMapPlotHelper.GeoDefaultPlotScale,
                locationStrings,
                columnsByIndex[GeoMapValue],
                colors,
                GeoSpawnScale,
                GeoHeightScaleMax,
                GeoHeightScaleMin,
                PlotHelper.GetPlotHolder()
                );

            var plotter       = geoMapPlotterHelper.GetMrMap(data);
            var plotContainer = Instantiate(plotter);

            SetSpawn(plotContainer.MapHolder);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 通关获得的物品奖励
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="npcInfo"></param>
        /// <returns></returns>
        private List <UniversalInfo> GetUniversalList()
        {
            List <UniversalInfo> universalList = new List <UniversalInfo>();

            foreach (PrizeItemInfo info in prizeItems)
            {
                if (info.Type == 0)
                {
                    ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(info.ItemID);
                    if (itemInfo != null)
                    {
                        universalList.Add(new UniversalInfo()
                        {
                            Name = itemInfo.ItemName, HeadID = itemInfo.HeadID, Num = info.Num
                        });
                    }
                }
                else if (info.Type == 1)
                {
                    SparePartInfo sparePart = new ConfigCacheSet <SparePartInfo>().FindKey(info.ItemID);
                    if (sparePart != null)
                    {
                        universalList.Add(new UniversalInfo()
                        {
                            Name = sparePart.Name, HeadID = sparePart.HeadID, Num = info.Num
                        });
                    }
                }
                else if (info.Type == 2)
                {
                    EnchantInfo enchantInfo = new ConfigCacheSet <EnchantInfo>().FindKey(info.ItemID);
                    if (enchantInfo != null)
                    {
                        universalList.Add(new UniversalInfo()
                        {
                            Name = enchantInfo.EnchantName, HeadID = enchantInfo.HeadID, Num = info.Num
                        });
                        PlotHelper.EnchantAddUser(ContextUser, enchantInfo.EnchantID);
                    }
                }
            }
            return(universalList);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 当前玩家所在的层、关的副本
        /// </summary>
        /// <returns></returns>
        public static PlotInfo CheckUserPlotKalpa(GameUser user)
        {
            PlotInfo plotInfo = null;

            var userPlotArray = UserPlotHelper.UserPlotFindAll(user.UserID).FindAll(m => m.PlotType == PlotType.Kalpa);

            if (userPlotArray.Count == 0)
            {
                PlotHelper.EnablePlot(user.UserID, 8000);
                UserPlotHelper.UserPlotFindAll(user.UserID).FindAll(m => m.PlotType == PlotType.Kalpa);
            }
            if (userPlotArray.Count > 0)
            {
                userPlotArray.QuickSort((x, y) =>
                {
                    int result = 0;
                    if (x == null && y == null)
                    {
                        return(0);
                    }
                    if (x != null && y == null)
                    {
                        return(1);
                    }
                    if (x == null)
                    {
                        return(-1);
                    }
                    result = new ConfigCacheSet <PlotInfo>().FindKey(y.PlotID).LayerNum.CompareTo(
                        new ConfigCacheSet <PlotInfo>().FindKey(x.PlotID).LayerNum);
                    if (result == 0)
                    {
                        result = new ConfigCacheSet <PlotInfo>().FindKey(y.PlotID).PlotSeqNo.CompareTo(
                            new ConfigCacheSet <PlotInfo>().FindKey(x.PlotID).PlotSeqNo);
                    }
                    return(result);
                });
                plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(userPlotArray[0].PlotID);
            }
            return(plotInfo);
        }
        public static void Show(PlotHelper plot)
        {
            ok = false;
            TraderBotResultsPlotViewModel vm = null;
            Thread newWindowThread           = new Thread(new ThreadStart(() =>
            {
                // Create our context, and install it:
                SynchronizationContext.SetSynchronizationContext(
                    new DispatcherSynchronizationContext(
                        Dispatcher.CurrentDispatcher));

                TraderBotResultsPlot Window = new TraderBotResultsPlot();
                vm        = new Plotting.TraderBotResultsPlotViewModel(plot);
                vm.Window = Window;
                // When the window closes, shut down the dispatcher
                Window.Closed += (s, e) =>
                                 Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);
                Window.Loaded += (s, e) => ok = true;
                try
                {
                    Window.DataContext = vm;
                    Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => Window.Show()));
                    // Start the Dispatcher Processing
                    System.Windows.Threading.Dispatcher.Run();
                }
                catch (Exception)
                {
                }
            }));

            newWindowThread.SetApartmentState(ApartmentState.STA);
            // Make the thread a background thread
            newWindowThread.IsBackground = true;
            // Start the thread
            newWindowThread.Start();
            while (!ok)
            {
                Thread.Sleep(100);
            }
            vm.UpdateChart();
        }
Exemplo n.º 12
0
        public override bool TakeAction()
        {
            int totalNum = 0;

            UserHelper.ChechDailyRestrain(ContextUser.UserID);
            totalNum = PlotHelper.HeroSurplusNum(ContextUser.UserID, cityID, ContextUser.VipLv);
            if (totalNum <= 0 || PlotHelper.HeroRefreshNum(ContextUser.UserID, cityID) > totalNum)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4014_HeroRefreshPlotFull;
                return(false);
            }
            int useGold = ConfigEnvSet.GetInt("UserPlot.HeroRefreshGoldNum");

            if (ops == 1)
            {
                ErrorCode = ops;
                ErrorInfo = string.Format(LanguageManager.GetLang().St4014_HeroRefreshPlot, useGold);
                return(false);
            }
            else if (ops == 2)
            {
                if (ContextUser.GoldNum < useGold)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                UserDailyRestrain dailyRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(ContextUser.UserID);
                if (dailyRestrain != null)
                {
                    //z增加刷新次数 (未完成)
                    HeroRefreshNum(ContextUser.UserID, cityID);
                }
                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue);
                //ContextUser.Update();
            }
            return(true);
        }
Exemplo n.º 13
0
        public override bool TakeAction()
        {
            UserTask      usertask = new GameDataCacheSet <UserTask>().FindKey(ContextUser.UserID, TaskID);
            StoryTaskInfo taskInfo = new ConfigCacheSet <StoryTaskInfo>().FindKey(TaskID);

            if (taskInfo == null)
            {
                return(false);
            }
            if (usertask == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                //ErrorInfo = LanguageManager.GetLang().St3002_NotFind;
                SaveLog(new Exception(string.Format("{0},User:{1},task:{2}", LanguageManager.GetLang().St3002_NotFind, ContextUser.UserID, TaskID)));
                return(false);
            }
            ErrorCode = Ops;
            if (Ops == 1)
            {
                //领取
                if (usertask.TaskState != TaskState.AllowTake)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    //ErrorInfo = LanguageManager.GetLang().St3002_NoAllowTaked;
                    return(false);
                }
                if (taskInfo.TaskLv > ContextUser.UserLv)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St3002_LvNotEnough;
                    return(false);
                }

                TaskState taskState = TaskState.Taked;
                if (taskInfo.TermsType == PlotTermsType.Dialogue)
                {
                    //对话直接完成
                    taskState = TaskState.Completed;
                }
                if (new GameDataCacheSet <UserTask>().FindKey(usertask.UserID, usertask.TaskID) == null)
                {
                    usertask = new UserTask()
                    {
                        UserID        = ContextUser.UserID,
                        TaskID        = TaskID,
                        TaskType      = taskInfo.TaskType,
                        TaskTargetNum = string.Empty,
                        TaskState     = taskState,
                        TakeDate      = DateTime.Now,
                        CompleteNum   = 0,
                        CreateDate    = DateTime.Now
                    };
                    new GameDataCacheSet <UserTask>().Add(usertask);
                }
                else
                {
                    usertask.TaskState = taskState;
                    usertask.TakeDate  = DateTime.Now;
                    //usertask.Update();
                }
                PlotHelper.EnablePlot(Uid, taskInfo.PlotID);
            }
            else if (Ops == 2)
            {
                if (usertask.TaskState == TaskState.Completed)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St3002_Completed;
                    return(false);
                }
                if (usertask.TaskState != TaskState.Taked)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    //ErrorInfo = LanguageManager.GetLang().St3002_NoTaked;
                    return(false);
                }
                usertask.TaskTargetNum = string.Empty;
                usertask.TaskState     = TaskState.AllowTake;
                //usertask.Update();
            }

            return(true);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        //protected override bool ValidateElement()
        //{
        //    return UserHelper.GetKeyWordSubstitution(UserName);

        //}
        protected override bool CreateUserRole(out IUser user)
        {
            user = null;
            int MaxLength = ConfigEnvSet.GetInt("User.MaxLength");
            int length    = System.Text.Encoding.Default.GetByteCount(UserName);

            if (UserHelper.GetKeyWordSubstitution(UserName))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RegistNameKeyWord;
                return(false);
            }
            if (GameUser.IsNickName(UserName))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_Rename;
                return(false);
            }
            if (length <= 0 || length > MaxLength)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = string.Format(LanguageManager.GetLang().St1005_KingNameTooLong, MaxLength);
                return(false);
            }
            Regex re = new Regex(@"^[\u4e00-\u9fa5\w]+$");

            if (!re.IsMatch(UserName))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RegistNameExceptional;
                return(false);
            }
            if (!Pid.ToLower().StartsWith("z"))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_PassportError;
                return(false);
            }
            GeneralInfo general = new ConfigCacheSet <GeneralInfo>().FindKey(generalID);

            if (general == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            CareerInfo careerInfo = new ConfigCacheSet <CareerInfo>().FindKey(general.CareerID);

            if (careerInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_Professional;
                return(false);
            }

            GameUser userEntity = new GameDataCacheSet <GameUser>().FindKey(Uid);

            if (userEntity != null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RoleExist;
                return(false);
            }
            bool userSex = Sex == 0 ? false : true;

            if (new GameDataCacheSet <GameUser>().FindKey(Uid) == null)
            {
                userEntity = CreateGameUser(userSex);
                user       = new SessionUser(userEntity);
                NoviceHelper.RetailLoginDaysReceive(userEntity); //渠道登录奖励
                CreateGeneral(careerInfo);
                CreateMagic(userEntity);
                //每日限制次数
                CreateDailyRestrain();
                //开启默认功能
                EnableFunction();
                //SendGifItem();
                UserPrayHelper.AddUserPray(Uid.ToInt(), PrayType.SanTianQiDao);
                UserPackHelper.AddUserPack(Uid);
                UserLoginLog userLoginLog = new UserLoginLog();
                userLoginLog.UserId     = Uid;
                userLoginLog.SessionID  = Sid;
                userLoginLog.MobileType = MobileType;
                userLoginLog.ScreenX    = ScreenX;
                userLoginLog.ScreenY    = ScreenY;
                userLoginLog.RetailId   = RetailID;
                userLoginLog.AddTime    = DateTime.Now;
                userLoginLog.State      = LoginStatus.Logined;
                userLoginLog.DeviceID   = DeviceID;
                userLoginLog.Ip         = this.GetRealIP();
                userLoginLog.Pid        = userEntity.Pid;
                userLoginLog.UserLv     = userEntity.UserLv;
                var sender = DataSyncManager.GetDataSender();
                sender.Send(userLoginLog);
                BackPackHelper.AddBack(userEntity);
                UserHelper.OpenMagic(Uid, 1);
                //封测注册发放礼包
                UserItemHelper.AddUserItem(Uid, 1704, 1, ItemStatus.BeiBao);
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RoleExist;
                return(false);
            }
            PlotHelper.EnablePlot(Uid, ConfigEnvSet.GetInt("UserPlot.OpenLockPlotID"));
            return(true);
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
        public override bool TakeAction()
        {
            bool result = true;

            taskInfo = new ConfigCacheSet <StoryTaskInfo>().FindKey(TaskID);
            if (taskInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                //this.ErrorInfo = LanguageManager.GetLang().St3002_NotFind;
                SaveLog(new Exception(string.Format("{0},User:{1},task:{2}", LanguageManager.GetLang().St3002_NotFind, ContextUser.UserID, TaskID)));
                return(false);
            }
            _userGeneral = UserGeneral.GetMainGeneral(Uid);
            //获得奖励
            UserTask userTask = new GameDataCacheSet <UserTask>().FindKey(ContextUser.UserID, TaskID);

            if (userTask == null || userTask.TaskState != TaskState.Completed)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St3007_NoCompleted;
                return(false);
            }
            //交付物品任务扣除材料
            if (taskInfo.TermsType == PlotTermsType.Shouji || taskInfo.TermsType == PlotTermsType.Delivery)
            {
                UserItemHelper.UseUserItem(Uid, taskInfo.TargetItemID, taskInfo.TargetItemNum);
            }
            userTask.TaskState = TaskState.Close;
            UserTaskLog taskLog = new UserTaskLog()
            {
                LogID     = Guid.NewGuid().ToString(),
                TaskID    = userTask.TaskID,
                UserID    = userTask.UserID,
                TaskType  = userTask.TaskType,
                TaskState = userTask.TaskState,
                TaskPrize = string.Format("Experience:{0},GameCoin:{1};GameCoin:{2} ",
                                          taskInfo.Experience,
                                          taskInfo.GameCoin,
                                          ContextUser.GameCoin
                                          ),
                CreateDate = DateTime.Now
            };
            var sender = DataSyncManager.GetDataSender();

            sender.Send(taskLog);

            ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, taskInfo.GameCoin, int.MaxValue);
            if (taskInfo.TaskType == TaskType.Master && ContextUser.TaskProgress < TaskID)
            {
                ContextUser.TaskProgress = TaskID;
            }
            //ContextUser.Update();

            //任务加佣兵经验
            //var userEmbattles = new GameDataCacheSet<UserEmbattle>().FindAll(UserEmbattle.Index_UserID_MagicID, Uid, ContextUser.UseMagicID);
            //foreach (var userEmbattle in userEmbattles)
            //{
            //    UserGeneral userGeneral = new GameDataCacheSet<UserGeneral>().FindKey(ContextUser.UserID, userEmbattle.GeneralID);
            //    if (userGeneral == null) continue;
            //    userGeneral.CurrExperience = MathUtils.Addition(userGeneral.CurrExperience, taskInfo.Experience, int.MaxValue);
            //    //userGeneral.Update();
            //}
            UserHelper.UserGeneralExp(ContextUser.UserID, taskInfo.Experience);

            //开启功能
            TaskHelper.EnableFunction(ContextUser, taskInfo.FunctionEnum);

            //下发可接任务
            TaskHelper.SendAllowTask(ContextUser, TaskID);

            //开启副本
            PlotHelper.EnablePlot(Uid, taskInfo.EnablePlot);

            //保留主线任务
            var cacheSet = new GameDataCacheSet <UserTask>();

            if (userTask.TaskType == TaskType.Master)
            {
                //userTask.Update();
            }
            else
            {
                //原因:最后支线任务无限刷新BUG
                if (!TaskHelper.IsLastTask(userTask))
                {
                    cacheSet.Delete(userTask);
                }
            }
            return(result);
        }
Exemplo n.º 18
0
 public void ShowPlot(PlotHelper plot)
 {
     ShowPlotCallback?.Invoke(plot);
 }
Exemplo n.º 19
0
        public override bool TakeAction()
        {
            if (PlotType.Elite == plotType)
            {
                PlotHelper.EnablePlot(Uid, ConfigEnvSet.GetInt("UserPlot.OpenLockJYPlotID"));
            }

            if (plotType == PlotType.Elite && ContextUser.UserLv >= ConfigEnvSet.GetInt("User.JYLv"))
            {
                PlotLsit();
            }
            else
            {
                if (plotType == PlotType.Normal)
                {
                    PlotLsit();
                }
            }
            //var cacheSetUserAbility = new GameDataCacheSet<UserAbility>();
            //var cacheSetItemPackage = new GameDataCacheSet<UserItemPackage>();
            //var cacheSetUserGeneral = new GameDataCacheSet<UserGeneral>();
            //var cacheSetUserPack = new GameDataCacheSet<UserPack>();
            //var userPack = cacheSetUserPack.FindKey(UserId.ToString());
            //if (userPack != null)
            //{
            //    var userItemPack = cacheSetItemPackage.FindKey(UserId.ToString());
            //    userPack.PackTypeList.Foreach(PackTyp =>
            //    {
            //        switch (PackTyp.BackpackType)
            //        {
            //            case BackpackType.BeiBao:

            //                if (userItemPack != null)
            //                {
            //                    int itemNum = userItemPack.ItemPackage.FindAll(s => s.ItemType == ItemType.ZhuangBei).Count;
            //                    _backpackType = itemNum >= PackTyp.Position ? BackpackType.BeiBao.ToInt() : 0;
            //                }
            //                break;
            //            case BackpackType.ZhuangBei:
            //                if (userItemPack != null)
            //                {
            //                    int packNum = userItemPack.ItemPackage.FindAll(s => s.ItemType != ItemType.ZhuangBei).Count;
            //                    _backpackType = packNum >= PackTyp.Position ? BackpackType.ZhuangBei.ToInt() : 0;
            //                }
            //                break;
            //            case BackpackType.HunJi:
            //                var userAbility = cacheSetUserAbility.FindKey(Uid);
            //                if (userAbility != null)
            //                {
            //                    int abilityNum = userAbility.AbilityList.Count;
            //                    _backpackType = abilityNum >= PackTyp.Position ? BackpackType.HunJi.ToInt() : 0;
            //                }
            //                break;
            //            case BackpackType.YongBing:
            //                int generalNum = cacheSetUserGeneral.FindAll(Uid).Count;


            //                _backpackType = generalNum >= PackTyp.Position ? BackpackType.YongBing.ToInt() : 0;

            //                break;
            //        }
            //        return true;
            //    });
            //}
            return(true);
        }
Exemplo n.º 20
0
        public override bool TakeAction()
        {
            if (ContextUser.UserStatus == UserStatus.CountryCombat)
            {
                CountryCombat countryCombat = new CountryCombat(ContextUser);
                if (countryCombat.GameActive != null && countryCombat.GameActive.RefreshStatus() == CombatStatus.Combat)
                {
                    countryCombat.Exit();
                }
            }

            if (ContextUser.EnergyNum <= 0 && ContextUser.SurplusEnergy <= 0)
            {
                ErrorCode = 3;
                ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
                return(false);
            }
            //if (_ops != 1 && UserHelper.IsPromptBlood(ContextUser.UserID))
            //{
            //    ErrorCode = 1;
            //    ErrorInfo = LanguageManager.GetLang().St4002_PromptBlood;
            //    return false;
            //}
            //if (_ops != 1 && UserItemHelper.CheckItemOut(ContextUser, ItemStatus.BeiBao))
            //{
            //    ErrorCode = 1;
            //    ErrorInfo = LanguageManager.GetLang().St_User_BeiBaoMsg;
            //    return false;
            //}

            UserHelper.UserGeneralPromptBlood(ContextUser);//佣兵自动使用绷带补血

            plotInfo = new ShareCacheStruct <PlotInfo>().FindKey(plotID);

            if (plotInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().LoadDataError;
                return(false);
            }
            int challengeNum = PlotHelper.GetPlotChallengeNum(UserId.ToString(), plotInfo.PlotID);

            if (plotInfo.PlotType == PlotType.Elite && challengeNum >= plotInfo.ChallengeNum)
            {
                ErrorCode = 4;
                ErrorInfo = LanguageManager.GetLang().St4002_IsPlotEliteNotChallengeNum;
                return(false);
            }

            if ((challengeNum >= plotInfo.ChallengeNum && ContextUser.VipLv < 3))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4002_NotChallengeNum;
                return(false);
            }

            int num = challengeNum;
            int challengeDefSoldNum    = ConfigEnvSet.GetInt("UserPlot.ChallengeDefSoldNum");
            int challengeDoubleSoldNum = ConfigEnvSet.GetInt("UserPlot.ChallengeDoubleSoldNum");

            if (_ops != 1 && num >= plotInfo.ChallengeNum && PlotHelper.GetPlotIsOne(UserId.ToString(), plotInfo.PlotID))
            {
                ErrorCode = 1;
                _plotNum  = challengeDefSoldNum;
                return(false);
            }
            else
            {
                if (_ops != 1 && num >= plotInfo.ChallengeNum && PlotHelper.GetPlotIsOne(UserId.ToString(), plotInfo.PlotID) == false)
                {
                    int openNum = num - plotInfo.ChallengeNum + 1;
                    _plotNum = challengeDoubleSoldNum * openNum + challengeDefSoldNum;
                }
            }

            if (_ops != 1 && num >= plotInfo.ChallengeNum)
            {
                ErrorCode = 1;
                ErrorInfo = string.Format(LanguageManager.GetLang().St4002_IsPlotNum, _plotNum);
                return(false);
            }
            if (_ops == 1 && num >= plotInfo.ChallengeNum)
            {
                if (ContextUser.GoldNum < _plotNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                ContextUser.UseGold = MathUtils.Subtraction(ContextUser.UseGold, _plotNum);
            }
            if (_ops == 1 && num >= plotInfo.ChallengeNum && PlotHelper.GetPlotIsOne(UserId.ToString(), plotInfo.PlotID) == false)
            {
                int openNum = num - plotInfo.ChallengeNum + 1;
                _plotNum = challengeDoubleSoldNum * openNum + challengeDefSoldNum;;
                if (ContextUser.GoldNum < _plotNum)
                {
                    ErrorCode = 2;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, _plotNum);
            }
            if (_ops != 1 && !string.IsNullOrEmpty(plotInfo.EnchantID) && plotInfo.EnchantProbability > 0 && EnchantHelper.IsEnchantPackage(ContextUser.UserID))
            {
                ErrorCode = 1;
                ErrorInfo = LanguageManager.GetLang().St4002_EnchantPackageFull;
                return(false);
            }
            //var cacheSetUserPlot = new PersonalCacheStruct<UserPlotPackage>();
            //var userPlotPack = cacheSetUserPlot.FindKey(ContextUser.UserID);
            //var userPlot = userPlotPack != null ? userPlotPack.PlotPackage.Find(s => s.PlotID == npcInfo.PlotID) : null;
            var userPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, plotID);

            if (userPlot != null && userPlot.PlotNum >= plotInfo.ChallengeNum)
            {
                if (plotInfo.PlotType == PlotType.Elite)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St4002_EliteUsed;
                    return(false);
                }
                else if (plotInfo.PlotType == PlotType.HeroPlot)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St4002_HeroPlotNum;
                    return(false);
                }
            }
            npcList = new ShareCacheStruct <PlotNPCInfo>().FindAll(m => m.PlotID == plotID);
            //if (ContextUser.EnergyNum < (npcList.Count * PlotInfo.BattleEnergyNum))
            //{
            //    ErrorCode = 3;
            //    ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
            //    return false;
            //}
            ContextUser.InPlotDate = DateTime.Now;
            //if (ContextUser.UserExtend == null || ContextUser.UserExtend.PlotStatusID == 0 || ContextUser.UserExtend.MercenarySeq == 0)
            //{
            //    ContextUser.TempEnergyNum = PlotInfo.BattleEnergyNum;
            //    //ContextUser.RemoveEnergyNum(PlotInfo.BattleEnergyNum);
            //}
            //ContextUser.Update();
            if (ContextUser.UserExtend != null && ContextUser.UserExtend.PlotStatusID <= 0)
            {
                ContextUser.UserExtend.UpdateNotify(obj =>
                {
                    ContextUser.UserExtend.PlotStatusID = plotID;
                    ContextUser.UserExtend.PlotNpcID    = -1;
                    ContextUser.UserExtend.MercenarySeq = 1;
                    ContextUser.UserExtend.IsBoss       = false;
                    return(true);
                });
            }

            _isOverCombat             = userPlot != null && userPlot.PlotStatus == PlotStatus.Completed;
            ContextUser.TempEnergyNum = PlotInfo.BattleEnergyNum;
            return(true);
        }
Exemplo n.º 21
0
 static void ShowPlot(PlotHelper plot)
 {
     PlottingHelper.Show(plot);
     Console.ReadLine();
 }
Exemplo n.º 22
0
        public override bool TakeAction()
        {
            //if (ContextUser.EnergyNum <= 0)
            //{
            //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
            //    return false;
            //}
            //if (ContextUser.EnergyNum <= 0 && ContextUser.TempEnergyNum == 0)
            //{
            //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
            //    return false;
            //}
            if (ContextUser.UserStatus == UserStatus.SaoDang)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4007_Saodanging;
                return(false);
            }
            if (ContextUser.UseMagicID == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic;
                return(false);
            }
            if (new GameDataCacheSet <UserEmbattle>().FindAll(Uid, m => m.MagicID == ContextUser.UseMagicID).Count == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4004_EmbattleEmpty;
                return(false);
            }

            //if (ContextUser.TempEnergyNum == 0)
            //{
            //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
            //    return false;
            //}

            ContextUser.UserStatus = UserStatus.Combat;
            try
            {
                //触发战斗
                PlotNPCInfo npcInfo = new ConfigCacheSet <PlotNPCInfo>().FindKey(PlotNpcID);

                //原因:碰npc时掉线,再请求战斗详情
                if (npcInfo == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().LoadDataError;
                    return(false);
                }

                //原因:最后一个npc时,清空玩家保存副本
                if (ContextUser.UserExtend != null && ContextUser.UserExtend.MercenarySeq > npcInfo.NpcSeqNo)
                {
                    ContextUser.UserStatus = UserStatus.Normal;
                    ContextUser.UserExtend.UpdateNotify(obj =>
                    {
                        ContextUser.UserExtend.PlotStatusID = 0;
                        ContextUser.UserExtend.PlotNpcID    = -1;
                        ContextUser.UserExtend.MercenarySeq = 1;
                        ContextUser.UserExtend.IsBoss       = false;
                        return(true);
                    });
                    //ErrorCode = LanguageManager.GetLang().ErrorCode;
                    //ErrorInfo = LanguageManager.GetLang().St4011_NoMonster;
                    //return false;
                }

                PlotInfo plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(npcInfo.PlotID);
                if (plotInfo == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().LoadDataError;
                    return(false);
                }

                var cacheSetUserPlot = new GameDataCacheSet <UserPlotPackage>();
                var cacheSetItemInfo = new ShareCacheStruct <ItemBaseInfo>();
                var cacheSet         = new GameDataCacheSet <UserPlotCombat>();
                var userPlotPack     = cacheSetUserPlot.FindKey(ContextUser.UserID);
                var userPlot         = userPlotPack != null?userPlotPack.PlotPackage.Find(s => s.PlotID == npcInfo.PlotID) : null;

                //PlotHelper.IsKill(ContextUser.UserID, plotInfo.PlotID, plotInfo.CityID)
                if (userPlot != null && userPlot.PlotNum >= plotInfo.ChallengeNum)
                {
                    if (plotInfo.PlotType == PlotType.Elite)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St4002_EliteUsed;
                        return(false);
                    }
                    else if (plotInfo.PlotType == PlotType.HeroPlot)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St4002_HeroPlotNum;
                        return(false);
                    }
                }

                //if (userPlot != null && userPlot.ItemList != null)
                //{
                //    userPlot.UpdateNotify(obj =>
                //    {
                //        userPlot.ItemList.Clear();
                //        return true;
                //    });
                //}
                if (npcInfo.NpcSeqNo == 1)
                {
                    userPlot.ItemList.Clear();
                    ContextUser.IsItem = false;
                }
                userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID);
                if (userPlotCombat != null && userPlotCombat.IsWin && ContextUser.UserExtend != null &&
                    PlotNpcID == ContextUser.UserExtend.PlotNpcID && !ContextUser.IsItem)
                {
                    prizeItems = PlotHelper.GetPlotMonsterItems(Uid, npcInfo.PlotNpcID);
                }
                else
                {
                    ISingleCombat plotCombater = CombatFactory.TriggerPlot(ContextUser, PlotNpcID);
                    if (plotCombater == null)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().LoadDataError;
                        return(false);
                    }
                    if (userPlotCombat == null)
                    {
                        userPlotCombat = new UserPlotCombat()
                        {
                            UserID    = ContextUser.UserID,
                            PlotNpcID = PlotNpcID
                        };
                        cacheSet.Add(userPlotCombat, GameEnvironment.CacheUserPeriod);
                        userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID);
                    }
                    userPlotCombat.PlotID     = npcInfo.PlotID;
                    userPlotCombat.CombatDate = DateTime.Now;
                    userPlotCombat.IsWin      = plotCombater.Doing();
                    if (!userPlotCombat.IsWin)
                    {
                        userPlotCombat.OverNum += 1;
                    }
                    ContextUser.IsItem            = npcInfo.NpcSeqNo == 1 ? false : ContextUser.IsItem;
                    combatProcessList             = (CombatProcessContainer)plotCombater.GetProcessResult();
                    userPlotCombat.GeneralNum     = combatProcessList.AttackList.Count;
                    userPlotCombat.GeneralOverNum = GetOverGeneralNum(combatProcessList.AttackList.ToList());
                    //userPlotCombat.CombatProcess = JsonUtils.Serialize(combatProcessList);
                    int generalNum = combatProcessList.DefenseList.FindAll(s => s.LiveNum > 0).Count;
                    if (userPlotCombat.IsWin)
                    {
                        if (ContextUser.UserExtend != null)
                        {
                            ContextUser.UserExtend.UpdateNotify(obj =>
                            {
                                ContextUser.UserExtend.PlotStatusID = npcInfo.PlotID;
                                ContextUser.UserExtend.PlotNpcID    = PlotNpcID;
                                ContextUser.UserExtend.MercenarySeq = MathUtils.Addition(npcInfo.NpcSeqNo, (short)1);
                                ContextUser.UserExtend.IsBoss       = npcInfo.IsBoss; //是否最后一个副本npc
                                return(true);
                            });
                        }
                        //玩家通过一个城市的所有副本时,增加聊天频道系统提示
                        if (userPlot.PlotStatus != PlotStatus.Completed && npcInfo.IsBoss)      //玩家此副本胜利
                        {
                            var city     = new ConfigCacheSet <CityInfo>().FindKey(plotInfo.CityID);
                            var nextPlot = new ConfigCacheSet <PlotInfo>().FindKey(plotInfo.AftPlotID);
                            if (city != null && nextPlot != null && nextPlot.CityID != plotInfo.CityID)            //此城市的最后一个副本
                            {
                                string content = string.Format(LanguageManager.GetLang().St_systemprompts, ContextUser.NickName,
                                                               city.CityName);
                                new TjxChatService().SystemSend(ChatType.World, content);
                            }
                        }
                        PlotHelper.DoPlotPrize(Uid, npcInfo, userPlotCombat, generalNum, out _honourNum);
                        if (npcInfo.NpcSeqNo == 1)
                        {
                            ContextUser.EnergyNum = MathUtils.Subtraction(ContextUser.EnergyNum, ContextUser.TempEnergyNum).ToShort();
                            //原因:刷晶石BUG
                            ContextUser.TempEnergyNum = 0;
                        }
                        if (!ContextUser.IsItem)
                        {
                            prizeItems = PlotHelper.GetPlotMonsterItems(Uid, npcInfo.PlotNpcID);
                        }
                        TaskHelper.KillPlotMonster(Uid, npcInfo.PlotID, PlotNpcID);

                        //var stroyTaskList = new ConfigCacheSet<StoryTaskInfo>().FindAll(s => s.PlotID == plotInfo.AftPlotID);
                        //foreach (var story in stroyTaskList)
                        //{
                        //    var usertask = new GameDataCacheSet<UserTask>().FindKey(ContextUser.UserID, story.PlotID);
                        //    if (usertask != null)
                        //    {
                        PlotHelper.EnablePlot(Uid, plotInfo.AftPlotID);
                        //    }
                        //}

                        if (plotInfo.PlotType == PlotType.Elite)
                        {
                            EliteDailyRestrain(npcInfo);
                            NoviceHelper.ElitePlotFestivalList(ContextUser); //通关精英副本获得奖励
                        }
                        else if (plotInfo.PlotType == PlotType.Kalpa)
                        {
                            KalpaDailyRestrain(npcInfo);
                        }
                        else if (plotInfo.PlotType == PlotType.HeroPlot)
                        {
                            PlotHelper.EnableHeroPlot(ContextUser.UserID, plotInfo.PlotID);
                            PlotHelper.HeroDailyRestrain(ContextUser.UserID, plotInfo.PlotID, plotInfo.CityID);
                        }
                    }
                    else
                    {
                        ContextUser.GeneralAllCount  = 0;
                        ContextUser.GeneralKillCount = 0;
                    }


                    var restrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid);
                    if (restrain != null)
                    {
                        var restrainSet = new ShareCacheStruct <DailyRestrainSet>().FindKey(RestrainType.PlotGoto);
                        if (restrainSet != null)
                        {
                            GotoNum = MathUtils.Subtraction(restrainSet.MaxNum, restrain.Funtion14, 0);
                        }
                    }
                }
                //原因:最后一个npc时,清空玩家保存副本
                if (ContextUser.UserExtend != null && ContextUser.UserExtend.IsBoss)
                {
                    ContextUser.UserExtend.UpdateNotify(obj =>
                    {
                        ContextUser.UserExtend.PlotStatusID = 0;
                        ContextUser.UserExtend.PlotNpcID    = -1;
                        ContextUser.UserExtend.MercenarySeq = 0;
                        ContextUser.UserExtend.IsBoss       = npcInfo.IsBoss;
                        return(true);
                    });
                }

                if (!ContextUser.IsItem)
                {
                    foreach (var prize in prizeItems)
                    {
                        if (prize.Type == 0 && userPlot != null)
                        {
                            var           itemInfo      = cacheSetItemInfo.FindKey(prize.ItemID);
                            UniversalInfo universalInfo = new UniversalInfo();
                            universalInfo.HeadID    = itemInfo != null ? itemInfo.HeadID : string.Empty;
                            universalInfo.ItemID    = itemInfo != null ? itemInfo.ItemID : 0;
                            universalInfo.ItemDesc  = itemInfo != null ? itemInfo.ItemDesc : string.Empty;
                            universalInfo.MaxHeadID = itemInfo != null ? itemInfo.MaxHeadID : string.Empty;
                            universalInfo.Name      = itemInfo != null ? itemInfo.ItemName : string.Empty;
                            universalInfo.Num       = prize.Num;
                            if (userPlot.ItemList != null && userPlot.ItemList.Count > 0)
                            {
                                var item = userPlot.ItemList.Find(s => s.ItemID == prize.ItemID);
                                if (item != null)
                                {
                                    item.UpdateNotify(obj =>
                                    {
                                        item.Num = MathUtils.Addition(item.Num, prize.Num);
                                        return(true);
                                    });
                                }
                                else
                                {
                                    userPlot.UpdateNotify(obj =>
                                    {
                                        userPlot.ItemList.Add(universalInfo);
                                        return(true);
                                    });
                                }
                            }
                            else
                            {
                                userPlot.UpdateNotify(obj =>
                                {
                                    userPlot.ItemList.Add(universalInfo);
                                    return(true);
                                });
                            }
                        }
                        ContextUser.IsItem = true;
                    }
                }
                var a = userPlot.ItemList;
            }
            finally
            {
                ContextUser.UserStatus = UserStatus.Normal;
            }
            //日志
            UserCombatLog log = new UserCombatLog();

            log.CombatLogID   = Guid.NewGuid().ToString();
            log.UserID        = userPlotCombat.UserID;
            log.CityID        = ContextUser.CityID;
            log.PlotID        = userPlotCombat.PlotID;
            log.NpcID         = userPlotCombat.PlotNpcID;
            log.CombatType    = CombatType.Plot;
            log.HostileUser   = string.Empty;
            log.IsWin         = userPlotCombat.IsWin;
            log.CombatProcess = JsonUtils.Serialize(combatProcessList);
            log.PrizeItem     = prizeItems;
            log.CreateDate    = DateTime.Now;
            var sender = DataSyncManager.GetDataSender();

            sender.Send(log);

            UserHelper.GetGeneralLife(ContextUser.UserID);
            UserHelper.RegainGeneralLife(ContextUser.UserID);

            //var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true);
            //           foreach (var userEmbattle in userEmbattleList)
            //           {
            //               _userTalPriority = MathUtils.Addition(_userTalPriority, PriorityHelper.GeneralTotalPriority(ContextUser.UserID, userEmbattle.GeneralID));
            //           }
            selfAbilityEffectList = UserAbilityHelper.GetSelfAbilityEffectList(ContextUser.UserID, 0);
            //var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true);

            _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0);

            return(true);
        }
Exemplo n.º 23
0
        public override bool TakeAction()
        {
            //刷新副本奖励
            if (!PlotHelper.RefleshPrize(ContextUser.UserID, plotID))
            {
                //this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                //this.ErrorInfo = LanguageManager.GetLang().St4007_SaodangOver;
            }
            var sweepCacheSet     = new GameDataCacheSet <UserSweepPool>();
            var tempSweepPoolList = sweepCacheSet.FindAll(ContextUser.UserID, m => m.IsSend == false);

            tempSweepPoolList.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                int result = 0;
                x.UserID   = x.UserID == null ? "" : x.UserID;
                y.UserID   = y.UserID == null ? "" : y.UserID;

                result = x.UserID.CompareTo(y.UserID);
                if (result == 0)
                {
                    if (x.TurnsNum < y.TurnsNum)
                    {
                        return(-1);
                    }
                    else if (x.TurnsNum > y.TurnsNum)
                    {
                        return(1);
                    }
                    else
                    {
                        if (x.BattleNum < y.BattleNum)
                        {
                            return(-1);
                        }
                        else if (x.BattleNum > y.BattleNum)
                        {
                            return(1);
                        }
                    }
                }
                return(result);
            });


            userEmbattleList = new GameDataCacheSet <UserEmbattle>().FindAll(ContextUser.UserID, m => m.GeneralID > 0 && m.MagicID == ContextUser.UseMagicID);

            foreach (UserSweepPool userSweepPool in tempSweepPoolList)
            {
                if (userSweepPool != null)
                {
                    sweepCacheSet.Delete(userSweepPool);
                }
            }

            var tempList = new List <UserSweepPool>(tempSweepPoolList);
            int pageSize = 12;
            int index    = 0;

            if (tempList.Count > pageSize)
            {
                index = tempList.Count - pageSize;
            }
            else
            {
                pageSize = tempList.Count;
            }
            if (tempList.Count > 0)
            {
                userSweepPoolList = tempList.GetRange(index, pageSize);
            }

            return(true);
        }
Exemplo n.º 24
0
        public override bool TakeAction()
        {
            var cacheEnvSet = new ConfigCacheSet <ConfigEnvSet>();
            var envset      = cacheEnvSet.FindKey("CombatMaxBout");

            if (envset != null)
            {
            }
            PlotNPCInfo npcInfo = new ConfigCacheSet <PlotNPCInfo>().FindKey(PlotNpcID);

            if (npcInfo == null)
            {
                return(false);
            }
            PlotInfo plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(npcInfo.PlotID);

            if (plotInfo == null)
            {
                return(false);
            }
            //判断是否有下一关
            int nextLayerNum  = MathUtils.Addition(ContextUser.UserExtend.LayerNum, 1);
            int nextHurdleNum = MathUtils.Addition(ContextUser.UserExtend.HurdleNum, 1);

            if ((UserHelper.IsLastLayer(plotInfo) || !IsGotoNextLayer(nextLayerNum)))
            {
                if (UserHelper.IsKill(ContextUser, npcInfo.PlotID))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St4303_PlotNotEnableLayerNum;
                    return(false);
                }
            }

            if (ops != 1 && UserHelper.IsPromptBlood(ContextUser.UserID))
            {
                ErrorCode = 1;
                ErrorInfo = LanguageManager.GetLang().St4002_PromptBlood;
                return(false);
            }
            //原因:灵件背包满时未提示
            if (ops != 1 && UserHelper.IsSpareGridNum(ContextUser, 0))
            {
                ErrorCode = 1;
                ErrorInfo = LanguageManager.GetLang().St_User_SpareBeiBaoMsg;
                return(false);
            }

            if (ops != 1 && !string.IsNullOrEmpty(plotInfo.EnchantID) && plotInfo.EnchantProbability > 0 && EnchantHelper.IsEnchantPackage(ContextUser.UserID))
            {
                ErrorCode = 1;
                ErrorInfo = LanguageManager.GetLang().St4002_EnchantPackageFull;
                return(false);
            }

            if (ContextUser.UserStatus == UserStatus.SaoDang)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4007_Saodanging;
                return(false);
            }
            if (ContextUser.UseMagicID == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic;
                return(false);
            }
            if (new GameDataCacheSet <UserEmbattle>().FindAll(Uid, m => m.MagicID == ContextUser.UseMagicID).Count == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4004_EmbattleEmpty;
                return(false);
            }
            //PlotNPCInfo npcInfo = new ConfigCacheSet<PlotNPCInfo>().FindKey(PlotNpcID);
            if (IsPlotOut(npcInfo))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4303_PlotNotEnable;
                return(false);
            }

            UserHelper.UserGeneralPromptBlood(ContextUser);//佣兵自动使用绷带补血

            //触发战斗
            ISingleCombat plotCombater = CombatFactory.TriggerPlot(ContextUser, PlotNpcID);

            if (plotCombater == null)
            {
                return(false);
            }
            var cacheSet = new GameDataCacheSet <UserPlotCombat>();

            userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID);
            if (userPlotCombat == null)
            {
                userPlotCombat = new UserPlotCombat()
                {
                    UserID    = ContextUser.UserID,
                    PlotNpcID = PlotNpcID
                };
                cacheSet.Add(userPlotCombat, GameEnvironment.CacheUserPeriod);
                userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID);
            }
            userPlotCombat.PlotID     = npcInfo.PlotID;
            userPlotCombat.CombatDate = DateTime.Now;
            userPlotCombat.IsWin      = plotCombater.Doing();
            if (!userPlotCombat.IsWin)
            {
                userPlotCombat.OverNum += 1;
            }
            combatProcessList             = (CombatProcessContainer)plotCombater.GetProcessResult();
            userPlotCombat.GeneralNum     = combatProcessList.AttackList.Count;
            userPlotCombat.GeneralOverNum = GetOverGeneralNum(combatProcessList.AttackList.ToList());

            if (userPlotCombat.IsWin)
            {
                int honourNum = 0;
                PlotHelper.DoPlotPrize(Uid, npcInfo, userPlotCombat, 0, out honourNum);
                prizeItems     = PlotHelper.GetKalpaPlotMonsterItems(Uid, npcInfo.PlotID, npcInfo.PlotNpcID);
                universalArray = GetUniversalList().ToArray();
                if (plotInfo.PlotType == PlotType.Kalpa)
                {
                    KalpaDailyRestrain(npcInfo);
                    if (ContextUser.UserExtend == null)
                    {
                        ContextUser.UserExtend = new GameUserExtend();
                    }

                    PlotInfo[] plotInfoList = new ConfigCacheSet <PlotInfo>().FindAll(m => m.LayerNum == ContextUser.UserExtend.LayerNum && m.PlotSeqNo == nextHurdleNum && m.PlotType == PlotType.Kalpa).ToArray();
                    if (plotInfoList.Length > 0)
                    {
                        int layerNum  = ContextUser.UserExtend.LayerNum;
                        int hurdleNum = ContextUser.UserExtend.HurdleNum;

                        if (CheckHurdleNum(ContextUser.UserID, layerNum, hurdleNum))
                        {
                            ContextUser.UserExtend.UpdateNotify(obj =>
                            {
                                ContextUser.UserExtend.HurdleNum = nextHurdleNum;
                                return(true);
                            });
                            //ContextUser.Update();
                            PlotHelper.EnablePlot(ContextUser.UserID, plotInfo.AftPlotID);
                        }
                    }
                    else if (IsGotoNextLayer(nextLayerNum))
                    {
                        //判断是否能到下一层
                        plotInfoList = new ConfigCacheSet <PlotInfo>().FindAll(m => m.LayerNum == nextLayerNum && m.PlotType == PlotType.Kalpa).ToArray();
                        if (plotInfoList.Length > 0)
                        {
                            ContextUser.UserExtend.UpdateNotify(obj =>
                            {
                                ContextUser.UserExtend.LayerNum  = nextLayerNum;
                                ContextUser.UserExtend.HurdleNum = 1;
                                return(true);
                            });
                            //ContextUser.Update();
                            PlotHelper.EnablePlot(ContextUser.UserID, plotInfo.AftPlotID);
                        }
                    }
                }
            }


            //日志
            UserCombatLog log = new UserCombatLog();

            log.CombatLogID   = Guid.NewGuid().ToString();
            log.UserID        = userPlotCombat.UserID;
            log.CityID        = ContextUser.CityID;
            log.PlotID        = userPlotCombat.PlotID;
            log.NpcID         = userPlotCombat.PlotNpcID;
            log.CombatType    = CombatType.Kalpa;
            log.HostileUser   = string.Empty;
            log.IsWin         = userPlotCombat.IsWin;
            log.CombatProcess = JsonUtils.Serialize(combatProcessList);
            log.PrizeItem     = prizeItems;
            log.CreateDate    = DateTime.Now;
            var sender = DataSyncManager.GetDataSender();

            sender.Send(log);

            UserHelper.GetGeneralLife(ContextUser.UserID);

            return(true);
        }