//a method used to change the multiplayer's menu public void EnableMenu(MultiplayerMenu targetMenu) { if (manager.InGame) //if we're already in the game { return; //menu has been already destroyed, do not continue } mainMPMenu.gameObject.SetActive(targetMenu == MultiplayerMenu.main); loadingMenu.gameObject.SetActive(targetMenu == MultiplayerMenu.loading); lobbyMenu.gameObject.SetActive(targetMenu == MultiplayerMenu.lobby); mapMenu.gameObject.SetActive(targetMenu == MultiplayerMenu.lobby); currentMenu = targetMenu; if (currentMenu == MultiplayerMenu.main) //if we're back to the main menu { manager.IsHost = false; //if player was hosting, then reset that. addressInputField.text = manager.networkAddress; //display the current address and port portInputField.text = transport.port.ToString(); } if (currentMenu == MultiplayerMenu.lobby) //if we're currently in the lobby { lobbyName.text = manager.networkAddress + ":" + transport.port; //show the lobby's address as the name } }
private void btn_multi_Click(object sender, RoutedEventArgs e) { Window multiplayer = new MultiplayerMenu(this); this.Hide(); multiplayer.ShowDialog(); }
void SetupMultiplayerMenu() { multiplayerMenu = Instantiate(multiplayerPrefab, menuPanelParent).GetComponent <MultiplayerMenu>(); multiplayerMenu.gameObject.SetActive(false); multiplayerMenu.Setup(); multiplayerMenu.SetCloseEvent(CloseMultiplayerMenu); }
public static Node MultiplayerMenu() { Node menuInstance = Session.Instance("res://Scenes/Prefabs/Menus/MultiplayerMenu.tscn"); MultiplayerMenu menu = (MultiplayerMenu)menuInstance; Session.session.AddChild(menu); menu.Init(); return(menuInstance); }
public void Successful() { MultiplayerMenu multiplayerMenu = this.GetComponentInParent <MultiplayerMenu>(); if (multiplayerMenu) { multiplayerMenu.SubmitCreateRoomDetails(); } }
void Start() { _mainMenue = FindObjectOfType <MainMenue>(); _singleplayerMenu = FindObjectOfType <SingleplayerMenu>(); _multiplayerMenu = FindObjectOfType <MultiplayerMenu>(); _singleplayerButton.onClick.AddListener(OnSingleplayerClick); _multiplayerButton.onClick.AddListener(OnMultiplayerClick); _backButton.onClick.AddListener(OnBackClick); }
public void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Debug.Log("Instance already exists, destroying object!"); } }
void Awake() { playerNameInput = PlayerPrefs.GetString("playerName", ""); requirePlayerName = true; myWindowRect = new Rect(); joinMenuScript = GetComponent <JoinMenu>(); singleplayermenu = GetComponent <Player1Menu>(); gameLobbyScript = GetComponent <GameLobby>(); multiplayerScript = GetComponent <MultiplayerMenu>(); //OpenMenu("multiplayer"); }
public override void OnInspectorGUI() { MultiplayerMenu mpMenu = target as MultiplayerMenu; mpMenu.gameNameInput = (UIInput)EditorGUILayout.ObjectField("Game Name Input:", mpMenu.gameNameInput, typeof(UIInput), true); mpMenu.IPInput = (UIInput)EditorGUILayout.ObjectField("IP Input:", mpMenu.IPInput, typeof(UIInput), true); mpMenu.portInput = (UIInput)EditorGUILayout.ObjectField("Port Input:", mpMenu.portInput, typeof(UIInput), true); mpMenu.portForwardCheckbox = (UIToggle)EditorGUILayout.ObjectField("Port Forward Toggle:", mpMenu.portForwardCheckbox, typeof(UIToggle), true); mpMenu.hostPortInput = (UIInput)EditorGUILayout.ObjectField("Host Port Input:", mpMenu.hostPortInput, typeof(UIInput), true); mpMenu.hostLocalCheckbox = (UIToggle)EditorGUILayout.ObjectField("Host Local Toggle:", mpMenu.hostLocalCheckbox, typeof(UIToggle), true); mpMenu.maxPlayerSlider = (SliderAction)EditorGUILayout.ObjectField("Max Player Slider:", mpMenu.maxPlayerSlider, typeof(SliderAction), true); mpMenu.gameDurationSlider = (SliderAction)EditorGUILayout.ObjectField("Game Duration Slider:", mpMenu.gameDurationSlider, typeof(SliderAction), true); mpMenu.mapSelection = (GameObject)EditorGUILayout.ObjectField("Map Selection:", mpMenu.mapSelection, typeof(GameObject), true); DarkRef.GUISeparator(5); if (mpMenu.cachedNetworking == null) { mpMenu.cachedNetworking = (GameObject)EditorGUILayout.ObjectField("Cached Networking:", mpMenu.cachedNetworking, typeof(GameObject), true); DarkRef.GUISeparator(5); } EditorGUILayout.LabelField("HOST SERVER MENU", EditorStyles.boldLabel); EditorGUI.indentLevel += 1; EditorGUIUtility.labelWidth = 140f; mpMenu.mapSelectionBox = (UISprite)EditorGUILayout.ObjectField("Map Selection Box:", mpMenu.mapSelectionBox, typeof(UISprite), true); mpMenu.sliderStart = (Transform)EditorGUILayout.ObjectField("Selection Start:", mpMenu.sliderStart, typeof(Transform), true); mpMenu.mapSpacing = EditorGUILayout.FloatField("Selection Spacing:", mpMenu.mapSpacing); GUILayout.Space(5f); mpMenu.backButton = (GameObject)EditorGUILayout.ObjectField("Back Button:", mpMenu.backButton, typeof(GameObject), true); mpMenu.hostServerButton = (UIButton)EditorGUILayout.ObjectField("Host Server Button:", mpMenu.hostServerButton, typeof(UIButton), true); mpMenu.editServerButton = (UIButton)EditorGUILayout.ObjectField("Edit Server Button:", mpMenu.editServerButton, typeof(UIButton), true); mpMenu.moreInfoButton = (UIButton)EditorGUILayout.ObjectField("More Info Button:", mpMenu.moreInfoButton, typeof(UIButton), true); EditorGUI.indentLevel -= 1; EditorGUIUtility.LookLikeControls(); DarkRef.GUISeparator(5); mpMenu.mServerStatus = (UILabel)EditorGUILayout.ObjectField("Server Status:", mpMenu.mServerStatus, typeof(UILabel), true); mpMenu.mServerPing = (UILabel)EditorGUILayout.ObjectField("Server Ping:", mpMenu.mServerPing, typeof(UILabel), true); mpMenu.mCheckingIcon = (UISprite)EditorGUILayout.ObjectField("Checking Icon:", mpMenu.mCheckingIcon, typeof(UISprite), true); mpMenu.mServerPingButton = (UIButton)EditorGUILayout.ObjectField("Ping Button:", mpMenu.mServerPingButton, typeof(UIButton), true); mpMenu.mSettingControl = (GM_SettingsControl)EditorGUILayout.ObjectField("Settings Control:", mpMenu.mSettingControl, typeof(GM_SettingsControl), true); if (GUI.changed) { EditorUtility.SetDirty(mpMenu); } }
public MultiplayerScreen(MainWindow window) : base(window, "Multiplayer") { debugRenderer = Renderer.GetRenderer3D <DebugRenderer>(); gamemodes = new Dictionary <GamemodeType, NetworkedGamemode>() { { GamemodeType.TDM, new TDMGamemode(this) }, { GamemodeType.CTF, new CTFGamemode(this) } }; // Build the UI elements theme = AssetManager.CreateDefaultGameTheme(); font = theme.GetField <BMPFont>(null, "SmallFont"); hud = new HUD(Renderer); loadingBar = new MultiplayerLoadingBar(GUISystem, theme); chat = new ChatBox(new UDim2(0, 40, 1f, -240), new UDim2(0, 350, 0, 165), theme, this); menu = new MultiplayerMenu(GUISystem, theme, Window); menu.OnClosed += Menu_OnClosed; announcementLabel = new GUILabel(new UDim2(0.5f, 0, 0.5f, 0), UDim2.Zero, "", TextAlign.Center, theme); announcementLabel.Font = AssetManager.LoadFont("karmasuture-32"); announcementLabel.Visible = false; // Add each UI element GUIArea.AddTopLevel(chat, announcementLabel); GUISystem.Add(loadingBar, menu); Windows.Add(loadingBar); Windows.Add(menu); // Setup default multiplayer cvars DashCMD.SetCVar("cl_impacts", false); DashCMD.SetCVar("cl_interp", 0.5f); // Client interpolation with server position DashCMD.SetCVar("cl_interp_movement_smooth", 1f); // Client player movement smoothing (1f = no smoothing) DashCMD.SetCVar("cl_interp_rep", 20f); // Replicated entities interpolation DashCMD.SetCVar("cl_max_error_dist", 12f); // Max distance the client's position can be off from the server's }
// Add a player selector private static void MultiplayerMenu_ctor(On.Menu.MultiplayerMenu.orig_ctor orig, MultiplayerMenu self, ProcessManager manager) { orig(self, manager); // Place relative to the first join button self.pages[0].subObjects.Add(new PlayerSelector(self, self.pages[0], self.playerJoinButtons[0].pos + new Vector2(-1f, -40f))); }
void Awake() { //Static initialization Instance = this; AudioListener.pause = false; possibleGameTypes = new Dictionary <string, Type>(); possibleGameTypes.Add("Team Deathmatch", typeof(TeamDeathmatch)); possibleGameTypes.Add("Deathmatch", typeof(Deathmatch)); //Automatically initialize the lists, DON'T TOUCH! if (gameTypeIndexes == null || gameTypeNames == null) { gameTypeIndexes = new Dictionary <string, int>(); gameTypeNames = new Dictionary <int, string>(); List <string> gameTypeKeys = new List <string>(possibleGameTypes.Keys); for (int i = 0; i < gameTypeKeys.Count; i++) { gameTypeIndexes.Add(gameTypeKeys[i], i); gameTypeNames.Add(i, gameTypeKeys[i]); } } Topan.Network.sendNetworkViewsOnConnect = false; Topan.Network.enableDebugging = true; tooltipInfo = moreInfoButton.GetComponent <ShowTooltip>(); ServerEditMode(false); mapSelectionBox.transform.localPosition = sliderStart.localPosition; for (int i = 0; i < StaticMapsList.mapsArraySorted.Count; i++) { GameObject newHostMap = (GameObject)Instantiate(mapSelection); newHostMap.transform.parent = sliderStart.parent; newHostMap.transform.localPosition = sliderStart.localPosition + (Vector3.right * mapSpacing * i); newHostMap.transform.localRotation = sliderStart.localRotation; newHostMap.transform.localScale = Vector3.one; ButtonAction hostba = newHostMap.GetComponent <ButtonAction>(); hostba.sendMessage.numericalMessage.enabled = true; hostba.sendMessage.numericalMessage.isInt = true; hostba.sendMessage.numericalMessage.messageName = "SelectMap"; hostba.sendMessage.numericalMessage.messageReceiver = gameObject; hostba.sendMessage.numericalMessage.valueToSend = i; MapGUI MGUI = newHostMap.GetComponent <MapGUI>(); Map thisMap = StaticMapsList.mapsArraySorted[i]; MGUI.nameLabel.text = thisMap.mapName; MGUI.description = thisMap.mapName + "|| " + thisMap.loaderSubheader; if (thisMap.previewIcon != null) { MGUI.mapScreenshot.mainTexture = thisMap.previewIcon; } } selectedMap = Mathf.Clamp(PlayerPrefs.GetInt("SavedMapIndex", 0), 0, StaticMapsList.mapsArraySorted.Count - 1); UpdateSelection(); IPInput.value = PlayerPrefs.GetString("SavedIPConnect", "127.0.0.1"); portInput.value = PlayerPrefs.GetString("SavedPortConnect", "7100"); pingLimitInput.value = PlayerPrefs.GetString("SavedPingLimit", "9999"); portForwardCheckbox.value = (PlayerPrefs.GetInt("PortForward", 0) == 1) ? true : false; hostLocalCheckbox.value = (PlayerPrefs.GetInt("LocalServer", 0) == 1) ? true : false; mpErrorTooltip.text = "Validating client version..."; InvokeRepeating("GetModeSettings", 0f, 1f); //For the clients cInput.Init(); //Initialize cInput at start of game, so we can avoid initializing during gameplay. }
public void EnterMultiplayerMenu() { currentGameState = GameState.Multiplayer; multiplayer_menu = new MultiplayerMenu(this); }
IEnumerator LoginUser() { WWWForm form = new WWWForm(); form.AddField("name", nameField.text); form.AddField("password", passwordField.text); UnityWebRequest www = UnityWebRequest.Post($"http://{NetworkConstants.IpAddress}/sqlconnect/login.php", form); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); InfoText.text = www.error; } else { string[] serverData = www.downloadHandler.text.Split('\t'); if (serverData[0] == "0") { Debug.Log("User logged in"); InfoText.text = "User logged in"; DBManager.username = nameField.text; DBManager.achievements = new HashSet <string>(serverData[1].Split(',').ToList()); DBManager.face_recognition_image_location = serverData[2]; Debug.Log(serverData[3]); DBManager.role_id = System.Convert.ToInt32(serverData[3]); DBManager.id = System.Convert.ToInt32(serverData[4]); // TODO: microlesson setup DBManager.microLesson.LessonName = "virtual_reality"; //TODO: add presentation_ppt_content to DB DBManager.microLesson.presentation_ppt_content = $"http://{NetworkConstants.IpAddress}/presentations/{DBManager.microLesson.LessonName}/"; // C:\MAMP\htdocs\presentations\acauser123\virtual_reality Debug.Log(@"C:\MAMP\htdocs\Python\face_recognize_webcam.py" + @" ..\" + DBManager.face_recognition_image_location); Debug.Log(DBManager.microLesson.presentation_ppt_content); //Without face detection -> GoToVirtualRoom(); MultiplayerMenu sn = multiPlayerMenu.GetComponent <MultiplayerMenu>(); if (DBManager.role_id == 1) { sn.Host(); } else if (DBManager.role_id == 2) { sn.Connect(); } // load ip adress form = new WWWForm(); form.AddField("user_id", DBManager.id); www = UnityWebRequest.Post($"http://{NetworkConstants.IpAddress}/sqlconnect/getIpAddress.php", form); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); InfoText.text = www.error; } else { Debug.Log("IP address " + www.downloadHandler.text); // TODO: ip address for networking, NetworkConstants.IpAddress is db address //yield return new WaitForSeconds(1); //Wait //FaceRecognitionManager.Start(); GoToVirtualRoom(); } } else { Debug.Log("User logged in failed. Error #" + www.downloadHandler.text); InfoText.text = "User logged in failed. Error #" + www.downloadHandler.text; } } }