public void ui_lobby_OnCharacterList(S2GC_CharacterListResponse list)
        {
            UI_CharacterList newList = new UI_CharacterList();

            newList.LobbyNumCharacters = list.Data.LobbyNumCharacters;
            newList.LobbyMaxCharacters = list.Data.LobbyMaxCharacters;
            if (newList.LobbyNumCharacters > 0)
            {
                for (int i = 0; i < list.Data.Characters.Count; i++)
                {
                    UI_Character newChar = new UI_Character();
                    newChar.CharacterIndex     = list.Data.Characters[i].CharacterIndex;
                    newChar.CharacterName      = list.Data.Characters[i].CharacterName;
                    newChar.CharacterGender    = list.Data.Characters[i].CharacterGender;
                    newChar.CharacterEyeShape  = list.Data.Characters[i].CharacterEyeShape;
                    newChar.CharacterEyeType   = list.Data.Characters[i].CharacterEyeType;
                    newChar.CharacterEyeColor  = list.Data.Characters[i].CharacterEyeColor;
                    newChar.CharacterFrontHair = list.Data.Characters[i].CharacterFrontHair;
                    newChar.CharacterBackHair  = list.Data.Characters[i].CharacterBackHair;
                    newChar.CharacterHairColor = list.Data.Characters[i].CharacterHairColor;
                    newList.Characters.Add(newChar);
                }
            }

            if (LoginUI_Root.activeSelf)
            {
                LoginUI_Root.SetActive(false);
            }
            if (!LobbyUI_Root.activeSelf)
            {
                LobbyUI_Root.SetActive(true);
            }

            Lobby.UpdateCharacterSelect(newList);
        }
示例#2
0
        public void UpdateCharacterSelect(UI_CharacterList list)
        {
            if (list != null)
            {
                CharacterList = list;
            }
            int numCharButtons = select_CharacterListParent.transform.childCount;

            for (int i = 0; i < numCharButtons; i++)
            {
                if (select_CharacterListParent.transform.GetChild(i).gameObject.name != "CreateButton")
                {
                    GameObject.Destroy(select_CharacterListParent.transform.GetChild(i).gameObject);
                }
            }

            foreach (UI_Character c in CharacterList.Characters)
            {
                GameObject newCharacterButton = GameObject.Instantiate(select_CharacterButtonPrefab, select_CharacterListParent.transform);
                newCharacterButton.name = c.CharacterName + "_Select";
                newCharacterButton.GetComponentInChildren <Text>().text = c.CharacterName;
                newCharacterButton.GetComponent <Button>().onClick.AddListener(delegate
                {
                    int tmpCI = c.CharacterIndex;
                    SelectCharacter(tmpCI);
                });
            }

            if (CharacterList.LobbyNumCharacters < CharacterList.LobbyMaxCharacters)
            {
                select_NewCharacterButton.gameObject.transform.SetAsLastSibling();
                select_NewCharacterButton.gameObject.SetActive(true);
            }
            else
            {
                select_NewCharacterButton.gameObject.SetActive(false);
            }

            LayoutRebuilder.ForceRebuildLayoutImmediate(select_CharacterListParent.GetComponent <RectTransform>());

            select_CharacterAmountText.text = CharacterList.LobbyNumCharacters + " / " + CharacterList.LobbyMaxCharacters;

            select_DeleteCharacterButton.interactable = false;

            select_UIRoot.SetActive(true);
            create_UIRoot.SetActive(false);

            if (CharacterList.LobbyNumCharacters > 0)
            {
                SelectCharacter(0);
            }
            else
            {
                if (preview_ModelInstance != null)
                {
                    Destroy(preview_ModelInstance);
                }
            }
        }