static public void SendFireHandler(NetConnection connection, object data) { FireData fire = null; try { fire = GSrv.Deserialize <FireData>((byte[])data); } catch { return; } if (!PlayerCaches.AuthDone(connection)) { return; } if (PlayerCaches.InLobby(connection)) { return; } int roomid = PlayerCaches.GetRoomID(connection); if (Lobby.GetRoomState(roomid) == 0) { return; } Lobby.ReplyFire(connection, roomid, fire); }
static public void LeaveRoomHandler(NetConnection connection, object data) { if (!PlayerCaches.AuthDone(connection)) { return; } if (PlayerCaches.InLobby(connection)) { return; } int roomid = PlayerCaches.GetRoomID(connection); if (Lobby.GetRoomState(roomid) == 1) { return; } Lobby.LeaveRoom(connection, roomid); Lobby.SendRoomStateToAll(roomid); Lobby.CheckBattleStart(roomid); GSrv.Send(MessageType.ReplySuccessLeaveRoom, connection, NetDeliveryMethod.ReliableOrdered); LobbyState state = Lobby.GetLobbyState(); GSrv.Send(MessageType.ReplyLobbyState, GSrv.Serialize <LobbyState>(state), connection, NetDeliveryMethod.ReliableOrdered); }
static public void PushHandler(NetConnection connection, object data) { PushData push = null; try { push = GSrv.Deserialize <PushData>((byte[])data); } catch { return; } if (!PlayerCaches.AuthDone(connection)) { return; } if (PlayerCaches.InLobby(connection)) { return; } int roomid = PlayerCaches.GetRoomID(connection); if (Lobby.GetRoomState(roomid) == 0) { return; } Lobby.Push(connection, roomid, push); }
public static void Disconnect(NetConnection connection) { if (PlayerCaches.InLobby(connection)) { Console.WriteLine("Leave:" + players[connection].username); players.Remove(connection); } else { int roomid = PlayerCaches.GetRoomID(connection); rooms[roomid].Disconnect(connection); } PlayerCaches.Disconnect(connection); }
static public void SetBlockHandler(NetConnection connection, object data) { BlockData block = null; try { block = GSrv.Deserialize <BlockData>((byte[])data); } catch { return; } if (!PlayerCaches.AuthDone(connection)) { return; } if (PlayerCaches.InLobby(connection)) { return; } int roomid = PlayerCaches.GetRoomID(connection); if (Lobby.GetRoomState(roomid) == 0) { return; } if (!Env.IsInsideWorld(block.x, block.y, block.z)) { return; } if (Env.IsCorePos(block.x, block.y, block.z)) { return; } Lobby.ReplySetBlock(roomid, block); }
static public void TouchCoreHandler(NetConnection connection, object data) { if (!PlayerCaches.AuthDone(connection)) { return; } if (PlayerCaches.InLobby(connection)) { return; } int roomid = PlayerCaches.GetRoomID(connection); if (Lobby.GetRoomState(roomid) == 0) { return; } Lobby.TouchCore(connection, roomid); }
static public void ChangeFactionHandler(NetConnection connection, object data) { if (!PlayerCaches.AuthDone(connection)) { return; } if (PlayerCaches.InLobby(connection)) { return; } int roomid = PlayerCaches.GetRoomID(connection); if (Lobby.GetRoomState(roomid) == 1) { return; } Lobby.ChangeFaction(connection, roomid); Lobby.SendRoomStateToAll(roomid); }