void Update() { if (manager.state == NetworkState.Lobby && !uiCharacterCreation.IsVisible()) { panel.SetActive(true); if (manager.charactersAvailableMsg != null) { CharactersAvailableMsg.CharacterPreview[] characters = manager.charactersAvailableMsg.characters; UIUtils.BalancePrefabs(slotPrefab.gameObject, characters.Length, content); for (int i = 0; i < characters.Length; ++i) { GameObject prefab = manager.playerClasses.Find(p => p.name == characters[i].className); UICharacterSelectionSlot slot = content.GetChild(i).GetComponent <UICharacterSelectionSlot>(); slot.nameText.text = characters[i].name; slot.image.sprite = prefab.GetComponent <Player>().classIcon; slot.selectButton.interactable = ClientScene.localPlayer == null; int icopy = i; slot.selectButton.onClick.SetListener(() => { ClientScene.Ready(NetworkClient.connection); NetworkClient.connection.Send(new CharacterSelectMsg { value = icopy }); panel.SetActive(false); }); slot.deleteButton.onClick.SetListener(() => { uiConfirmation.Show( "Na pewno chcesz usunąć <b>" + characters[icopy].name + "</b>?", () => { NetworkClient.Send(new CharacterDeleteMsg { value = icopy }); } ); }); } createButton.interactable = characters.Length < manager.characterLimit; createButton.onClick.SetListener(() => { panel.SetActive(false); uiCharacterCreation.Show(); }); quitButton.onClick.SetListener(() => { NetworkManagerSurvival.Quit(); }); } } else { panel.SetActive(false); } }
void Update() { if (manager.state == NetworkState.Offline || manager.state == NetworkState.Handshake) { panel.SetActive(true); if (manager.IsConnecting()) { statusText.text = "Łączenie..."; } else if (manager.state == NetworkState.Handshake) { statusText.text = "Handshake..."; } else { statusText.text = ""; } registerButton.interactable = !manager.isNetworkActive; registerButton.onClick.SetListener(() => { uiPopup.Show(registerMessage); }); loginButton.interactable = !manager.isNetworkActive && auth.IsAllowedAccountName(accountInput.text); loginButton.onClick.SetListener(() => { manager.StartClient(); }); hostButton.interactable = Application.platform != RuntimePlatform.WebGLPlayer && !manager.isNetworkActive && auth.IsAllowedAccountName(accountInput.text); hostButton.onClick.SetListener(() => { manager.StartHost(); }); cancelButton.gameObject.SetActive(manager.IsConnecting()); cancelButton.onClick.SetListener(() => { manager.StopClient(); }); dedicatedButton.interactable = Application.platform != RuntimePlatform.WebGLPlayer && !manager.isNetworkActive; dedicatedButton.onClick.SetListener(() => { manager.StartServer(); }); quitButton.onClick.SetListener(() => { NetworkManagerSurvival.Quit(); }); auth.loginAccount = accountInput.text; auth.loginPassword = passwordInput.text; serverDropdown.interactable = !manager.isNetworkActive; serverDropdown.options = manager.serverList.Select( sv => new Dropdown.OptionData(sv.name) ).ToList(); manager.networkAddress = manager.serverList[serverDropdown.value].ip; } else { panel.SetActive(false); } }