public void NotifyTimeStateInfoAndScoreInfo(GameClient client, bool timeState = true, bool sideScore = true, bool selfScore = true) { lock (RuntimeData.Mutex) { KingOfBattleScene scene; if (SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene)) { if (timeState) { client.sendCmd((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData); } if (sideScore) { client.sendCmd((int)TCPGameServerCmds.CMD_SPR_KINGOFBATTLE_SIDE_SCORE, scene.ScoreData); } if (selfScore) { KingOfBattleClientContextData clientContextData = client.SceneContextData2 as KingOfBattleClientContextData; if (null != clientContextData) { client.sendCmd((int)TCPGameServerCmds.CMD_SPR_KINGOFBATTLE_SELF_SCORE, clientContextData.TotalScore); } } } } }
/// <summary> /// 提交采集BUFF /// </summary> public void SubmitCrystalBuff(GameClient client, int areaLuaID) { if (areaLuaID != client.ClientData.BattleWhichSide) { return; } BattleCrystalMonsterItem crystalItem = client.SceneContextData as BattleCrystalMonsterItem; if (null == crystalItem) { return; } lock (RuntimeData.Mutex) { KingOfBattleScene scene; if (!SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene)) { return; } // 加分 KingOfBattleClientContextData contextData = client.SceneContextData2 as KingOfBattleClientContextData; if (null != contextData && scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN) { int addScore = 0; addScore = crystalItem.BattleJiFen; contextData.TotalScore += addScore; scene.GameStatisticalData.CaiJiScore += addScore; if (client.ClientData.BattleWhichSide == 1) { scene.ScoreData.Score1 += addScore; } else if (client.ClientData.BattleWhichSide == 2) { scene.ScoreData.Score2 += addScore; } if (addScore > 0) { GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_KINGOFBATTLE_SIDE_SCORE, scene.ScoreData, scene.CopyMap); NotifyTimeStateInfoAndScoreInfo(client, false, false, true); } } // 清除Buff UpdateBuff4GameClient(client, crystalItem.BuffGoodsID, crystalItem, false); // 水晶复活 AddDelayCreateMonster(scene, TimeUtil.NOW() + crystalItem.FuHuoTime, crystalItem); } }
public void OnKillRole(GameClient client, GameClient other) { lock (RuntimeData.Mutex) { KingOfBattleScene scene; if (SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene)) { if (scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN) { int addScore = 0; int addScoreDie = RuntimeData.KingOfBattleDie; KingOfBattleClientContextData clientLianShaContextData = client.SceneContextData2 as KingOfBattleClientContextData; KingOfBattleClientContextData otherLianShaContextData = other.SceneContextData2 as KingOfBattleClientContextData; HuanYingSiYuanLianSha huanYingSiYuanLianSha = null; HuanYingSiYuanLianshaOver huanYingSiYuanLianshaOver = null; HuanYingSiYuanAddScore huanYingSiYuanAddScore = new HuanYingSiYuanAddScore(); huanYingSiYuanAddScore.Name = Global.FormatRoleName4(client); huanYingSiYuanAddScore.ZoneID = client.ClientData.ZoneID; huanYingSiYuanAddScore.Side = client.ClientData.BattleWhichSide; huanYingSiYuanAddScore.ByLianShaNum = 1; huanYingSiYuanAddScore.RoleId = client.ClientData.RoleID; huanYingSiYuanAddScore.Occupation = client.ClientData.Occupation; //addScore += RuntimeData.WarriorBattlePk; // scene.GameStatisticalData.KillScore += RuntimeData.KingOfBattleUltraKillParam1; if (null != clientLianShaContextData) { clientLianShaContextData.KillNum++; int lianShaScore = RuntimeData.KingOfBattleUltraKillParam1 + clientLianShaContextData.KillNum * RuntimeData.KingOfBattleUltraKillParam2; lianShaScore = Math.Min(RuntimeData.KingOfBattleUltraKillParam4, Math.Max(RuntimeData.KingOfBattleUltraKillParam3, lianShaScore)); huanYingSiYuanAddScore.ByLianShaNum = 1; huanYingSiYuanLianSha = new HuanYingSiYuanLianSha(); huanYingSiYuanLianSha.Name = huanYingSiYuanAddScore.Name; huanYingSiYuanLianSha.ZoneID = huanYingSiYuanAddScore.ZoneID; huanYingSiYuanLianSha.Occupation = huanYingSiYuanAddScore.Occupation; // 每杀5人,连杀公告就更暴力,所以除以5,计算属于哪个连杀类型,最大为30 / 5 huanYingSiYuanLianSha.LianShaType = Math.Min(clientLianShaContextData.KillNum, 30) / 5; huanYingSiYuanLianSha.ExtScore = lianShaScore; huanYingSiYuanLianSha.Side = huanYingSiYuanAddScore.Side; addScore += lianShaScore; scene.GameStatisticalData.LianShaScore += lianShaScore; //只在连杀数为5的倍数时推送消息 if ((clientLianShaContextData.KillNum % 5) != 0) { huanYingSiYuanLianSha = null; } } if (null != otherLianShaContextData) { int overScore = RuntimeData.KingOfBattleShutDownParam1 + otherLianShaContextData.KillNum * RuntimeData.KingOfBattleShutDownParam2; overScore = Math.Min(RuntimeData.KingOfBattleShutDownParam4, Math.Max(RuntimeData.KingOfBattleShutDownParam3, overScore)); addScore += overScore; scene.GameStatisticalData.ZhongJieScore += overScore; if (otherLianShaContextData.KillNum >= 10) { huanYingSiYuanLianshaOver = new HuanYingSiYuanLianshaOver(); huanYingSiYuanLianshaOver.KillerName = huanYingSiYuanAddScore.Name; huanYingSiYuanLianshaOver.KillerZoneID = huanYingSiYuanAddScore.ZoneID; huanYingSiYuanLianshaOver.KillerOccupation = client.ClientData.Occupation; huanYingSiYuanLianshaOver.KillerSide = huanYingSiYuanAddScore.Side; huanYingSiYuanLianshaOver.KilledName = Global.FormatRoleName4(other); huanYingSiYuanLianshaOver.KilledZoneID = other.ClientData.ZoneID; huanYingSiYuanLianshaOver.KilledOccupation = other.ClientData.Occupation; huanYingSiYuanLianshaOver.KilledSide = other.ClientData.BattleWhichSide; huanYingSiYuanLianshaOver.ExtScore = overScore; } otherLianShaContextData.KillNum = 0; otherLianShaContextData.TotalScore += addScoreDie; scene.GameStatisticalData.KillScore += addScoreDie; } huanYingSiYuanAddScore.Score = addScore; if (client.ClientData.BattleWhichSide == 1) { scene.ScoreData.Score1 += addScore; scene.ScoreData.Score2 += addScoreDie; } else { scene.ScoreData.Score2 += addScore; scene.ScoreData.Score1 += addScoreDie; } if (null != clientLianShaContextData) { clientLianShaContextData.TotalScore += addScore; } //GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_HYSY_ADD_SCORE, huanYingSiYuanAddScore, huanYingSiYuanScene.CopyMap); GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_KINGOFBATTLE_SIDE_SCORE, scene.ScoreData, scene.CopyMap); if (null != huanYingSiYuanLianSha) { GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_KINGOFBATTLE_LIANSHA, huanYingSiYuanLianSha, scene.CopyMap); } if (null != huanYingSiYuanLianshaOver) { GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_KINGOFBATTLE_STOP_LIANSHA, huanYingSiYuanLianshaOver, scene.CopyMap); } NotifyTimeStateInfoAndScoreInfo(client, false, false, true); NotifyTimeStateInfoAndScoreInfo(other, false, false, true); } } } }
/// <summary> /// 添加一个场景 /// </summary> public bool AddCopyScenes(GameClient client, CopyMap copyMap, SceneUIClasses sceneType) { if (sceneType == SceneUIClasses.KingOfBattle) { GameMap gameMap = null; if (!GameManager.MapMgr.DictMaps.TryGetValue(client.ClientData.MapCode, out gameMap)) { return(false); } int fuBenSeqId = copyMap.FuBenSeqID; int mapCode = copyMap.MapCode; int roleId = client.ClientData.RoleID; int gameId = (int)Global.GetClientKuaFuServerLoginData(client).GameId; DateTime now = TimeUtil.NowDateTime(); lock (RuntimeData.Mutex) { KingOfBattleScene scene = null; if (!SceneDict.TryGetValue(fuBenSeqId, out scene)) { KingOfBattleSceneInfo sceneInfo = null; YongZheZhanChangFuBenData fuBenData; if (!RuntimeData.FuBenItemData.TryGetValue(gameId, out fuBenData)) { LogManager.WriteLog(LogTypes.Error, "王者战场没有为副本找到对应的跨服副本数据,GameID:" + gameId); } if (!RuntimeData.SceneDataDict.TryGetValue(fuBenData.GroupIndex, out sceneInfo)) { LogManager.WriteLog(LogTypes.Error, "王者战场没有为副本找到对应的档位数据,ID:" + fuBenData.GroupIndex); } scene = new KingOfBattleScene(); scene.CopyMap = copyMap; scene.CleanAllInfo(); scene.GameId = gameId; scene.m_nMapCode = mapCode; scene.CopyMapId = copyMap.CopyMapID; scene.FuBenSeqId = fuBenSeqId; scene.m_nPlarerCount = 1; scene.SceneInfo = sceneInfo; scene.MapGridWidth = gameMap.MapGridWidth; scene.MapGridHeight = gameMap.MapGridHeight; DateTime startTime = now.Date.Add(GetStartTime(sceneInfo.Id)); scene.StartTimeTicks = startTime.Ticks / 10000; InitScene(scene, client); scene.GameStatisticalData.GameId = gameId; SceneDict[fuBenSeqId] = scene; } else { scene.m_nPlarerCount++; } KingOfBattleClientContextData clientContextData; if (!scene.ClientContextDataDict.TryGetValue(roleId, out clientContextData)) { clientContextData = new KingOfBattleClientContextData() { RoleId = roleId, ServerId = client.ServerId, BattleWhichSide = client.ClientData.BattleWhichSide }; scene.ClientContextDataDict[roleId] = clientContextData; } else { clientContextData.KillNum = 0; } client.SceneObject = scene; client.SceneGameId = scene.GameId; client.SceneContextData2 = clientContextData; copyMap.IsKuaFuCopy = true; copyMap.SetRemoveTicks(TimeUtil.NOW() + scene.SceneInfo.TotalSecs * TimeUtil.SECOND); } //更新状态 YongZheZhanChangClient.getInstance().GameFuBenRoleChangeState(roleId, (int)KuaFuRoleStates.StartGame); return(true); } return(false); }
/// <summary> /// 伤害或击杀Boss的处理 /// </summary> /// <param name="client"></param> /// <param name="monster"></param> /// <param name="injure"></param> public void OnInjureMonster(GameClient client, Monster monster, long injure) { if (monster.MonsterType != (int)MonsterTypes.BOSS /*&& monster.MonsterType != (int)MonsterTypes.XianFactionGuard * && monster.MonsterType != (int)MonsterTypes.MoFactionGuard && monster.MonsterType != (int)MonsterTypes.CampNoAttack*/) { return; } KingOfBattleClientContextData contextData = client.SceneContextData2 as KingOfBattleClientContextData; if (null == contextData) { return; } KingOfBattleDynamicMonsterItem tagInfo = monster.Tag as KingOfBattleDynamicMonsterItem; if (null == tagInfo) { return; } KingOfBattleScene scene = null; int addScore = 0; if (monster.HandledDead && monster.WhoKillMeID == client.ClientData.RoleID) { addScore += tagInfo.JiFenKill; } #if ___CC___FUCK___YOU___BB___ double jiFenInjure = RuntimeData.KingBattleBossAttackPercent * monster.XMonsterInfo.MaxHP; #else double jiFenInjure = RuntimeData.KingBattleBossAttackPercent * monster.MonsterInfo.VLifeMax; #endif lock (RuntimeData.Mutex) { if (SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene)) { if (scene.m_eStatus != GameSceneStatuses.STATUS_BEGIN) { return; } double InjureBossDelta = 0.0d; #if ___CC___FUCK___YOU___BB___ contextData.InjureBossDeltaDict.TryGetValue(monster.XMonsterInfo.MonsterId, out InjureBossDelta); #else contextData.InjureBossDeltaDict.TryGetValue(monster.MonsterInfo.ExtensionID, out InjureBossDelta); #endif InjureBossDelta += injure; if (InjureBossDelta >= jiFenInjure && jiFenInjure > 0.0) { // 求出达成的伤害倍数 int calcRate = (int)(InjureBossDelta / jiFenInjure); InjureBossDelta -= jiFenInjure * calcRate; addScore += tagInfo.JiFenDamage * calcRate; } #if ___CC___FUCK___YOU___BB___ contextData.InjureBossDeltaDict[monster.XMonsterInfo.MonsterId] = InjureBossDelta; #else contextData.InjureBossDeltaDict[monster.MonsterInfo.ExtensionID] = InjureBossDelta; #endif contextData.TotalScore += addScore; // 处理Boss死亡重生 if (monster.HandledDead) { KingOfBattleDynamicMonsterItem RebornItem = null; if (tagInfo.RebornID != -1 && RuntimeData.DynMonsterDict.TryGetValue(tagInfo.RebornID, out RebornItem)) { long ticks = TimeUtil.NOW(); AddDelayCreateMonster(scene, ticks + RebornItem.DelayBirthMs, RebornItem); } // Buff TryAddBossKillRandomBuff(client, tagInfo); } // 积分 if (client.ClientData.BattleWhichSide == 1) { scene.ScoreData.Score1 += addScore; } else if (client.ClientData.BattleWhichSide == 2) { scene.ScoreData.Score2 += addScore; } scene.GameStatisticalData.BossScore += addScore; } } if (addScore > 0 && scene != null) { GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_KINGOFBATTLE_SIDE_SCORE, scene.ScoreData, scene.CopyMap); NotifyTimeStateInfoAndScoreInfo(client, false, false, true); } }