public void HandleCommand(BaseGame game, Player player, GSPacketIn packet) { if (game is PVEGame) { PVEGame pve = game as PVEGame; bool tryAgain = packet.ReadBoolean(); bool isHost = packet.ReadBoolean(); if (isHost) { if (tryAgain) { if (player.PlayerDetail.RemoveMoney(500, LogMoneyType.Game, LogMoneyType.Game_TryAgain) > 0) { pve.WantTryAgain = 1; game.SendToAll(packet); } else { player.PlayerDetail.SendInsufficientMoney(2); } } else { pve.WantTryAgain = 0; game.SendToAll(packet); } pve.CheckState(0); } } }
public void HandleCommand(BaseGame game, Player player, GSPacketIn packet) { if (game is PVEGame) { PVEGame pVEGame = game as PVEGame; int num = packet.ReadInt(); bool flag = packet.ReadBoolean(); if (flag) { if (num == 1) { if (player.PlayerDetail.RemoveMoney(100) > 0) { pVEGame.WantTryAgain = 1; game.SendToAll(packet); player.PlayerDetail.LogAddMoney(AddMoneyType.Game, AddMoneyType.Game_TryAgain, player.PlayerDetail.PlayerCharacter.ID, 100, player.PlayerDetail.PlayerCharacter.Money); } else { player.PlayerDetail.SendInsufficientMoney(2); } } else { pVEGame.WantTryAgain = 0; game.SendToAll(packet); } pVEGame.CheckState(0); } } }
public void HandleCommand(BaseGame game, Player player, GSPacketIn packet) { if (game is PVEGame) { PVEGame pve = game as PVEGame; bool tryAgain = packet.ReadBoolean(); bool isHost = packet.ReadBoolean(); if (isHost == true) { if (tryAgain == true) { if (player.PlayerDetail.RemoveMoney(100) > 0) { //退回关卡结算 pve.WantTryAgain = 1; game.SendToAll(packet); player.PlayerDetail.LogAddMoney(AddMoneyType.Game, AddMoneyType.Game_TryAgain, player.PlayerDetail.PlayerCharacter.ID, 100, player.PlayerDetail.PlayerCharacter.Money); } else { player.PlayerDetail.SendInsufficientMoney((int)eBattleRemoveMoneyType.TryAgain); } } else { //退回房间 pve.WantTryAgain = 0; game.SendToAll(packet); } pve.CheckState(0); } } }
public void HandleCommand(BaseGame game, Player player, GSPacketIn packet) { if (game is PVEGame) { PVEGame pve = game as PVEGame; if (pve.BossCardCount + 1 > 0) { int index = packet.ReadByte(); if (index < 0 || index > pve.BossCards.Length) { if (pve.IsBossWar != "") { pve.TakeBossCard(player); } else { pve.TakeCard(player); } } else { if (pve.IsBossWar != "") { pve.TakeBossCard(player, index); } else { pve.TakeCard(player, index); } } } } }
public void HandleCommand(BaseGame game, Player player, GSPacketIn packet) { if (game is PVEGame) { PVEGame pVEGame = game as PVEGame; if (pVEGame.BossCardCount + 1 > 0) { int num = (int)packet.ReadByte(); if (num < 0 || num > pVEGame.BossCards.Length) { if (pVEGame.IsBossWar != "") { pVEGame.TakeBossCard(player); return; } pVEGame.TakeCard(player); return; } else { if (pVEGame.IsBossWar != "") { pVEGame.TakeBossCard(player, num); return; } pVEGame.TakeCard(player, num); } } } }
public static BaseGame StartPVEGame(List <IGamePlayer> player, int mapIndex, eRoomType roomType, eTeamType teamType, eGameType gameType, int timeType) { try { int index = MapMgr.GetMapIndex(mapIndex, (byte)roomType, m_serverId); index = 1072; Map map = MapMgr.CloneMap(index); if (map != null) { PVEGame game = new PVEGame(m_gameId++, player, map, roomType, teamType, gameType, timeType); lock (m_games) { m_games.Add(game); } game.Prepare(); return(game); } else { return(null); } } catch (Exception e) { log.Error("Create game error:", e); return(null); } }
/// <summary> /// end the game /// </summary> private void OnGameEnd() { m_game = null; MsgBoxAPI.ShowMsgBox("Game Over", "your score for this game is: " + cur_score, "OK", (arg) => { UIManager.Instance.GoBackPage(); }); }
/// <summary> /// 停止游戏 /// </summary> private void StopGame() { if (m_game != null) { m_game.Stop(); m_game = null; } }
/// <summary> /// 当游戏结束时 /// </summary> private void OnGameEnd() { m_game = null; UIAPI.ShowMsgBox("游戏结束", "显示游戏积分...", "确定", (arg) => { UIManager.Instance.GoBackPage(); }); }
public void HandleCommand(BaseGame game, Player player, GSPacketIn packet) { if (game is PVEGame && game.GameState != eGameState.Playing) { PVEGame pveGame = game as PVEGame; pveGame.IsPassDrama = packet.ReadBoolean(); pveGame.CheckState(0); } }
public override void OnNewTurnStarted() { PVEGame pveGame = Game as PVEGame; int turnNpcRank = pveGame.FindTurnNpcRank(); if (Game.GetLivedLivings().Count == 0) { pveGame.NpcTurnQueue[turnNpcRank] = 0; } if (Game.TurnIndex > 1 && Game.CurrentPlayer.Delay > pveGame.NpcTurnQueue[turnNpcRank]) { if (GetLivingBlueNpc() + GetLivingRedNpc() == 15) { return; } if (redNpc.Count + blueNpc.Count < 15) { CreateFullNpc(); } else { for (int i = 0; i < 4; i++) { if (GetLivingRedNpc() < 12 && redNpc.Count < 4 * Game.MissionInfo.TotalCount / 5) { if (i < 1) { redNpc.Add(Game.CreateNpc(redNpcID, 900 + (i + 1) * 100, 505, 1)); } else if (i < 3) { redNpc.Add(Game.CreateNpc(redNpcID, 920 + (i + 1) * 100, 505, 1)); } else { redNpc.Add(Game.CreateNpc(redNpcID, 1000 + (i + 1) * 100, 515, 1)); } } else { break; } } if (GetLivingBlueNpc() < 3 && blueNpc.Count < Game.MissionInfo.TotalCount / 5) { blueNpc.Add(Game.CreateNpc(blueNpcID, 1465, 494, 1)); } } } }
void OnLeaveBattle() { if (pveGame != null) { pveGame.Stop(); pveGame = null; } ClearBattleView(); ModuleManager.Instance.OpenModule(ModuleDef.LobbyModule); }
/// <summary> /// when open PVE UI /// </summary> /// <param name="arg"></param> protected override void OnOpen(object arg) { base.OnOpen(arg); //listen on game status PVEModule module = ModuleManager.Instance.GetModule(ModuleConst.PVEModule) as PVEModule; m_game = module.GetCurrentGame(); m_game.onMainPlayerDie += OnMainPlayerDie; m_game.onGameEnd += OnGameEnd; txtUserInfo.text = UserManager.Instance.MainUserData.name; txtTimeInfo.text = ""; }
public override void OnNewTurnStarted() { base.OnNewTurnStarted(); PVEGame pveGame = Game as PVEGame; int turnNpcRank = pveGame.FindTurnNpcRank(); if (Game.GetLivedLivings().Count == 0) { pveGame.NpcTurnQueue[turnNpcRank] = 0; } if (Game.TurnIndex > 1 && Game.CurrentPlayer.Delay > pveGame.NpcTurnQueue[turnNpcRank]) { if (Game.GetLivedLivings().Count < 10) { for (int i = 0; i < 10 - Game.GetLivedLivings().Count; i++) { if (someNpc.Count == Game.MissionInfo.TotalCount) { break; } else { int index = Game.Random.Next(0, birthX.Length); int NpcX = birthX[index]; int direction = -1; if (NpcX <= 320) { direction = 1; } index = Game.Random.Next(0, npcIDs.Length); if (index == 1 && GetNpcCountByID(npcIDs[1]) < 10) { someNpc.Add(Game.CreateNpc(npcIDs[1], NpcX, 506, 1, direction)); } else { someNpc.Add(Game.CreateNpc(npcIDs[0], NpcX, 506, 1, direction)); } } } } } }
void OnEnterBattleReply(GameParam param) { if (pveGame != null) { Debuger.LogError("PVEModule", "The pveGame is already created!"); return; } pveGame = new PVEGame(); pveGame.Start(param); EventManager.Instance.SendEvent(EventDef.OnEnterBattle); CreateBattleView(); }
/// <summary> /// 开始游戏 /// </summary> /// <param name="mode"></param> private void StartGame(int mode) { GameParam param = new GameParam(); param.mode = (GameMode)mode; param.limitedTime = 10; m_game = new PVEGame(); m_game.Start(param); m_game.onGameEnd += () => { StopGame(); }; //打开战斗UI UIManager.Instance.OpenPage(UIDef.UIPVEGamePage); }
public static BaseGame StartPVEGame(int roomId, List <IGamePlayer> players, int copyId, eRoomType roomType, eGameType gameType, int timeType, eHardLevel hardLevel, int levelLimits) { BaseGame result; try { List <PetSkillElementInfo> gameNeedPetSkillInfoList = PetMgr.GameNeedPetSkill(); PveInfo pveInfo; if (copyId == 0 || copyId == 100000) { pveInfo = PveInfoMgr.GetPveInfoByType(roomType, levelLimits); } else { pveInfo = PveInfoMgr.GetPveInfoById(copyId); } if (pveInfo != null) { PVEGame pVEGame = new PVEGame(GameMgr.m_gameId++, roomId, pveInfo, players, null, roomType, gameType, timeType, hardLevel, gameNeedPetSkillInfoList); pVEGame.GameOverLog += new BaseGame.GameOverLogEventHandle(LogMgr.LogFightAdd); List <BaseGame> games; Monitor.Enter(games = GameMgr.m_games); try { GameMgr.m_games.Add(pVEGame); } finally { Monitor.Exit(games); } pVEGame.Prepare(); result = pVEGame; } else { result = null; } } catch (Exception exception) { GameMgr.log.Error("Create game error:", exception); result = null; } return(result); }
/// <summary> /// start the game /// </summary> /// <param name="mode"></param> private void StartGame(int mode) { GameParam param = new GameParam(); param.mode = (GameMode)mode; //time limit in limited mode param.limitedTime = 150; m_game = new PVEGame(); m_game.Start(param); m_game.onGameEnd += () => { StopGame(); }; //open the UI for PVE game UIManager.Instance.OpenPage(UIConst.UIPVEGamePage); }
public override void OnNewTurnStarted() { base.OnNewTurnStarted(); PVEGame pveGame = Game as PVEGame; int turnNpcRank = pveGame.FindTurnNpcRank(); if (Game.GetLivedLivings().Count == 0) { pveGame.NpcTurnQueue[turnNpcRank] = 0; } //if (Game.TurnIndex > 1 && Game.CurrentPlayer.Delay > pveGame.NpcTurnQueue[turnNpcRank]) //{ // for (int i = 0; i < 4; i++) // { // if (redTotalCount < Game.MissionInfo.TotalCount) // { // redTotalCount++; // if (i < 1) // { // someNpc.Add(Game.CreateNpc(redNpcID, 900 + (i + 1) * 100, 505, 1)); // } // else if (i < 3) // { // someNpc.Add(Game.CreateNpc(redNpcID, 920 + (i + 1) * 100, 505, 1)); // } // else // { // someNpc.Add(Game.CreateNpc(redNpcID, 1000 + (i + 1) * 100, 515, 1)); // } // } // } // if (redTotalCount < Game.MissionInfo.TotalCount) // { // redTotalCount++; // someNpc.Add(Game.CreateNpc(redNpcID, 1465, 494, 1)); // } //} }
public static BaseGame StartPVEGame(int roomId, List <IGamePlayer> players, int copyId, eRoomType roomType, eGameType gameType, int timeType, eHardLevel hardLevel, int levelLimits) { BaseGame result; try { PveInfo info; if (copyId == 0 || copyId == 10000) { info = PveInfoMgr.GetPveInfoByType(roomType, levelLimits); } else { info = PveInfoMgr.GetPveInfoById(copyId); } if (info != null) { PVEGame game = new PVEGame(GameMgr.m_gameId++, roomId, info, players, null, roomType, gameType, timeType, hardLevel); List <BaseGame> games; Monitor.Enter(games = GameMgr.m_games); try { GameMgr.m_games.Add(game); } finally { Monitor.Exit(games); } game.Prepare(); result = game; } else { result = null; } } catch (Exception e) { GameMgr.log.Error("Create game error:", e); result = null; } return(result); }
public void Execute() { if (m_player.CurrentRoom != null) { m_player.CurrentRoom.RemovePlayer(m_player); } BaseRoom[] rooms = RoomMgr.Rooms; BaseRoom rm = null; if (m_roomId == -1) { return; } else { rm = rooms[m_roomId - 1]; } if (rm.NeedPassword == false || rm.Password == m_pwd) { RoomMgr.WaitingRoom.RemovePlayer(m_player); m_player.Out.SendRoomLoginResult(true); m_player.Out.SendRoomCreate(rm); if (rm.Game != null && rm.Game is PVEGame) { PVEGame pve = rm.Game as PVEGame; Player fp = new Player(m_player, pve.PhysicalId++, pve, 1); pve.AddPlayer(m_player, fp); } rm.AddPlayer(m_player); RoomMgr.WaitingRoom.SendUpdateRoom(rm); } else { m_player.Out.SendMessage(eMessageType.ERROR, "房间密码错误"); m_player.Out.SendRoomLoginResult(false); } }
public override void OnNewTurnStarted() { base.OnNewTurnStarted(); PVEGame game = base.Game; int key = game.FindTurnNpcRank(); if (base.Game.GetLivedLivings().Count == 0) { game.NpcTurnQueue[key] = 0; } if (base.Game.TurnIndex > 1 && base.Game.CurrentPlayer.Delay > game.NpcTurnQueue[key] && base.Game.GetLivedLivings().Count < 10) { for (int i = 0; i < 10 - base.Game.GetLivedLivings().Count; i++) { if (this.someNpc.Count == base.Game.MissionInfo.TotalCount) { return; } int num = base.Game.Random.Next(0, this.birthX.Length); int num2 = this.birthX[num]; int direction = -1; if (num2 <= 320) { direction = 1; } num = base.Game.Random.Next(0, this.npcIDs.Length); if (num == 1 && this.GetNpcCountByID(this.npcIDs[1]) < 10) { this.someNpc.Add(base.Game.CreateNpc(this.npcIDs[1], num2, 506, 1, direction)); } else { this.someNpc.Add(base.Game.CreateNpc(this.npcIDs[0], num2, 506, 1, direction)); } } } }
public static BaseGame StartPVEGame(int roomId, List <IGamePlayer> players, int copyId, eRoomType roomType, eGameType gameType, int timeType, eHardLevel hardLevel, int levelLimits) { try { PveInfo info = null; if (copyId == 0 || copyId == 100000) { info = PveInfoMgr.GetPveInfoByType(roomType, levelLimits); } else { info = PveInfoMgr.GetPveInfoById(copyId); } if (info != null) { PVEGame game = new PVEGame(m_gameId++, roomId, info, players, null, roomType, gameType, timeType, hardLevel); game.GameOverLog += new BaseGame.GameOverLogEventHandle(LogMgr.LogFightAdd); lock (m_games) { m_games.Add(game); } game.Prepare(); return(game); } else { return(null); } } catch (Exception e) { log.Error("Create game error:", e); return(null); } }
public GameShowCardAction(PVEGame game, int delay, int finishTime) : base(delay, finishTime) { this.m_game = game; }
public override void OnNewTurnStarted() { base.OnNewTurnStarted(); PVEGame pveGame = Game as PVEGame; int turnNpcRank = pveGame.FindTurnNpcRank(); if (Game.GetLivedLivings().Count == 0) { pveGame.NpcTurnQueue[turnNpcRank] = 0; } if (Game.TurnIndex > 1 && Game.CurrentPlayer.Delay > pveGame.NpcTurnQueue[turnNpcRank]) { if (Game.GetLivedLivings().Count == 15) { return; } if (someNpc.Count < 15) { for (int i = 0; i < 4; i++) { if (i < 1) { someNpc.Add(Game.CreateNpc(redNpcID, 900 + (i + 1) * 100, 505, 1)); } else if (i < 3) { someNpc.Add(Game.CreateNpc(redNpcID, 920 + (i + 1) * 100, 505, 1)); } else { someNpc.Add(Game.CreateNpc(redNpcID, 1000 + (i + 1) * 100, 515, 1)); } } someNpc.Add(Game.CreateNpc(redNpcID, 1465, 494, 1)); } else { for (int i = 0; i < 4; i++) { if (Game.GetLivedLivings().Count < 15 && someNpc.Count < Game.MissionInfo.TotalCount) { if (i < 1) { someNpc.Add(Game.CreateNpc(redNpcID, 900 + (i + 1) * 100, 505, 1)); } else if (i < 3) { someNpc.Add(Game.CreateNpc(redNpcID, 920 + (i + 1) * 100, 505, 1)); } else { someNpc.Add(Game.CreateNpc(redNpcID, 1000 + (i + 1) * 100, 515, 1)); } } else { break; } } if (Game.GetLivedLivings().Count < 15 && someNpc.Count < Game.MissionInfo.TotalCount) { someNpc.Add(Game.CreateNpc(redNpcID, 1465, 494, 1)); } } } }
/// <summary> /// 请不要直接调用,使用RoomMgr.ExitRoom /// </summary> /// <param name="player"></param> public bool RemovePlayerUnsafe(GamePlayer player, bool isKick) { int index = -1; lock (m_places) { for (int i = 0; i < 10; i++) { if (m_places[i] == player) { m_places[i] = null; m_playerState[i] = 0; m_placesState[i] = -1; m_playerCount--; index = i; break; } } } if (index != -1) { UpdatePosUnsafe(index, false, -1, -100); player.CurrentRoom = null; player.TempBag.ClearBag(); GSPacketIn pkg = player.Out.SendRoomPlayerRemove(player); SendToAll(pkg); //发送踢人信息 if (isKick) { player.Out.SendMessage(eMessageType.ChatERROR, LanguageMgr.GetTranslation("Game.Server.SceneGames.KickRoom")); } //从新挑选房主 bool isChangeHost = false; if (m_host == player) { if (m_playerCount > 0) { for (int i = 0; i < 10; i++) { if (m_places[i] != null) { SetHost(m_places[i]); isChangeHost = true; break; } } } else { m_host = null; } } //游戏中移除人物 if (IsPlaying) { if (m_game != null) { //如果关卡中,房主退出,重置新房主的ready状态 if (isChangeHost && m_game is PVEGame) { PVEGame pveGame = m_game as PVEGame; foreach (Player p in pveGame.Players.Values) { if (p.PlayerDetail == m_host) { p.Ready = false; } } } m_game.RemovePlayer(player, isKick); } if (BattleServer != null) { if (m_game != null) { BattleServer.Server.SendPlayerDisconnet(Game.Id, player.GamePlayerId, RoomId); if (PlayerCount == 0) { BattleServer.RemoveRoom(this); } } else { SendMessage(eMessageType.ChatERROR, LanguageMgr.GetTranslation("Game.Server.SceneGames.PairUp.Failed")); RoomMgr.AddAction(new CancelPickupAction(BattleServer, this)); BattleServer.RemoveRoom(this); IsPlaying = false; } } } else { UpdateGameStyle(); if (isChangeHost) { //if (RoomType == eRoomType.Dungeon) //{ // HardLevel = eHardLevel.Normal; //} //else //{ // HardLevel = eHardLevel.Simple; //} foreach (GamePlayer gp in GetPlayers()) { gp.Out.SendRoomChange(this); } } } } return(index != -1); }
public void Execute(BaseGame game, long tick) { if (this.m_time <= tick && game.GetWaitTimer() < tick) { PVEGame pVEGame = game as PVEGame; if (pVEGame != null) { switch (pVEGame.GameState) { case eGameState.Inited: pVEGame.Prepare(); break; case eGameState.Prepared: pVEGame.PrepareNewSession(); break; case eGameState.Loading: if (!pVEGame.IsAllComplete()) { game.WaitTime(1000); } else { pVEGame.StartGame(); } break; case eGameState.GameStartMovie: if (game.CurrentActionCount > 1) { pVEGame.StartGameMovie(); } else { pVEGame.StartGame(); } break; case eGameState.GameStart: pVEGame.PrepareNewGame(); break; case eGameState.Playing: if ((pVEGame.CurrentLiving == null || !pVEGame.CurrentLiving.IsAttacking) && game.CurrentActionCount <= 1) { if (pVEGame.CanGameOver()) { pVEGame.GameOver(); } else { pVEGame.NextTurn(); } } break; case eGameState.GameOver: if (!pVEGame.HasNextSession()) { pVEGame.GameOverAllSession(); } else { pVEGame.PrepareNewSession(); } break; case eGameState.SessionPrepared: if (!pVEGame.CanStartNewSession()) { game.WaitTime(1000); } else { pVEGame.StartLoading(); } break; case eGameState.ALLSessionStopped: if (pVEGame.PlayerCount == 0 || pVEGame.WantTryAgain == 0) { pVEGame.Stop(); } else { if (pVEGame.WantTryAgain == 1) { pVEGame.SessionId--; pVEGame.PrepareNewSession(); } else { game.WaitTime(1000); } } break; } } this.m_isFinished = true; } }
public void Execute(BaseGame game, long tick) { if (m_time <= tick && game.GetWaitTimer() < tick) { PVEGame pve = game as PVEGame; if (pve != null) { switch (pve.GameState) { case eGameState.Inited: pve.Prepare(); break; case eGameState.Prepared: pve.PrepareNewSession(); break; case eGameState.SessionPrepared: if (pve.CanStartNewSession()) { pve.StartLoading(); break; } else { game.WaitTime(1000); } break; case eGameState.Loading: if (pve.IsAllComplete()) { pve.StartGame(); break; } else { game.WaitTime(1000); } break; //TODO case eGameState.GameStartMovie: if (game.CurrentActionCount <= 1) { pve.StartGame(); break; } else { pve.StartGameMovie(); } break; case eGameState.GameStart: pve.PrepareNewGame(); break; case eGameState.Playing: if ((pve.CurrentLiving == null || pve.CurrentLiving.IsAttacking == false) && game.CurrentActionCount <= 1) { if (pve.CanGameOver()) { //log.Error(string.Format("stage : {0}", -1)); pve.GameOver(); break; } else { //log.Error(string.Format("stage : {0}", 0)); pve.NextTurn(); } } break; case eGameState.GameOver: if (pve.HasNextSession()) { //log.Error(string.Format("stage : {0}", 1)); pve.PrepareNewSession(); break; } else { //log.Error(string.Format("stage : {0}", 2)); pve.GameOverAllSession(); } break; case eGameState.ALLSessionStopped: if ((pve.PlayerCount != 0) && (pve.WantTryAgain != 0)) { if (pve.WantTryAgain == 1) { pve.SessionId--; pve.PrepareNewSession(); //log.Error(string.Format("stage : {0}", 3)); } else { game.WaitTime(1000); //log.Error(string.Format("stage : {0}", 4)); } break; } pve.Stop(); break; } } m_isFinished = true; } }
public void Execute() { bool result = true; if (this.m_player.IsActive) { if (this.m_player.CurrentRoom != null) { this.m_player.CurrentRoom.RemovePlayerUnsafe(this.m_player); } BaseRoom[] rooms = RoomMgr.Rooms; BaseRoom rm; if (this.m_roomId == -1) { rm = this.FindRandomRoom(rooms); if (rm == null) { this.m_player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("EnterRoomAction.noroom", new object[0])); this.m_player.Out.SendRoomLoginResult(false); List <BaseRoom> list = RoomMgr.GetWaitingRoom(this.m_hallType, 0, 9, 0); this.m_player.Out.SendUpdateRoomList(list); return; } } else { if (this.m_roomId > rooms.Length || this.m_roomId <= 0) { this.m_player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("EnterRoomAction.noexist", new object[0])); return; } rm = rooms[this.m_roomId - 1]; } if (!rm.IsUsing) { this.m_player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("EnterRoomAction.noexist", new object[0])); List <BaseRoom> list = RoomMgr.GetWaitingRoom(this.m_hallType, 0, 9, 0); this.m_player.Out.SendUpdateRoomList(list); } else { if (this.m_hallType == 1 && (rm.RoomType == eRoomType.Boss || rm.RoomType == eRoomType.Exploration || rm.RoomType == eRoomType.Treasure)) { this.m_player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("EnterRoomAction.NotInPve", new object[0])); } else { if (this.m_hallType == 2 && (rm.RoomType == eRoomType.Freedom || rm.RoomType == eRoomType.Match)) { this.m_player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("EnterRoomAction.NotInPvp", new object[0])); } else { if (rm.IsPlaying) { if (rm.Game is PVEGame) { PVEGame pveGame = rm.Game as PVEGame; if (pveGame.GameState != eGameState.SessionPrepared || !this.m_isInvite) { this.m_player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("EnterRoomAction.start", new object[0])); result = false; } } else { this.m_player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("EnterRoomAction.start", new object[0])); result = false; } } if (result) { if (rm.PlayerCount == rm.PlacesCount) { result = false; this.m_player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("EnterRoomAction.full", new object[0])); } else { if (!rm.NeedPassword || rm.Password == this.m_pwd) { if (rm.Game == null || rm.Game.CanAddPlayer()) { if (rm.RoomType == eRoomType.Exploration && rm.LevelLimits > (int)rm.GetLevelLimit(this.m_player)) { this.m_player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("EnterRoomAction.level", new object[0])); return; } RoomMgr.WaitingRoom.RemovePlayer(this.m_player); this.m_player.Out.SendRoomLoginResult(true); this.m_player.Out.SendRoomCreate(rm); if (rm.AddPlayerUnsafe(this.m_player)) { if (rm.Game != null) { rm.Game.AddPlayer(this.m_player); } } RoomMgr.WaitingRoom.SendUpdateRoom(rm); this.m_player.Out.SendRoomChange(rm); } } else { string msg; if (rm.NeedPassword && string.IsNullOrEmpty(this.m_pwd)) { msg = LanguageMgr.GetTranslation("EnterRoomAction.EnterPassword", new object[0]); } else { msg = LanguageMgr.GetTranslation("EnterRoomAction.passworderror", new object[0]); } this.m_player.Out.SendMessage(eMessageType.ERROR, msg); this.m_player.Out.SendRoomLoginResult(false); } } } if (!result) { if (this.m_roomId != -1) { List <BaseRoom> list = RoomMgr.GetWaitingRoom(this.m_hallType, 0, 8, this.m_roomId); list.Add(rooms[this.m_roomId - 1]); this.m_player.Out.SendUpdateRoomList(list); } } } } } } }
public bool RemovePlayerUnsafe(GamePlayer player, bool isKick) { int num = -1; GamePlayer[] places; Monitor.Enter(places = this.m_places); try { for (int i = 0; i < 10; i++) { if (this.m_places[i] == player) { this.m_places[i] = null; this.m_playerState[i] = 0; this.m_placesState[i] = -1; this.m_playerCount--; num = i; break; } } } finally { Monitor.Exit(places); } if (num != -1) { this.UpdatePosUnsafe(num, false, -1, -100); player.CurrentRoom = null; player.TempBag.ClearBag(); GSPacketIn pkg = player.Out.SendRoomPlayerRemove(player); this.SendToAll(pkg); if (isKick) { player.Out.SendMessage(eMessageType.ChatERROR, LanguageMgr.GetTranslation("Game.Server.SceneGames.KickRoom", new object[0])); } bool flag = false; if (this.m_host == player) { if (this.m_playerCount > 0) { for (int j = 0; j < 10; j++) { if (this.m_places[j] != null) { this.SetHost(this.m_places[j]); flag = true; break; } } } else { this.m_host = null; } } if (this.IsPlaying) { if (this.m_game != null) { if (flag && this.m_game is PVEGame) { PVEGame pVEGame = this.m_game as PVEGame; foreach (Player current in pVEGame.Players.Values) { if (current.PlayerDetail == this.m_host) { current.Ready = false; } } } this.m_game.RemovePlayer(player, isKick); } if (this.BattleServer != null) { if (this.m_game != null) { this.BattleServer.Server.SendPlayerDisconnet(this.Game.Id, player.GamePlayerId, this.RoomId); if (this.PlayerCount == 0) { this.BattleServer.RemoveRoom(this); } } else { this.SendMessage(eMessageType.ChatERROR, LanguageMgr.GetTranslation("Game.Server.SceneGames.PairUp.Failed", new object[0])); RoomMgr.AddAction(new CancelPickupAction(this.BattleServer, this)); this.BattleServer.RemoveRoom(this); this.IsPlaying = false; } } } else { this.UpdateGameStyle(); if (flag) { foreach (GamePlayer current2 in this.GetPlayers()) { current2.Out.SendRoomChange(this); } } } } return(num != -1); }