private void Awake() { string[] args = Environment.GetCommandLineArgs(); bool allowWebplayerConnection = true; bool loadedRoom = false; for (int i = 0; i < args.Length; i++) { if (i == args.Length - 1 || string.IsNullOrEmpty(args[i + 1])) { break; } string next = args[i + 1]; if (args[i] == "-room") { RoomName = next; BeardedManStudios.Network.Unity.UnitySceneManager.LoadScene(RoomName); loadedRoom = true; //if (!Application.isLoadingLevel) //{ // loadedRoom = false; // // TODO: Add an error to the logging system // Application.Quit(); //} } else if (args[i] == "-arbitor") { ushort port; if (!ushort.TryParse(next, out port)) { // TODO: Add an error to the logging system Application.Quit(); } ArbitorPort = port; } else if (args[i] == "-port") { ushort port; if (!ushort.TryParse(next, out port)) { // TODO: Add an error to the logging system Application.Quit(); } StartOnPort = port; } else if (args[i] == "-players") { int maxPlayers; if (!int.TryParse(next, out maxPlayers)) { // TODO: Add an error to the logging system Application.Quit(); } MaxPlayers = maxPlayers; } else if (args[i] == "-protocol") { if (next == "tcp") { protocol = Networking.TransportationProtocolType.TCP; } else if (next == "udp") { protocol = Networking.TransportationProtocolType.UDP; } } else if (args[i] == "-identifier") { ID = next; } else if (args[i] == "-nowebplayer") { allowWebplayerConnection = false; } } // TODO: Allow the room thing to set the protocol type if (loadedRoom) { Networking.Host(StartOnPort, protocol, MaxPlayers, allowWebplayerConnection); } }
private void Awake() { string[] args = Environment.GetCommandLineArgs(); bool allowWebplayerConnection = true; bool loadedRoom = false; for (int i = 0; i < args.Length; i++) { if (i == args.Length - 1 || string.IsNullOrEmpty(args[i + 1])) break; string next = args[i + 1]; if (args[i] == "-room") { RoomName = next; Application.LoadLevel(RoomName); loadedRoom = true; if (!Application.isLoadingLevel) { loadedRoom = false; // TODO: Add an error to the logging system Application.Quit(); } } else if (args[i] == "-arbitor") { ushort port; if (!ushort.TryParse(next, out port)) { // TODO: Add an error to the logging system Application.Quit(); } ArbitorPort = port; } else if (args[i] == "-port") { ushort port; if (!ushort.TryParse(next, out port)) { // TODO: Add an error to the logging system Application.Quit(); } StartOnPort = port; } else if (args[i] == "-players") { int maxPlayers; if (!int.TryParse(next, out maxPlayers)) { // TODO: Add an error to the logging system Application.Quit(); } MaxPlayers = maxPlayers; } else if (args[i] == "-protocol") { if (next == "tcp") protocol = Networking.TransportationProtocolType.TCP; else if (next == "udp") protocol = Networking.TransportationProtocolType.UDP; } else if (args[i] == "-identifier") ID = next; else if (args[i] == "-nowebplayer") allowWebplayerConnection = false; } // TODO: Allow the room thing to set the protocol type if (loadedRoom) Networking.Host(StartOnPort, protocol, MaxPlayers, allowWebplayerConnection); }