Exemple #1
0
        /// <summary>
        /// 处理伤害奖励
        /// </summary>
        private void DoDamagePrize(GameUser user, int damageNum, BossCombatProcess bossCombatProcess)
        {
            BossActivePrize bossPrize = UserGuild.BossPrize;

            if (bossPrize == null)
            {
                return;
            }
            int obtainNum = MathUtils.Addition(((int)Math.Ceiling((double)damageNum / bossPrize.ObtainRate)), 0, bossPrize.MaxObtain);
            int maxCoin   = user.UserLv * bossPrize.MaxCoin;
            int gameCoin  = MathUtils.Addition((int)Math.Ceiling((double)damageNum / bossPrize.CoinRate), 0, maxCoin);

            user.ObtainNum = MathUtils.Addition(user.ObtainNum, obtainNum, int.MaxValue);
            user.GameCoin  = MathUtils.Addition(user.GameCoin, gameCoin, int.MaxValue);
            if (gameCoin <= 0)
            {
                gameCoin = 1;
            }
            if (obtainNum <= 0)
            {
                obtainNum = 1;
            }
            bossCombatProcess.ObtainNum = obtainNum;
            bossCombatProcess.GameCoin  = gameCoin;
            CountryCombat.Contribution(user.UserID, obtainNum); //公会贡献

            //发到聊天里
            var chatService = new TjxChatService();

            chatService.SystemSendWhisper(user, string.Format(LanguageManager.GetLang().St6105_CombatHarmReward, gameCoin, obtainNum));
        }
Exemple #2
0
 public override bool TakeAction()
 {
     CountryCombat countryCombat = new CountryCombat(ContextUser);
     _countryUserList = countryCombat.GetCountryUser(_countryID, _lv);
     _countryUserList = _countryUserList.GetPaging(_pageIndex, _pageSize, out _pageCount);
     return true;
 }
Exemple #3
0
        public override bool TakeAction()
        {
            CountryCombat countryCombat = new CountryCombat(ContextUser);
            if (countryCombat.GameActive == null || countryCombat.GameActive.RefreshStatus() == CombatStatus.NoStart)
            {
                if (ContextUser.UserStatus == UserStatus.CountryCombat)
                {
                    ContextUser.UserStatus = UserStatus.Normal;
                    //ContextUser.Update();
                }
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St5201_CombatNoStart;
                return false;
            }
            if (countryCombat.GameActive == null || countryCombat.GameActive.RefreshStatus() == CombatStatus.Over)
            {
                if (ContextUser.UserStatus == UserStatus.CountryCombat)
                {
                    ContextUser.UserStatus = UserStatus.Normal;
                    //ContextUser.Update();
                }
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St5201_CombatOver;
                return false;
            }
            if (UserHelper.IsUserEmbattle(ContextUser.UserID, ContextUser.UseMagicID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4004_EmbattleEmpty;
                return false;
            }
            countryCombat.JoinCombat();

            return true;
        }
Exemple #4
0
 private static void DisposeData(GameActive gameActive)
 {
     if (gameActive.LoadSuccess)
     {
         gameActive.LoadSuccess = false;
         if (gameActive.ActiveType == FunctionEnum.Booszhang)
         {
             BossCombat.Dispose(gameActive);
         }
         else if (gameActive.ActiveType == FunctionEnum.Lintuzhang)
         {
             CountryCombat.Dispose(gameActive);
         }
         else if (gameActive.ActiveType == FunctionEnum.Multiplot)
         {
             PlotTeamCombat.Dispose(gameActive);
         }
         else if (gameActive.ActiveType == FunctionEnum.MorePlotCoin)
         {
             PlotTeamCombat.Dispose(gameActive);
         }
         else if (gameActive.ActiveType == FunctionEnum.MorePlotEnergy)
         {
             PlotTeamCombat.Dispose(gameActive);
         }
     }
 }
Exemple #5
0
 public override bool TakeAction()
 {
     this.ErrorCode = ops;
     CountryCombat countryCombat = new CountryCombat(ContextUser);
     if (ops == 1)
     {
         this.ErrorInfo = string.Format(LanguageManager.GetLang().St5202_InspireTip, ExpNum);
     }
     else if (ops == 2)
     {
         if (ContextUser.ExpNum < ExpNum)
         {
             this.ErrorCode = LanguageManager.GetLang().ErrorCode;
             this.ErrorInfo = LanguageManager.GetLang().St_ExpNumNotEnough;
             return false;
         }
         if (!countryCombat.Inspire(false, out inspirePercent))
         {
             this.ErrorCode = LanguageManager.GetLang().ErrorCode;
             this.ErrorInfo = LanguageManager.GetLang().St_InspireFailed;
         }
         ContextUser.ExpNum = MathUtils.Subtraction(ContextUser.ExpNum, ExpNum, 0);
         //ContextUser.Update();
     }
     else if (ops == 3)
     {
         if (ContextUser.GoldNum < GlodNum)
         {
             this.ErrorCode = LanguageManager.GetLang().ErrorCode;
             this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
             return false;
         }
         this.ErrorInfo = string.Format(LanguageManager.GetLang().St5202_InspireGoldTip, GlodNum);
     }
     else if (ops == 4)
     {
         if (ContextUser.VipLv < CountryCombat.CombatInspireVipLv)
         {
             this.ErrorCode = LanguageManager.GetLang().ErrorCode;
             this.ErrorInfo = LanguageManager.GetLang().St_VipNotEnough;
             return false;
         }
         if (ContextUser.GoldNum < GlodNum)
         {
             this.ErrorCode = LanguageManager.GetLang().ErrorCode;
             this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
             return false;
         }
         if (!countryCombat.Inspire(true, out inspirePercent))
         {
             this.ErrorCode = LanguageManager.GetLang().ErrorCode;
             this.ErrorInfo = LanguageManager.GetLang().St_InspireFailed;
         }
         ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, GlodNum, int.MaxValue);
         //ContextUser.Update();
     }
     return true;
 }
Exemple #6
0
        public override bool TakeAction()
        {
            if (ContextUser.CountryID == CountryType.None)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St5201_NoJoinCountry;
                return false;
            }
            CountryCombat countryCombat = new CountryCombat(ContextUser);
            if (countryCombat.GameActive == null ||
                countryCombat.GameActive.RefreshStatus() == CombatStatus.NoStart ||
                countryCombat.GameActive.RefreshStatus() == CombatStatus.Over)
            {
                if (ContextUser.UserStatus == UserStatus.CountryCombat)
                {
                    ContextUser.UserStatus = UserStatus.Normal;
                    //ContextUser.Update();
                }
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St5201_CombatNoStart;
                return false;
            }
            //wuzf 检查战斗状态
            if (ContextUser.UserStatus != UserStatus.CountryCombat || UserHelper.IsUserEmbattle(ContextUser.UserID, ContextUser.UseMagicID))
            {
                countryCombat.Exit();
                //ErrorCode = LanguageManager.GetLang().ErrorCode;
                //ErrorInfo = LanguageManager.GetLang().St5201_NoJoinCountry;
                //return false;
            }

            if (ops == 1)
            {
                processList = countryCombat.GetCombatProcess(true);
            }
            else if (ops == 2)
            {
                processList = countryCombat.GetCombatProcess(false);
            }
            coldTime = countryCombat.GameActive.ColdTime;
            countryUser = countryCombat.GetCountryUser();
            firstUser = CountryCombat.FistCountryUser ?? new CountryUser();
            CountryGroup mogemaGroup;
            CountryGroup hashideGroup;
            if (CountryCombat.TryGroup(CountryType.M, out mogemaGroup) && CountryCombat.TryGroup(CountryType.H, out hashideGroup))
            {
                _mscoreNum = mogemaGroup.Score;
                _hscoreNum = hashideGroup.Score;
            }
            if (coldTime == 0)
            {

            }
            return true;
        }
Exemple #7
0
        private static void LoadData(GameActive gameActive)
        {
            if ((gameActive.CombatStatus == CombatStatus.Wait || gameActive.CombatStatus == CombatStatus.Combat) && !gameActive.LoadSuccess)
            {
                if (!string.IsNullOrEmpty(gameActive.Broadcast))
                {
                    var broadcastService = new TjxBroadcastService(null);
                    var msg = broadcastService.Create(NoticeType.Game, gameActive.Broadcast);

                    if (gameActive.ActiveId == 11)
                    {
                        int    invertal  = (int)new TimeSpan(0, 0, gameActive.WaitMinutes, 0).TotalSeconds / 5;
                        string startTime = DateTime.Now.ToString("HH:mm:ss");
                        string endTime   = DateTime.Now.AddMinutes(gameActive.WaitMinutes).ToString("HH:mm:ss");
                        broadcastService.SendTimer(msg, startTime, endTime, true, invertal);//秒
                    }
                    else
                    {
                        broadcastService.Send(msg);
                    }
                }
                gameActive.LoadSuccess = true;
                if (gameActive.ActiveType == FunctionEnum.Booszhang)
                {
                    BossCombat.InitBoss(gameActive);
                }
                else if (gameActive.ActiveType == FunctionEnum.Lintuzhang)
                {
                    CountryCombat.Init(gameActive);
                }
                else if (gameActive.ActiveType == FunctionEnum.Multiplot)
                {
                    PlotTeamCombat.Init(gameActive);
                }
                else if (gameActive.ActiveType == FunctionEnum.MorePlotCoin)
                {
                    PlotTeamCombat.Init(gameActive);
                }
                else if (gameActive.ActiveType == FunctionEnum.MorePlotEnergy)
                {
                    PlotTeamCombat.Init(gameActive);
                }
            }
        }
Exemple #8
0
 public override bool TakeAction()
 {
     CountryCombat countryCombat = new CountryCombat(ContextUser);
     countryCombat.Exit();
     return true;
 }
Exemple #9
0
        /// <summary>
        /// 处理击杀奖励
        /// </summary>
        private void DoKillPrize()
        {
            BossActivePrize bossPrize = UserGuild.BossPrize;

            if (bossPrize == null)
            {
                return;
            }
            //CacheChat cacheChat = new CacheChat();

            var rankingList = RefreshRanking();
            int length      = rankingList.Count > bossPrize.TopObtain ? bossPrize.TopObtain : rankingList.Count;
            int afterLength = rankingList.Count > bossPrize.AfterObtain ? bossPrize.AfterObtain : rankingList.Count;

            //处理排名奖励
            for (int i = 0; i < length; i++)
            {
                string   prizeItemMsg = string.Empty;
                GameUser tempUser     = new GameDataCacheSet <GameUser>().FindKey(rankingList[i].UserId);
                tempUser.ObtainNum = MathUtils.Addition(tempUser.ObtainNum, bossPrize.TopObtainNum, int.MaxValue);
                //前5名奖励
                if (i == 0)
                {
                    DoTopThreePrize(i + 1, tempUser, bossPrize.Rank1, bossPrize.Items, out prizeItemMsg);
                }
                else if (i == 1)
                {
                    DoTopThreePrize(i + 1, tempUser, bossPrize.Rank2, bossPrize.Items, out prizeItemMsg);
                }
                else if (i == 2)
                {
                    DoTopThreePrize(i + 1, tempUser, bossPrize.Rank3, bossPrize.Items, out prizeItemMsg);
                }
                else if (i == 3)
                {
                    DoTopThreePrize(i + 1, tempUser, bossPrize.Rank4, bossPrize.Items, out prizeItemMsg);
                }
                else if (i == 4)
                {
                    DoTopThreePrize(i + 1, tempUser, bossPrize.Rank5, bossPrize.Items, out prizeItemMsg);
                }
                //tempUser.Update();

                if (!string.IsNullOrEmpty(prizeItemMsg))
                {
                    prizeItemMsg = "," + prizeItemMsg;
                }

                new TjxChatService(tempUser).SystemGuildSend(ChatType.Guild, string.Format(LanguageManager.GetLang().St6105_CombatRankmReward,
                                                                                           tempUser.NickName,
                                                                                           (i + 1),
                                                                                           bossPrize.TopObtainNum,
                                                                                           prizeItemMsg));

                CountryCombat.Contribution(tempUser.UserID, bossPrize.TopObtainNum); //公会贡献
            }
            //后5名玩家奖励
            for (int i = length; i < afterLength; i++)
            {
                string   prizeItemMsg = string.Empty;
                GameUser tempUser     = new GameDataCacheSet <GameUser>().FindKey(rankingList[i].UserId);
                tempUser.ObtainNum = MathUtils.Addition(tempUser.ObtainNum, bossPrize.AfterObtainNum, int.MaxValue);
                //tempUser.Update();

                if (!string.IsNullOrEmpty(prizeItemMsg))
                {
                    prizeItemMsg = "," + prizeItemMsg;
                }

                new TjxChatService(tempUser).SystemGuildSend(ChatType.Guild, string.Format(LanguageManager.GetLang().St6105_CombatRankmReward,
                                                                                           tempUser.NickName,
                                                                                           (i + 1),
                                                                                           bossPrize.AfterObtainNum,
                                                                                           prizeItemMsg));

                CountryCombat.Contribution(tempUser.UserID, bossPrize.AfterObtainNum); //公会贡献
            }
        }
Exemple #10
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 ConfigCacheSet<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 GameDataCacheSet<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 ConfigCacheSet<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;
        }