void OnGUI() { if (!showGUI) { return; } int xpos = 10 + offsetX; int ypos = 40 + offsetY; const int spacing = 24; bool noConnection = (manager.client == null || manager.client.connection == null || manager.client.connection.connectionId == -1); if (!manager.IsClientConnected() && !NetworkServer.active && manager.matchMaker == null) { if (noConnection) { if (UnityEngine.Application.platform != RuntimePlatform.WebGLPlayer) { if (GUI.Button(new Rect(xpos, ypos, 200, 20), "LAN Host")) { manager.StartHost(); } ypos += spacing; } if (GUI.Button(new Rect(xpos, ypos, 105, 20), "LAN Client")) { //Make sure seat not taken TableSpawnNetworkManager tableManager = manager as TableSpawnNetworkManager; if (tableManager != null) { //if (tableManager.SeatIsOccupied()) { //TODO: This doesn't quite work. Need to check this ON SERVER. //Seat is occupied, do not connect //tableManager.ShowLoginError(); //return; //} } manager.StartClient(); } manager.networkAddress = GUI.TextField(new Rect(xpos + 100, ypos, 95, 20), manager.networkAddress); ypos += spacing; if (UnityEngine.Application.platform == RuntimePlatform.WebGLPlayer) { // cant be a server in webgl build GUI.Box(new Rect(xpos, ypos, 200, 25), "( WebGL cannot be server )"); ypos += spacing; } else { if (GUI.Button(new Rect(xpos, ypos, 200, 20), "LAN Server Only")) { manager.StartServer(); } ypos += spacing; } } else { GUI.Label(new Rect(xpos, ypos, 200, 20), "Connecting to " + manager.networkAddress + ":" + manager.networkPort + ".."); ypos += spacing; if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Cancel Connection Attempt")) { manager.StopClient(); } } } else { if (NetworkServer.active) { string serverMsg = "Server: port=" + manager.networkPort; if (manager.useWebSockets) { serverMsg += " (Using WebSockets)"; } GUI.Label(new Rect(xpos, ypos, 300, 20), serverMsg); ypos += spacing; } if (manager.IsClientConnected()) { GUI.Label(new Rect(xpos, ypos, 300, 20), "Client: address=" + manager.networkAddress + " port=" + manager.networkPort); ypos += spacing; } } if (manager.IsClientConnected() && !ClientScene.ready) { if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Client Ready")) { ClientScene.Ready(manager.client.connection); if (ClientScene.localPlayers.Count == 0) { ClientScene.AddPlayer(0); } } ypos += spacing; } if (NetworkServer.active || manager.IsClientConnected()) { if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Stop")) { manager.StopHost(); } ypos += spacing; } if (!NetworkServer.active && !manager.IsClientConnected() && noConnection) { ypos += 10; if (UnityEngine.Application.platform == RuntimePlatform.WebGLPlayer) { GUI.Box(new Rect(xpos - 5, ypos, 220, 25), "(WebGL cannot use Match Maker)"); return; } if (manager.matchMaker == null) { if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Enable Match Maker")) { manager.StartMatchMaker(); } ypos += spacing; } else { if (manager.matchInfo == null) { if (manager.matches == null) { if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Create Internet Match")) { manager.matchMaker.CreateMatch(manager.matchName, manager.matchSize, true, "", "", "", 0, 0, manager.OnMatchCreate); } ypos += spacing; GUI.Label(new Rect(xpos, ypos, 100, 20), "Room Name:"); manager.matchName = GUI.TextField(new Rect(xpos + 100, ypos, 100, 20), manager.matchName); ypos += spacing; ypos += 10; if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Find Internet Match")) { manager.matchMaker.ListMatches(0, 20, "", false, 0, 0, manager.OnMatchList); } ypos += spacing; } else { for (int i = 0; i < manager.matches.Count; i++) { var match = manager.matches[i]; if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Join Match:" + match.name)) { manager.matchName = match.name; manager.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, manager.OnMatchJoined); } ypos += spacing; } if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Back to Match Menu")) { manager.matches = null; } ypos += spacing; } } if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Change MM server")) { m_ShowServer = !m_ShowServer; } if (m_ShowServer) { ypos += spacing; if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Local")) { manager.SetMatchHost("localhost", 1337, false); m_ShowServer = false; } ypos += spacing; if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Internet")) { manager.SetMatchHost("mm.unet.unity3d.com", 443, true); m_ShowServer = false; } ypos += spacing; if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Staging")) { manager.SetMatchHost("staging-mm.unet.unity3d.com", 443, true); m_ShowServer = false; } } ypos += spacing; GUI.Label(new Rect(xpos, ypos, 300, 20), "MM Uri: " + manager.matchMaker.baseUri); ypos += spacing; if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Disable Match Maker")) { manager.StopMatchMaker(); } ypos += spacing; } } }
// Use this for initialization void Start() { defaultColor = this.GetComponent <MeshRenderer>().material.color; changedColor = Color.green; currentInputs = new List <NeuralInput>(); neuralInputThreshold = 10f; neuralInputThresholdHigh = 20f; last_firing = -100f; hardNeuralCooldown = 1f; softNeuralCooldown = 3f; if (isLocalPlayer) { manager = GameObject.FindObjectOfType <TableSpawnNetworkManager>(); swapper = GameObject.FindObjectOfType <CameraSwapper>(); transform.position = manager.GetSpawnPosition(); CmdSetPlayerPosition(gameObject, manager.GetSpawnPosition()); Camera.main.transform.position = new Vector3(transform.position.x, transform.position.y, Camera.main.transform.position.z); GameObject.Find("CameraSwapper").GetComponent <CameraSwapper>().SetStartingPosition(Camera.main.transform.position); int[] pos = manager.GetPositionIdentities(); tableNum = pos[0]; seatNum = pos[1]; //Check if seat occupied (as long as not 0,0) if (tableNum != 0 || seatNum != 0) { GameObject taken = GameObject.Find(tableNum + "," + seatNum); if (taken) { Debug.Log("Seat taken!"); //Check if ISN Controller neuron = taken.GetComponent <Controller>(); //if (neuron.IsInstructorControlled()) { //Tell instructor to delete RemoveInstructorSpawnedNeuron(neuron.gameObject); //} //else { //TODO: Disconnect current user with message that seat is occupied. //} } } isInstructor = manager.GetInstructorStatus(); isBeingControlled = true; CmdApplyPositionNumbers(gameObject, tableNum, seatNum); CmdPlayerEntered(gameObject, tableNum, seatNum); if (isInstructor) { //Engage Instructor Mode GetComponent <SphereSwapper>().enabled = true; //Enable SphereSwapper so instructor can create and swap between spheres. GetComponent <SphereSwapper>().AddNewSphere(true, gameObject); //Add instructor as a sphere that can be swapped to. CmdEngageInstructorMode(gameObject); Camera.main.gameObject.transform.position = new Vector3(0, 0, -20); } else { //Disengage Instructor Mode CmdDisengageInstructorMode(gameObject); } } }