internal void SendAddRoom(Game.Server.Rooms.BaseRoom room) { GSPacketIn pkg = new GSPacketIn((int)eFightPackageType.GAME_ROOM_CREATE); pkg.WriteInt(room.RoomId); pkg.WriteInt((int)room.GameType); pkg.WriteInt(room.Game.PlayerCount); List <GamePlayer> players = room.GetPlayersSafe(); foreach (GamePlayer p in players) { pkg.WriteInt(p.PlayerCharacter.ID);//改为唯一ID pkg.WriteInt(p.PlayerCharacter.Attack); pkg.WriteInt(p.PlayerCharacter.Defence); pkg.WriteInt(p.PlayerCharacter.Agility); pkg.WriteInt(p.PlayerCharacter.Luck); pkg.WriteDouble(p.GetBaseAttack()); pkg.WriteDouble(p.GetBaseDefence()); pkg.WriteDouble(p.GetBaseAgility()); pkg.WriteDouble(p.GetBaseBlood()); pkg.WriteInt(p.CurrentWeapon.TemplateID); } SendTCP(pkg, room); }
public void SendUpdateRoom(BaseRoom room) { GamePlayer[] players = GetPlayersSafe(); GSPacketIn pkg = null; foreach (GamePlayer p in players) { if (pkg == null) { //--------------- BaseRoom[] list = RoomMgr.Rooms; List <BaseRoom> tempList = new List <BaseRoom>(); for (int i = 0; i < list.Length; i++) { if (!list[i].IsEmpty) { tempList.Add(list[i]); } } pkg = p.Out.SendUpdateRoomList(tempList); } else { p.Out.SendTCP(pkg); } } }
public static bool CanChangeStyle(BaseRoom game, GSPacketIn pkg) { FightRateInfo[] infos = GetAllFightRateInfo(); try { foreach (FightRateInfo info in infos) { if (info.BeginDay.Year <= DateTime.Now.Year && DateTime.Now.Year <= info.EndDay.Year) { if (info.BeginDay.DayOfYear <= DateTime.Now.DayOfYear && DateTime.Now.DayOfYear <= info.EndDay.DayOfYear) { if (info.BeginTime.TimeOfDay <= DateTime.Now.TimeOfDay && DateTime.Now.TimeOfDay <= info.EndTime.TimeOfDay) { if (Bussiness.ThreadSafeRandom.NextStatic(1000000) < info.Rate) { //game.Data.FightName = info.Name; //GamePlayer[] selfs = game.GetAllPlayers(); //pkg.WriteBoolean(true); //pkg.WriteInt(selfs.Length); //foreach (GamePlayer p in selfs) //{ // string style = string.Empty; // string color = string.Empty; // string skin = string.Empty; // p.CurrentInventory.GetStyle(11, p.PlayerCharacter.Sex ? info.BoyTemplateID : info.GirlTemplateID, ref style, ref color, ref skin); // //p.UpdateStyle(style,color,skin, p.EquipShow(3, 1, p.PlayerCharacter.Hide), true); // pkg.WriteInt(p.PlayerCharacter.ID); // pkg.WriteString(style); // pkg.WriteInt(p.EquipShow(3, 1, p.PlayerCharacter.Hide)); // pkg.WriteBoolean(p.PlayerCharacter.Sex); // pkg.WriteString(skin); // pkg.WriteString(color); // p.Out.SendMessage(Game.Server.Packets.eMessageType.ChatNormal, info.SelfCue); //} //GamePlayer[] enemys = game.MatchGame.GetAllPlayers(); //foreach (GamePlayer p in enemys) //{ // p.Out.SendMessage(Game.Server.Packets.eMessageType.ChatNormal, info.EnemyCue); //} return true; } } } } } } catch { } pkg.WriteBoolean(false); return false; }
public UpdateRoomPosAction(BaseRoom room, int pos,bool isOpened, int place, int placeView) { m_room = room; m_pos = pos; m_isOpened = isOpened; m_place = place; m_placeView = placeView; }
public UpdateRoomPosAction(BaseRoom room, int pos, bool isOpened, int place, int placeView) { this.m_room = room; this.m_pos = pos; this.m_isOpened = isOpened; this.m_place = place; this.m_placeView = placeView; }
public void SendRoomSetupChange(BaseRoom room) { if (this.m_host != null) { GSPacketIn pkg = this.m_host.Out.SendRoomChange(room); this.SendToAll(pkg); } }
public static BattleServer AddRoom(BaseRoom room) { BattleServer server = FindActiveServer(); if (server != null && server.AddRoom(room)) { return server; } return null; }
public void Execute() { BaseRoom room = m_player.CurrentRoom; if (room != null) { room.SwitchTeamUnsafe(m_player); } }
public void Execute() { BaseRoom currentRoom = this.m_player.CurrentRoom; if (currentRoom != null) { currentRoom.SwitchTeamUnsafe(this.m_player); } }
public RoomSetupChangeAction(BaseRoom room, GSPacketIn packet, eRoomType roomType, byte timeMode, eHardLevel hardLevel, int levelLimits, int mapId) { m_room = room; m_roomType = roomType; m_timeMode = timeMode; m_hardLevel = hardLevel; m_levelLimits = levelLimits; m_mapId = mapId; m_packet = packet; }
public RoomSetupChangeAction(BaseRoom room, GSPacketIn packet, eRoomType roomType, byte timeMode, eHardLevel hardLevel, int levelLimits, int mapId, bool isArea) { this.m_room = room; this.m_roomType = roomType; this.m_timeMode = timeMode; this.m_hardLevel = hardLevel; this.m_levelLimits = levelLimits; this.m_mapId = mapId; this.m_packet = packet; this.m_isArea = isArea; }
public static void ClearRooms(long tick) { BaseRoom[] rooms = RoomMgr.m_rooms; for (int i = 0; i < rooms.Length; i++) { BaseRoom baseRoom = rooms[i]; if (baseRoom.IsUsing && baseRoom.PlayerCount == 0) { baseRoom.Stop(); } } }
public RoomSetupChangeAction(BaseRoom room, eRoomType roomType, byte timeMode, eHardLevel hardLevel, int levelLimits, int mapId, string password, string roomname, bool isCrosszone, bool isOpenBoss) { m_room = room; m_roomType = roomType; m_timeMode = timeMode; m_hardLevel = hardLevel; m_levelLimits = levelLimits; m_mapId = mapId; m_password = password; m_roomName = roomname; m_isCrosszone = isCrosszone; m_isOpenBoss = isOpenBoss; }
public RoomSetupChangeAction(BaseRoom room, eRoomType roomType, byte timeMode, eHardLevel hardLevel, int levelLimits, int mapId, string password, string roomname, bool isCrosszone, bool isOpenBoss) { this.m_room = room; this.m_roomType = roomType; this.m_timeMode = timeMode; this.m_hardLevel = hardLevel; this.m_levelLimits = levelLimits; this.m_mapId = mapId; this.m_password = password; this.m_roomName = roomname; this.m_isCrosszone = isCrosszone; this.m_isOpenBoss = isOpenBoss; }
public static bool Setup(int maxRoom) { maxRoom = maxRoom < 1 ? 1 : maxRoom; m_thread = new Thread(new ThreadStart(RoomThread)); m_actionQueue = new Queue <IAction>(); m_rooms = new BaseRoom[maxRoom]; for (int i = 0; i < maxRoom; i++) { m_rooms[i] = new BaseRoom(i + 1); } m_waitingRoom = new BaseWaitingRoom(); return(true); }
public static bool Setup(int maxRoom) { maxRoom = maxRoom < 1 ? 1 : maxRoom; m_thread = new Thread(new ThreadStart(RoomThread)); m_actionQueue = new Queue<IAction>(); m_rooms = new BaseRoom[maxRoom]; for (int i = 0; i < maxRoom; i++) { m_rooms[i] = new BaseRoom(i + 1); } m_waitingRoom = new BaseWaitingRoom(); return true; }
public void Execute() { if (this.m_player.CurrentRoom != null) { this.m_player.CurrentRoom.RemovePlayerUnsafe(this.m_player); } if (this.m_player.IsActive) { BaseRoom[] rooms = RoomMgr.Rooms; BaseRoom room = null; for (int i = 0; i < rooms.Length; i++) { if (!rooms[i].IsUsing) { room = rooms[i]; break; } } if (room != null) { RoomMgr.WaitingRoom.RemovePlayer(this.m_player); room.Start(); if (this.m_roomType == eRoomType.Exploration) { room.HardLevel = eHardLevel.Normal; room.LevelLimits = (int)room.GetLevelLimit(this.m_player); } room.UpdateRoom(this.m_name, this.m_password, this.m_roomType, this.m_timeType, 0); if (this.m_roomType == eRoomType.Match) { if (BattleMgr.IsOpenAreaFight) { room.IsArea = true; } } GSPacketIn pkg = this.m_player.Out.SendRoomCreate(room); room.AddPlayerUnsafe(this.m_player); RoomMgr.WaitingRoom.SendUpdateRoom(room); } else { Console.WriteLine(LanguageMgr.GetTranslation("CreateRoomAction.MaxRoom", new object[0])); this.m_player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("CreateRoomAction.MaxRoom", new object[0])); } } }
public void SendUpdateRoom(BaseRoom room) { GamePlayer[] players = GetPlayersSafe(); GSPacketIn pkg = null; foreach (GamePlayer p in players) { if (pkg == null) { pkg = p.Out.SendUpdateRoomList(room); } else { p.Out.SendTCP(pkg); } } }
public void Execute() { if (m_player.CurrentRoom != null) { m_player.CurrentRoom.RemovePlayerUnsafe(m_player); } if (m_player.IsActive == false) { return; } BaseRoom[] rooms = RoomMgr.Rooms; BaseRoom room = null; for (int i = 0; i < rooms.Length; i++) { if (rooms[i].IsUsing == false) { room = rooms[i]; break; } } if (room != null) { RoomMgr.WaitingRoom.RemovePlayer(m_player); room.Start(); //探险默认使用普通难度等级 if (m_roomType == eRoomType.Exploration) { room.HardLevel = eHardLevel.Normal; room.LevelLimits = (int)room.GetLevelLimit(m_player); } room.UpdateRoom(m_name, m_password, m_roomType, m_timeType, 0); GSPacketIn pkg = m_player.Out.SendRoomCreate(room); room.AddPlayerUnsafe(m_player); RoomMgr.WaitingRoom.SendUpdateRoom(room); } }
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 bool AddRoom(Game.Server.Rooms.BaseRoom room) { bool result = false; lock (m_rooms) { if (!m_rooms.ContainsKey(room.RoomId)) { m_rooms.Add(room.RoomId, room); result = true; } } if (result) { m_server.SendAddRoom(room); } return(result); }
public void Execute() { if (this.m_player.CurrentRoom != null) { this.m_player.CurrentRoom.RemovePlayerUnsafe(this.m_player); } if (!this.m_player.IsActive) { return; } BaseRoom[] rooms = RoomMgr.Rooms; BaseRoom baseRoom = null; for (int i = 0; i < rooms.Length; i++) { if (!rooms[i].IsUsing) { baseRoom = rooms[i]; break; } } if (baseRoom != null) { RoomMgr.WaitingRoom.RemovePlayer(this.m_player); baseRoom.Start(); if (this.m_roomType == eRoomType.Dungeon) { baseRoom.HardLevel = eHardLevel.Normal; baseRoom.LevelLimits = (int)baseRoom.GetLevelLimit(this.m_player); } baseRoom.UpdateRoom(this.m_name, this.m_password, this.m_roomType, this.m_timeType, 0); this.m_player.Out.SendRoomCreate(baseRoom); baseRoom.AddPlayerUnsafe(this.m_player); RoomMgr.WaitingRoom.SendUpdateRoom(baseRoom); } }
public static List <BaseRoom> GetAllUsingRoom() { List <BaseRoom> list = new List <BaseRoom>(); BaseRoom[] rooms; Monitor.Enter(rooms = RoomMgr.m_rooms); try { BaseRoom[] rooms2 = RoomMgr.m_rooms; for (int i = 0; i < rooms2.Length; i++) { BaseRoom room = rooms2[i]; if (room.IsUsing) { list.Add(room); } } } finally { Monitor.Exit(rooms); } return(list); }
public static void CancelPickup(BattleServer server, BaseRoom room) { AddAction(new CancelPickupAction(server, room)); }
public GSPacketIn SendRoomChange(Game.Server.Rooms.BaseRoom room) { throw new NotImplementedException(); }
public GSPacketIn SendRoomPairUpCancel(Game.Server.Rooms.BaseRoom room) { throw new NotImplementedException(); }
public static void UpdateRoomGameType(BaseRoom room, eRoomType roomType, byte timeMode, eHardLevel hardLevel, int levelLimits, int mapId, string password, string roomname, bool isCrosszone, bool isOpenBoss) { AddAction(new RoomSetupChangeAction(room, roomType, timeMode, hardLevel, levelLimits, mapId, password, roomname, isCrosszone, isOpenBoss)); }
public GSPacketIn SendRoomPairUpCancel(BaseRoom room) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_PAIRUP_CANCEL); SendTCP(pkg); return pkg; }
public GSPacketIn SendRoomChange(BaseRoom room) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_ROOM_SETUP_CHANGE); pkg.WriteInt(room.MapId); pkg.WriteByte((byte)room.RoomType); pkg.WriteByte((byte)room.TimeMode); pkg.WriteByte((byte)room.HardLevel); pkg.WriteInt(room.LevelLimits); pkg.WriteBoolean(false); SendTCP(pkg); return pkg; }
public void SendUpdateRoom(BaseRoom room) { }
public GSPacketIn SendGameRoomInfo(GamePlayer player, BaseRoom game) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_ROOM_CREATE, player.PlayerCharacter.ID); //pkg.WriteInt(game.ID); //pkg.WriteByte((byte)game.RoomType); //pkg.WriteByte(game.ScanTime); //pkg.WriteByte((byte)game.Count); //pkg.WriteByte((byte)(game.OpenState.Length - game.CloseTotal())); //pkg.WriteBoolean(game.Pwd != "" ? true : false); //pkg.WriteInt(game.MapIndex); //pkg.WriteBoolean(game.GameState == eGameState.FREE ? false : true); //pkg.WriteByte((byte)game.GameMode); //pkg.WriteString(game.Name); //pkg.WriteByte((byte)game.GameClass); //SendTCP(pkg); return pkg; }
public StartGameAction(BaseRoom room) { m_room = room; }
public CancelPickupAction(BattleServer server,BaseRoom room) { m_room = room; m_server = server; }
public void SendChangeGameType(BaseRoom room) { GSPacketIn pkg = new GSPacketIn((byte)eFightPackageType.CHANGE_GAME_TYPE) { Parameter1 = room.RoomId }; pkg.WriteInt((int)room.GameType); SendTCP(pkg); }
public void Execute() { if (m_player.IsActive == false) { return; } if (m_player.CurrentRoom != null) { m_player.CurrentRoom.RemovePlayerUnsafe(m_player); } BaseRoom[] rooms = RoomMgr.Rooms; BaseRoom rm = null; if (m_roomId == -1) { rm = FindRandomRoom(rooms); if (rm == null) { m_player.Out.SendMessage(eMessageType.ERROR, "暂时没有合适的房间,请稍后重试!"); m_player.Out.SendRoomLoginResult(false); return; } } else { rm = rooms[m_roomId - 1]; } if (!rm.IsUsing) { m_player.Out.SendMessage(eMessageType.Normal, "房间不存在!"); return; } if (rm.PlayerCount == rm.PlacesCount) { m_player.Out.SendMessage(eMessageType.ERROR, "房间人数已满!"); } else { if (rm.NeedPassword == false || rm.Password == m_pwd) { if (rm.Game == null || rm.Game.CanAddPlayer()) { if (rm.RoomType == eRoomType.Exploration && rm.LevelLimits > (int)rm.GetLevelLimit(m_player)) { m_player.Out.SendMessage(eMessageType.ERROR, "您的等级和该房间要求等级不符!"); return; } RoomMgr.WaitingRoom.RemovePlayer(m_player); m_player.Out.SendRoomLoginResult(true); m_player.Out.SendRoomCreate(rm); if (rm.AddPlayerUnsafe(m_player)) { if (rm.Game != null) { rm.Game.AddPlayer(m_player); } } RoomMgr.WaitingRoom.SendUpdateRoom(rm); m_player.Out.SendRoomChange(rm); } } else { m_player.Out.SendMessage(eMessageType.ERROR, "房间密码错误"); m_player.Out.SendRoomLoginResult(false); } } }
public ExitRoomAction(BaseRoom room, GamePlayer player) { this.m_room = room; this.m_player = player; }
public StartProxyGameAction(BaseRoom room,ProxyGame game) { m_room = room; m_game = game; }
public CancelPickupAction(BattleServer server, BaseRoom room) { this.m_room = room; this.m_server = server; }
public GSPacketIn SendRoomCreate(BaseRoom room) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_ROOM_CREATE); pkg.WriteInt(room.RoomId); pkg.WriteByte((byte)room.RoomType); pkg.WriteByte((byte)room.HardLevel); pkg.WriteByte((byte)room.TimeMode); pkg.WriteByte((byte)room.PlayerCount); pkg.WriteByte((byte)room.PlacesCount); pkg.WriteBoolean(string.IsNullOrEmpty(room.Password) ? false : true); pkg.WriteInt(room.MapId); pkg.WriteBoolean(room.IsPlaying); pkg.WriteString(room.Name); pkg.WriteByte((byte)room.GameType); pkg.WriteInt(room.LevelLimits); pkg.WriteBoolean(false); SendTCP(pkg); return pkg; }
public void SendRoomSetupChange(BaseRoom room) { if (m_host != null) { GSPacketIn pkg = m_host.Out.SendRoomChange(room); SendToAll(pkg); } }
public GSPacketIn SendRoomType(GamePlayer player, BaseRoom game) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_PAIRUP_ROOM_SETUP); pkg.WriteByte((byte)game.GameStyle); pkg.WriteInt((int)game.GameType); SendTCP(pkg); return pkg; }
public static void KickPlayer(BaseRoom baseRoom, byte index) { AddAction(new KickPlayerAction(baseRoom, index)); }
public GSPacketIn SendRoomClear(GamePlayer player, BaseRoom game) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_ROOM_CLEAR, player.PlayerCharacter.ID); pkg.WriteInt(game.RoomId); SendTCP(pkg); return pkg; }
public static void StartProxyGame(BaseRoom room, ProxyGame game) { AddAction(new StartProxyGameAction(room, game)); }
public static void ExitRoom(BaseRoom room, GamePlayer player) { AddAction(new ExitRoomAction(room, player)); }
public KickPlayerAction(BaseRoom room, int place) { m_room = room; m_place = place; }
public static void StartGameMission(BaseRoom room) { AddAction(new StartGameMissionAction(room)); }
public bool RemoveRoom(BaseRoom room) { bool result = false; lock (m_rooms) { result = m_rooms.ContainsKey(room.RoomId); } if (result) { m_server.SendRemoveRoom(room); } return result; }
public static void StopProxyGame(BaseRoom room) { AddAction(new StopProxyGameAction(room)); }
public static void UpdateRoomPos(BaseRoom room, int pos, bool isOpened, int place, int placeView) { AddAction(new UpdateRoomPosAction(room, pos, isOpened, place, placeView)); }
public void Execute() { if (m_player.IsActive == false) { return; } if (m_player.CurrentRoom != null) { m_player.CurrentRoom.RemovePlayerUnsafe(m_player); } BaseRoom[] rooms = RoomMgr.Rooms; BaseRoom rm = null; if (m_roomId == -1) { rm = FindRandomRoom(rooms); if (rm == null) { m_player.Out.SendMessage(eMessageType.ERROR, "Không có phòng game nào!"); m_player.Out.SendRoomLoginResult(false); return; } } else { rm = rooms[m_roomId - 1]; } if (!rm.IsUsing) { m_player.Out.SendMessage(eMessageType.Normal, "Phòng đang sử dụng!"); return; } if (rm.PlayerCount == rm.PlacesCount) { m_player.Out.SendMessage(eMessageType.ERROR, "Phòng đã đấy!"); } else { if (rm.NeedPassword == false || rm.Password == m_pwd) { if (rm.Game == null || rm.Game.CanAddPlayer()) { if (rm.LevelLimits > (int)rm.GetLevelLimit(m_player)) { m_player.Out.SendMessage(eMessageType.ERROR, "Level chưa đủ!"); return; } RoomMgr.WaitingRoom.RemovePlayer(m_player); m_player.Out.SendRoomLoginResult(true); m_player.Out.SendRoomCreate(rm); if (rm.AddPlayerUnsafe(m_player)) { if (rm.Game != null) { rm.Game.AddPlayer(m_player); } } RoomMgr.WaitingRoom.SendUpdateRoom(rm); m_player.Out.SendRoomChange(rm); } } else { m_player.Out.SendMessage(eMessageType.ERROR, "Password không đúng!"); m_player.Out.SendRoomLoginResult(false); } } }
internal void SendRemoveRoom(Game.Server.Rooms.BaseRoom room) { GSPacketIn pkg = new GSPacketIn((int)eFightPackageType.GAME_PAIRUP_CANCEL); SendTCP(pkg, room); }
public GSPacketIn SendRoomType(Game.Server.GameObjects.GamePlayer player, Game.Server.Rooms.BaseRoom game) { throw new NotImplementedException(); }
public KickPlayerAction(BaseRoom room, int place) { this.m_room = room; this.m_place = place; }
public UpdateRoomPosAction(BaseRoom room, int pos,bool isOpened) { m_room = room; m_pos = pos; m_isOpened = isOpened; }
public void SendRemoveRoom(BaseRoom room) { GSPacketIn pkg = new GSPacketIn((int)eFightPackageType.ROOM_REMOVE); pkg.Parameter1 = room.RoomId; SendTCP(pkg); }
public UpdatePlayerStateAction(GamePlayer player, BaseRoom room, byte state) { m_player = player; m_state = state; m_room = room; }