void Start() { if (userSessionController.userSessionInterfaceController == null) { userSessionController.userSessionInterfaceController = this; } player = userSessionController.Player; if (player != null && !string.IsNullOrEmpty(player.Name)) { UpdateElementText(player.Name, playerNameWelcomeValue); } else { UpdateElementText("New player", playerNameWelcomeValue); Utilities.ActivateOrDeactivateGameObject(true, newUserArea); } }
/// <summary> /// Sets the name in PlayerPrefs and posts a new entry on the scores table with the chosen name and 0 score. /// </summary> /// <param name="name">The player name</param> public void SubmitName(string name) { if (!string.IsNullOrEmpty(name)) { if (IsValidName(name)) { // Set the player prefs and prop PlayerName SetNewPlayerName(name); // Display success message and hide error //nameSuccessValidation.SetActive(true); Utilities.ActivateOrDeactivateGameObject(true, userSessionInterfaceController.nameSuccessValidation); //nameUnicityError.SetActive(false); Utilities.ActivateOrDeactivateGameObject(false, userSessionInterfaceController.nameUnicityError); // Interface userSessionInterfaceController.UpdateElementText(Player.Name, userSessionInterfaceController.playerNameWelcomeValue); //playerNameWelcomeValue.text = Player.Name; //editorForName.GetComponent<InputField>().interactable = false; userSessionInterfaceController.SetElementInteractable(false, userSessionInterfaceController.editorForName); AllPlayersList.Add(new Player { PlayerId = Player.PlayerId, Name = Player.Name, Score = "0" }); GameManagerController.Instance.Player = Player; // Post the new entry. StartCoroutine(PostScores("0", name, 0)); } else { //nameUnicityError.SetActive(true); Utilities.ActivateOrDeactivateGameObject(true, userSessionInterfaceController.nameUnicityError); } } }
private void LoginOrCreateNewUser() { // If there is an existing user, display welcome message // Else display the user creation area. if (PlayerPrefs.HasKey("PlayerName")) { Player.Name = PlayerPrefs.GetString("PlayerName"); userSessionInterfaceController.UpdateElementText(Player.Name, userSessionInterfaceController.playerNameWelcomeValue); //playerNameWelcomeValue.text = Player.Name; userSessionInterfaceController.SetElementInteractable(false, userSessionInterfaceController.editorForName); // editorForName.GetComponent<InputField>().text = Player.Name; userSessionInterfaceController.UpdateElementText(Player.Name, userSessionInterfaceController.editorForName, true); } else { // Interface userSessionInterfaceController.UpdateElementText("New user, please chose a name.", userSessionInterfaceController.playerNameWelcomeValue); //playerNameWelcomeValue.text = "New user, please chose a name."; userSessionInterfaceController.UpdateElementText(string.Empty, userSessionInterfaceController.editorForName, true); Utilities.ActivateOrDeactivateGameObject(true, userSessionInterfaceController.newUserArea); //newUserArea.SetActive(true); } }