public static void OnCreateTeamCopyRoleLog(GameClient client) { try { if (ZhuanShengShiLian.IsZhuanShengShiLianCopyScene(client.ClientData.MapCode)) { ZSSLScene mapInfo; if (ZhuanShengShiLian.SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out mapInfo)) { lock (ZhuanShengShiLian.ZhuanShengRunTimeData.Mutex) { BossAttackLog bossAttackLog = mapInfo.AttackLog; if (null != bossAttackLog) { long tID_Role = ZhuanShengShiLian.GetGUID(0, client.ClientData.RoleID); long tID_Team = ZhuanShengShiLian.GetGUID(client.ClientData.TeamID, client.ClientData.RoleID); BHAttackLog tAttackLog_Role = null; if (bossAttackLog.BHInjure.TryGetValue(tID_Role, out tAttackLog_Role)) { bossAttackLog.BHInjure.Remove(tID_Role); } if (null != tAttackLog_Role) { bossAttackLog.BHInjure[tID_Team] = tAttackLog_Role; } } } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, string.Format("ZhuanShengShiLian :: 处理拷贝角色伤害记录异常。", new object[0]), ex, true); } }
public static int CheckInviteOrApplyTeam(GameClient client, GameClient otherClient) { int result; if (!ZhuanShengShiLian.IsZhuanShengShiLianCopyScene(client.ClientData.MapCode) && !ZhuanShengShiLian.IsZhuanShengShiLianCopyScene(otherClient.ClientData.MapCode)) { result = 0; } else if (ZhuanShengShiLian.IsZhuanShengShiLianCopyScene(client.ClientData.MapCode) && !ZhuanShengShiLian.IsZhuanShengShiLianCopyScene(otherClient.ClientData.MapCode)) { result = -101; } else if (!ZhuanShengShiLian.IsZhuanShengShiLianCopyScene(client.ClientData.MapCode) && ZhuanShengShiLian.IsZhuanShengShiLianCopyScene(otherClient.ClientData.MapCode)) { result = -102; } else if (client.ClientData.FuBenSeqID != otherClient.ClientData.FuBenSeqID) { result = -101; } else { result = 0; } return(result); }
public static bool EnterSceneCopyScene(GameClient client, out int nSeqID, int mapCode) { nSeqID = -1; ZhuanShengMapInfo mapInfo; lock (ZhuanShengShiLian.ZhuanShengRunTimeData.Mutex) { if (!ZhuanShengShiLian.ZhuanShengRunTimeData.ZhuanShengMapDict.TryGetValue(mapCode, out mapInfo)) { return(false); } } bool result; if (!ZhuanShengShiLian.JudgeCanEnterOnTime(mapInfo)) { result = false; } else { int calEnterMapCode = ZhuanShengShiLian.GetZhuanShengShiLianMapCodeIDForRole(client); if (calEnterMapCode <= 0 || mapCode != calEnterMapCode) { result = false; } else { ZSSLScene sceneInfo = null; lock (ZhuanShengShiLian.ZhuanShengRunTimeData.Mutex) { foreach (KeyValuePair <int, ZSSLScene> kvp in ZhuanShengShiLian.SceneDict) { if (kvp.Value.SceneInfo.MapCode == mapCode) { sceneInfo = kvp.Value; nSeqID = kvp.Key; break; } } if (null == sceneInfo) { nSeqID = GameCoreInterface.getinstance().GetNewFuBenSeqId(); sceneInfo = new ZSSLScene(); sceneInfo.CleanAllInfo(); sceneInfo.SceneInfo = mapInfo; ZhuanShengShiLian.SceneDict[nSeqID] = sceneInfo; } } if (null != sceneInfo.m_CopyMap) { if (sceneInfo.m_CopyMap.GetGameClientCount() >= mapInfo.MaxEnterNum) { return(false); } } result = true; } } return(result); }
public static void ProcessClearRoleLog(GameClient client) { try { if (ZhuanShengShiLian.IsZhuanShengShiLianCopyScene(client.ClientData.MapCode)) { ZSSLScene mapInfo; if (ZhuanShengShiLian.SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out mapInfo)) { long tID = ZhuanShengShiLian.GetGUID(client.ClientData.TeamID, client.ClientData.RoleID); int leader = -1; TeamData td = GameManager.TeamMgr.FindData(client.ClientData.TeamID); if (null != td) { leader = td.LeaderRoleID; } bool top5Chg = false; lock (ZhuanShengShiLian.ZhuanShengRunTimeData.Mutex) { BossAttackLog bossAttackLog = mapInfo.AttackLog; if (null == bossAttackLog) { return; } BHAttackLog tAttackLog; if (bossAttackLog.BHInjure.TryGetValue(tID, out tAttackLog)) { if (leader == -1) { tAttackLog.BHInjure = 0L; bossAttackLog.BHInjure.Remove(tID); } else { long roleInjure = 0L; if (tAttackLog.RoleInjure.TryGetValue(client.ClientData.RoleID, out roleInjure)) { tAttackLog.RoleInjure.Remove(client.ClientData.RoleID); tAttackLog.BHInjure -= roleInjure; if (tAttackLog.BHInjure <= 0L) { bossAttackLog.BHInjure.Remove(tID); } } } top5Chg = ZhuanShengShiLian.TrySortAttackRank(bossAttackLog, tAttackLog); } } ZhuanShengShiLian.BroadBossLife(mapInfo, client, top5Chg); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, string.Format("ZhuanShengShiLian :: 处理清除角色伤害记录异常。", new object[0]), ex, true); } }
public static void ProcessChangeTeamName(GameClient client, bool needBroad = false) { try { if (ZhuanShengShiLian.IsZhuanShengShiLianCopyScene(client.ClientData.MapCode)) { ZSSLScene mapInfo; if (ZhuanShengShiLian.SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out mapInfo)) { TeamData td = GameManager.TeamMgr.FindData(client.ClientData.TeamID); if (null != td) { string newName = ""; long tID = ZhuanShengShiLian.GetGUID(client.ClientData.TeamID, client.ClientData.RoleID); lock (td) { if (td.LeaderRoleID == client.ClientData.RoleID) { return; } TeamMemberData member = td.GetLeader(); if (null == member) { return; } newName = member.RoleName; } BHAttackLog tAttackLog; lock (ZhuanShengShiLian.ZhuanShengRunTimeData.Mutex) { if (null == mapInfo.AttackLog) { return; } if (!mapInfo.AttackLog.BHInjure.TryGetValue(tID, out tAttackLog)) { return; } tAttackLog.BHName = newName; } if (needBroad) { int myRank = mapInfo.AttackLog.BHAttackRank.FindIndex((BHAttackLog x) => object.ReferenceEquals(x, tAttackLog)); bool top5Chg = myRank >= 0 && myRank < 5; ZhuanShengShiLian.BroadBossLife(mapInfo, client, top5Chg); } } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, string.Format("ZhuanShengShiLian :: 处理清除角色伤害记录异常。", new object[0]), ex, true); } }
public static void BroadBossLife(ZSSLScene mapInfo, GameClient client, bool Top5Chg) { if (null != mapInfo.AttackLog) { BossLifeLog bossLifeLog = new BossLifeLog(); bossLifeLog.InjureSum = mapInfo.AttackLog.InjureSum; if (null != mapInfo.AttackLog.BHAttackRank) { int countLimit = Global.GMin(mapInfo.AttackLog.BHAttackRank.Count, 5); bossLifeLog.BHAttackRank = mapInfo.AttackLog.BHAttackRank.GetRange(0, countLimit); } List <GameClient> objsList = mapInfo.m_CopyMap.GetClientsList(); if (objsList != null && objsList.Count > 0) { for (int i = 0; i < objsList.Count; i++) { GameClient c = objsList[i]; if (c != null) { if (!Top5Chg && null != client) { if (client.ClientData.TeamID > 0 && client.ClientData.TeamID != c.ClientData.TeamID) { goto IL_189; } if (c.ClientData.RoleID != client.ClientData.RoleID) { goto IL_189; } } if (null != mapInfo.AttackLog.BHInjure) { long tID = ZhuanShengShiLian.GetGUID(c.ClientData.TeamID, c.ClientData.RoleID); mapInfo.AttackLog.BHInjure.TryGetValue(tID, out bossLifeLog.SelfBHAttack); } c.sendCmd <BossLifeLog>(1906, bossLifeLog, false); } IL_189 :; } } } }
public static void TimerProc() { if (!GameManager.IsKuaFuServer) { long nowTicks = TimeUtil.NOW(); lock (ZhuanShengShiLian.ZhuanShengRunTimeData.Mutex) { if (Math.Abs(nowTicks - ZhuanShengShiLian.LastHeartBeatTicks) < 1000L) { return; } ZhuanShengShiLian.LastHeartBeatTicks = nowTicks; } if (157 == ZhuanShengShiLian.ZhuanShengRunTimeData.ThemeZSActivity.ActivityType && ZhuanShengShiLian.ZhuanShengRunTimeData.ThemeZSActivity.InActivityTime()) { foreach (KeyValuePair <int, ZSSLScene> scenes in ZhuanShengShiLian.SceneDict) { lock (ZhuanShengShiLian.ZhuanShengRunTimeData.Mutex) { switch (scenes.Value.State) { case BattleStates.NoBattle: { DateTime startTime = DateTime.Parse(scenes.Value.SceneInfo.TimePoints[0]).AddSeconds((double)scenes.Value.SceneInfo.ReadyTime); scenes.Value.StartTick = startTime.Ticks / 10000L; scenes.Value.EndTick = startTime.AddSeconds((double)scenes.Value.SceneInfo.FightSecs).Ticks / 10000L; scenes.Value.StatusEndTime = scenes.Value.StartTick; ZhuanShengShiLian.BroadMsg(scenes.Value.SceneInfo.MapCode, GLang.GetLang(4010, new object[0])); scenes.Value.State = BattleStates.WaitingFight; break; } case BattleStates.WaitingFight: if (nowTicks >= scenes.Value.StartTick && null != scenes.Value.m_CopyMap) { GameManager.MonsterZoneMgr.AddDynamicMonsters(scenes.Value.SceneInfo.MapCode, scenes.Value.SceneInfo.MonstersID, scenes.Value.m_CopyMap.FuBenSeqID, 1, scenes.Value.SceneInfo.BornX / 100, scenes.Value.SceneInfo.BornY / 100, 0, 0, SceneUIClasses.Normal, null, null); scenes.Value.State = BattleStates.StartFight; scenes.Value.StatusEndTime = scenes.Value.EndTick; ZhuanShengShiLian.SendTimeInfoToAll(scenes.Value, nowTicks); } break; case BattleStates.StartFight: if (nowTicks >= scenes.Value.EndTick) { scenes.Value.State = BattleStates.EndFight; scenes.Value.StatusEndTime = scenes.Value.EndTick; scenes.Value.BossDie = false; List <object> monsterList = GameManager.MonsterMgr.GetObjectsByMap(scenes.Value.SceneInfo.MapCode); foreach (object monster in monsterList) { if (monster is Monster) { GameManager.MonsterMgr.DeadMonsterImmediately(monster as Monster); } } } break; case BattleStates.EndFight: try { List <ShiLianReward> rewardList; if (ZhuanShengShiLian.ZhuanShengRunTimeData.ShiLianRewardDict.TryGetValue(scenes.Value.SceneInfo.MapCode, out rewardList)) { List <BHAttackLog> bhAttackLogList = scenes.Value.AttackLog.BHInjure.Values.ToList <BHAttackLog>(); int i; for (i = 0; i < bhAttackLogList.Count; i++) { if (bhAttackLogList[i].BHInjure > 0L) { int rank = scenes.Value.AttackLog.BHAttackRank.FindIndex((BHAttackLog x) => object.ReferenceEquals(x, bhAttackLogList[i])); rank++; ShiLianReward reward = rewardList.Find((ShiLianReward _x) => _x.MinRank <= rank && (rank <= _x.MaxRank || _x.MaxRank < 0)); if (null != reward) { int exp = scenes.Value.BossDie ? reward.WinrewardExp : reward.LoseRewardExp; int money = scenes.Value.BossDie ? reward.WinRewardMoney : reward.LoseRewardMoney; string goods = scenes.Value.BossDie ? reward.WinRewardItem : reward.LoseRewardItem; foreach (KeyValuePair <int, long> role in bhAttackLogList[i].RoleInjure) { GameClient client = GameManager.ClientMgr.FindClient(role.Key); if (null != client) { if (client.ClientData.MapCode == scenes.Value.SceneInfo.MapCode) { GameManager.ClientMgr.ProcessRoleExperience(client, (long)exp, false, true, false, "none"); GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, money, "转生试炼添加绑金", true); ZhuanShengShiLian.GiveGoodsAward(client, goods); client.sendCmd(1908, string.Format("{0}:{1}:{2}:{3}:{4}", new object[] { scenes.Value.BossDie ? 1 : 0, goods, exp, money, rank }), false); } } } } } } } scenes.Value.AttackLog = null; } catch (Exception ex) { DataHelper.WriteExceptionLogEx(ex, "转生试炼调度异常"); } scenes.Value.ClearTick = nowTicks + (long)(scenes.Value.SceneInfo.ClearRolesSecs * 1000); scenes.Value.StatusEndTime = scenes.Value.ClearTick; scenes.Value.State = BattleStates.ClearBattle; ZhuanShengShiLian.SendTimeInfoToAll(scenes.Value, nowTicks); break; case BattleStates.ClearBattle: if (nowTicks >= scenes.Value.ClearTick) { List <GameClient> objsList = scenes.Value.m_CopyMap.GetClientsList(); if (objsList != null && objsList.Count > 0) { for (int j = 0; j < objsList.Count; j++) { GameClient client = objsList[j]; if (client != null) { int toMapCode = GameManager.MainMapCode; int toPosX = -1; int toPosY = -1; if (client.ClientData.LastMapCode != -1 && client.ClientData.LastPosX != -1 && client.ClientData.LastPosY != -1) { if (MapTypes.Normal == Global.GetMapType(client.ClientData.LastMapCode)) { toMapCode = client.ClientData.LastMapCode; toPosX = client.ClientData.LastPosX; toPosY = client.ClientData.LastPosY; } } GameMap gameMap = null; if (GameManager.MapMgr.DictMaps.TryGetValue(toMapCode, out gameMap)) { GameManager.ClientMgr.NotifyChangeMap(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, toMapCode, toPosX, toPosY, -1, 0); } } } } scenes.Value.State = BattleStates.NoBattle; } break; } } } } } }
public static void ProcessAttack(GameClient client, Monster monster, int injure) { try { if (injure > 0) { long tID = ZhuanShengShiLian.GetGUID(client.ClientData.TeamID, client.ClientData.RoleID); string tName = client.ClientData.RoleName; TeamData td = GameManager.TeamMgr.FindData(client.ClientData.TeamID); if (null != td) { lock (td) { TeamMemberData member = td.GetLeader(); if (null != member) { tName = member.RoleName; } } } ZSSLScene mapInfo; if (ZhuanShengShiLian.SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out mapInfo)) { bool top5Chg = false; lock (ZhuanShengShiLian.ZhuanShengRunTimeData.Mutex) { BossAttackLog bossAttackLog = mapInfo.AttackLog; if (null == bossAttackLog) { bossAttackLog = new BossAttackLog { InjureSum = 0L, BHInjure = new Dictionary <long, BHAttackLog>(), BHAttackRank = new List <BHAttackLog>() }; } BHAttackLog bhAttackLog; if (!bossAttackLog.BHInjure.TryGetValue(tID, out bhAttackLog)) { bhAttackLog = new BHAttackLog { BHName = tName, BHInjure = 0L, RoleInjure = new Dictionary <int, long>() }; bossAttackLog.BHInjure[tID] = bhAttackLog; } if (!bhAttackLog.RoleInjure.ContainsKey(client.ClientData.RoleID)) { bhAttackLog.RoleInjure[client.ClientData.RoleID] = 0L; } Dictionary <int, long> roleInjure; int roleID; (roleInjure = bhAttackLog.RoleInjure)[roleID = client.ClientData.RoleID] = roleInjure[roleID] + (long)injure; bhAttackLog.BHInjure += (long)injure; top5Chg = ZhuanShengShiLian.TrySortAttackRank(bossAttackLog, bhAttackLog); bossAttackLog.InjureSum += (long)injure; } ZhuanShengShiLian.BroadBossLife(mapInfo, client, top5Chg); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, string.Format("ZhuanShengShiLian :: 处理攻击boss异常。", new object[0]), ex, true); } }
public static void OnEnterScene(GameClient client) { ZhuanShengShiLian.SendTimeInfoToClient(client); }