protected void OnOkButtonClick() { if (_selectedCharacterIndex < 0 || _selectedCharacterIndex >= _charactersScrollRect.content.childCount) { return; } string characterName; string worldName; string worldAddress; int worldPort; if (_playdata != null) { var character = _playdata.Characters[_selectedCharacterIndex]; characterName = character.Name; var world = _playdata.FindWorld(character.WorldId); worldName = world.Name; worldAddress = world.GetAddress(OpenTibiaUnity.GameManager.ClientVersion, OpenTibiaUnity.GameManager.BuildVersion); worldPort = world.GetPort(OpenTibiaUnity.GameManager.ClientVersion, OpenTibiaUnity.GameManager.BuildVersion); } else { var character = _charactersList.Characters[_selectedCharacterIndex]; characterName = character.Name; var world = _charactersList.FindWorld(character.WorldId); worldName = world.Name; worldAddress = world.HostName; worldPort = world.Port; } DoEnterGame(characterName, worldAddress, worldName, worldPort); }
public void Setup(Session session, Playdata playData) { _session = session; _playdata = playData; _sessionKey = null; _accountName = null; _password = null; _token = null; foreach (Transform child in _charactersScrollRect.content) { Destroy(child.gameObject); } int characterCount = playData.Characters.Count; for (int i = 0; i < characterCount; i++) { var character = playData.Characters[i]; var world = playData.FindWorld(character.WorldId); string worldName = world.Name; if (world.PreviewState == 1) { worldName += " (Experimental)"; } if (OpenTibiaUnity.GameManager.ClientVersion >= 1200) { worldName += $"\n({world.GetPvPTypeDescription()})"; } var characterPanel = Instantiate(ModulesManager.Instance.CharacterPanelPrefab, _charactersScrollRect.content); characterPanel.ColorReversed = characterCount % 3 == 0; characterPanel.characterName.text = character.Name; characterPanel.worldName.text = worldName; characterPanel.toggleComponent.onValueChanged.AddListener((value) => OnCharacterValueToggleValueChanged(characterPanel, value)); characterPanel.toggleComponent.group = _charactersToggleGroup; characterPanel.GetComponent <LayoutElement>().minHeight = 34; characterPanel.onDoubleClick.AddListener(OnOkButtonClick); } OpenTibiaUnity.GameManager.InvokeOnMainThread(() => SelectCharacterByIndex(0)); }
public void Setup(Session session, Playdata playData) { _session = session; _playdata = playData; _sessionKey = null; _accountName = null; _password = null; _token = null; var content = _charactersScrollRect.content; foreach (Transform child in content) { Destroy(child.gameObject); } for (int i = 0; i < playData.Characters.Count; i++) { int characterIndex = i; var character = playData.Characters[i]; var characterPanel = Instantiate(ModulesManager.Instance.CharacterPanelPrefab); characterPanel.GetComponent <LayoutElement>().minHeight = 34; characterPanel.transform.SetParent(content); characterPanel.characterName.text = character.Name; var world = playData.FindWorld(character.WorldId); characterPanel.worldName.text = string.Format("{0}\n({1})", world.Name, world.GetPvPTypeDescription()); characterPanel.toggleComponent.onValueChanged.AddListener((value) => { if (value) { _selectedCharacterIndex = characterIndex; } }); characterPanel.toggleComponent.group = _charactersToggleGroup; characterPanel.onDoubleClick.AddListener(OnOkButtonClick); } _selectedCharacterIndex = -1; }
protected void OnOkButtonClick() { if (m_SelectedCharacterIndex < 0 || m_SelectedCharacterIndex >= m_CharactersScrollRect.content.childCount) { return; } var child = m_CharactersScrollRect.content.GetChild(m_SelectedCharacterIndex); var characterPanel = child.GetComponent <CharacterPanel>(); string characterName; string worldName; string worldAddress; int worldPort; if (m_Playdata != null) { var character = m_Playdata.Characters[m_SelectedCharacterIndex]; characterName = character.Name; var world = m_Playdata.FindWorld(character.WorldID); worldName = world.Name; worldAddress = world.GetAddress(OpenTibiaUnity.GameManager.ClientVersion, OpenTibiaUnity.GameManager.BuildVersion); worldPort = world.GetPort(OpenTibiaUnity.GameManager.ClientVersion, OpenTibiaUnity.GameManager.BuildVersion); } else { var character = m_CharactersList.Characters[m_SelectedCharacterIndex]; characterName = character.Name; var world = m_CharactersList.FindWorld(character.WorldID); worldName = world.Name; worldAddress = world.HostName; worldPort = world.Port; } DoEnterGame(characterName, worldAddress, worldName, worldPort); }