Beispiel #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));
        }
Beispiel #2
0
        /// <summary>
        /// 处理击杀奖励
        /// </summary>
        private void DoKillPrize(GameUser user)
        {
            BossActivePrize bossPrize = GameActive.BossPrize;

            if (bossPrize == null)
            {
                return;
            }
            TjxChatService chatService = new TjxChatService();

            var rankingList = RefreshRanking();

            ServerEnvSet.Set(ServerEnvKey.FirstHalfBoss, rankingList.ToJson());
            int length = rankingList.Count > bossPrize.TopObtain ? bossPrize.TopObtain : rankingList.Count;

            //处理排名奖励
            for (int i = 0; i < length; i++)
            {
                string   prizeItemMsg = string.Empty;
                GameUser tempUser     = new GameDataCacheSet <GameUser>().FindKey(rankingList[i].UserId);
                tempUser.GameCoin = MathUtils.Addition(tempUser.GameCoin, bossPrize.TopObtainNum, int.MaxValue);
                //前3名奖励
                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);
                }
                //tempUser.Update();

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

                chatService.SystemSend(ChatType.World, string.Format(LanguageManager.GetLang().St5405_CombatRankmReward,
                                                                     tempUser.NickName,
                                                                     (i + 1),
                                                                     bossPrize.TopObtainNum,
                                                                     prizeItemMsg));
                TraceLog.ReleaseWriteDebug(string.Format(LanguageManager.GetLang().St5405_CombatRankmReward,
                                                         tempUser.NickName,
                                                         (i + 1),
                                                         bossPrize.TopObtainNum,
                                                         prizeItemMsg));
                // CountryCombat.Contribution(tempUser.UserID, bossPrize.TopObtainNum); //公会贡献
            }
        }
Beispiel #3
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); //公会贡献
            }
        }
Beispiel #4
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);
        }