Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 触发战斗
        /// </summary>
        /// <param name="user"></param>
        /// <param name="bossCombatProcess"></param>
        /// <returns></returns>
        public bool Combat(GameUser user, BossCombatProcess bossCombatProcess)
        {
            CombatGeneral bossGeneral = Boss;

            bossGeneral.LossLifeNum = 0;
            bool     isWin    = false;
            BossUser bossUser = GetCombatUser(user.UserID);

            ICombatController controller     = CombatControllerFactory.Create();
            ISingleCombat     plotCombater   = controller.GetSingleCombat(CombatType.BossPlot);
            double            inspirePercent = bossUser.InspirePercent + bossUser.ReliveInspirePercent;

            plotCombater.SetAttack(new UserEmbattleQueue(user.UserID, user.UseMagicID, inspirePercent,
                                                         CombatType.BossPlot));
            plotCombater.SetDefend(new MonsterQueue(bossGeneral));

            isWin = plotCombater.Doing();
            bossCombatProcess.ProcessContainer = (CombatProcessContainer)plotCombater.GetProcessResult();
            bossUser.CombatNum         += 1;
            bossUser.DamageNum          = MathUtils.Addition(bossUser.DamageNum, bossGeneral.LossLifeNum, int.MaxValue);
            bossCombatProcess.LiveNum   = bossGeneral.LifeNum;
            bossCombatProcess.DamageNum = bossGeneral.LossLifeNum;
            bossCombatProcess.IsWin     = isWin;
            bossCombatProcess.UserId    = user.UserID;

            DoDamagePrize(user, bossGeneral.LossLifeNum, bossCombatProcess);
            if (isWin && bossGeneral.IsOver)
            {
                //GameActive active = GameActive;
                UserGuild guild        = UserGuild;
                short     bossprizeLv  = 0;
                int       killbossrate = 0;
                if (guild.BossPrize != null)
                {
                    bossprizeLv  = (short)guild.BossPrize.KillBossLv;
                    killbossrate = guild.BossPrize.KillBossRate;
                    //击杀奖
                    BossActivePrize bossPrize    = UserGuild.BossPrize;
                    string          prizeItemMsg = string.Empty;
                    DoTopThreePrize(0, user, bossPrize.KillReward, bossPrize.Items, out prizeItemMsg);
                }

                short lv       = MathUtils.Subtraction(bossGeneral.Lv, bossprizeLv, (short)1);
                int   killCoin = lv * killbossrate;
                user.GameCoin = MathUtils.Addition(user.GameCoin, killCoin, int.MaxValue);
                // new CacheChat().SystemSend(ChatType.World, string.Format("{0}玩家获得公会Boss战击杀奖,奖励{1}金币", user.NickName, killCoin));
                new TjxChatService(user).SystemGuildSend(ChatType.Guild,
                                                         string.Format(LanguageManager.GetLang().St6105_CombatKillReward, user.NickName, killCoin));
                bossCombatProcess.KillGameCoin = killCoin;

                DoKillPrize();


                int tempMinute = gameActive.Minutes - ConfigEnvSet.GetInt("BossCombat.KillTime");
                int subSeconds = (int)new TimeSpan(0, tempMinute, 0).TotalSeconds;
                if (subSeconds - guild.ColdTime < 0)
                {
                    //Boss自动升级
                    guild.GuildBossInfo.UpdateNotify(obj =>
                    {
                        guild.GuildBossInfo.BossLv = MathUtils.Addition(guild.GuildBossInfo.BossLv, (short)1, short.MaxValue);
                        return(true);
                    });
                    //guild.Update();
                }
                guild.CombatStatus = CombatStatus.Killed;
                CombatHelper.UpdateGuildBossKill(guild.GuildID); //公会boss已被杀
            }
            else
            {
                bossUser.IsRelive        = true;
                bossUser.ReliveBeginDate = DateTime.Now;
            }
            //日志
            var log = new UserCombatLog
            {
                CombatLogID   = Guid.NewGuid().ToString(),
                UserID        = user.UserID,
                CityID        = user.CityID,
                PlotID        = gameActive == null ? 0 : gameActive.BossPlotID,
                NpcID         = bossGeneral.GeneralID,
                CombatType    = CombatType.BossPlot,
                HostileUser   = string.Empty,
                IsWin         = isWin,
                CombatProcess = JsonUtils.Serialize(bossCombatProcess),
                CreateDate    = DateTime.Now
            };

            var sender = DataSyncManager.GetDataSender();

            sender.Send(log);

            //user.Update();

            return(isWin);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 触发战斗
        /// </summary>
        /// <param name="user"></param>
        /// <param name="bossCombatProcess"></param>
        /// <returns></returns>
        public bool Combat(GameUser user, BossCombatProcess bossCombatProcess)
        {
            CombatGeneral bossGeneral = Boss;

            bossGeneral.LossLifeNum = 0;

            BossUser          bossUser       = GetCombatUser(user.UserID);
            ICombatController controller     = CombatControllerFactory.Create();
            ISingleCombat     plotCombater   = controller.GetSingleCombat(CombatType.BossPlot);
            double            inspirePercent = bossUser.InspirePercent + bossUser.ReliveInspirePercent;

            plotCombater.SetAttack(new UserEmbattleQueue(user.UserID, user.UseMagicID, inspirePercent, CombatType.BossPlot));
            plotCombater.SetDefend(new MonsterQueue(Boss));

            bool isWin = plotCombater.Doing();

            bossCombatProcess.ProcessContainer = (CombatProcessContainer)plotCombater.GetProcessResult();
            bossUser.CombatNum         += 1;
            bossUser.DamageNum          = MathUtils.Addition(bossUser.DamageNum, bossGeneral.LossLifeNum, int.MaxValue);
            bossCombatProcess.LiveNum   = bossGeneral.LifeNum;
            bossCombatProcess.DamageNum = bossGeneral.LossLifeNum;
            bossCombatProcess.IsWin     = isWin;
            bossCombatProcess.UserId    = user.UserID;

            DoDamagePrize(user, bossGeneral.LossLifeNum, bossCombatProcess);
            if (isWin && bossGeneral.IsOver)
            {
                GameActive active   = GameActive;
                short      lv       = MathUtils.Subtraction(bossGeneral.Lv, (short)active.BossPrize.KillBossLv, (short)1);
                int        killCoin = lv * active.BossPrize.KillBossRate;
                user.GameCoin = MathUtils.Addition(user.GameCoin, killCoin, int.MaxValue);

                new TjxChatService().SystemSend(ChatType.World, string.Format(LanguageManager.GetLang().St5405_CombatKillReward, user.NickName, killCoin));
                TraceLog.ReleaseWriteDebug(string.Format(LanguageManager.GetLang().St5405_CombatKillReward, user.NickName, killCoin));
                bossCombatProcess.KillGameCoin = killCoin;

                ServerEnvSet.Set(ServerEnvKey.KillBossUserID, user.UserID);
                DoKillPrize(user);

                int tempMinute = active.Minutes - ConfigEnvSet.GetInt("BossCombat.KillTime");
                if (new TimeSpan(0, tempMinute, 0).TotalSeconds - active.ColdTime < 0)
                {
                    //Boss自动升级
                    active.BossLv = MathUtils.Addition(active.BossLv, (short)1);
                    //active.Update();
                }
                active.CombatStatus = CombatStatus.Killed;
                CombatHelper.BossKillDate(); //增加boss被杀时间
            }
            else
            {
                bossUser.IsRelive        = true;
                bossUser.ReliveBeginDate = DateTime.Now;
            }
            //日志
            var log = new UserCombatLog
            {
                CombatLogID   = Guid.NewGuid().ToString(),
                UserID        = user.UserID,
                CityID        = user.CityID,
                PlotID        = GameActive == null ? 0 : GameActive.BossPlotID,
                NpcID         = bossGeneral.GeneralID,
                CombatType    = CombatType.BossPlot,
                HostileUser   = string.Empty,
                IsWin         = isWin,
                CombatProcess = JsonUtils.Serialize(bossCombatProcess),
                CreateDate    = DateTime.Now
            };
            var sender = DataSyncManager.GetDataSender();

            sender.Send(log);

            //user.Update();

            return(isWin);
        }