public string GetUsername() { var storage = DepenencyInjector.Resolve <IInternalStorage>(); PlayerPrefs.DeleteAll(); string defaultName = ""; Debug.Log("defaultName:" + defaultName); var userString = storage.GetValue("Name"); if (userString != "null") { // Auth'ed User defaultName = userString; Debug.Log("defaultName:" + defaultName); } else { if (PlayerPrefs.HasKey("PlayerName")) { defaultName = PlayerPrefs.GetString("PlayerName"); Debug.Log("defaultName:" + defaultName); } else { var rnd = new System.Random(); defaultName = "GuestUser#" + rnd.Next(1, 9000); Debug.Log("defaultName:" + defaultName); } } Debug.Log("defaultName:" + defaultName); return(defaultName); }
public void LeaveRoom() { var userControler = DepenencyInjector.Resolve <IUserController>(); var discordApi = DepenencyInjector.Resolve <IDiscordApi>(); PhotonNetwork.LeaveRoom(); StartCoroutine(discordApi.PlayerLeft(userControler.GetUsername())); }
/// <summary> /// MonoBehaviour method called on GameObject by Unity during initialization phase. /// </summary> void Start() { DepenencyInjector.SetupInjection(); this.SetUserName(); discordApi = DepenencyInjector.Resolve <IDiscordApi>(); progressLabel.SetActive(false); controlPanel.SetActive(true); }
/// <summary> /// MonoBehaviour method called on GameObject by Unity during initialization phase. /// </summary> void Start() { var storage = DepenencyInjector.Resolve <IInternalStorage>(); string defaultName = ""; InputField _inputField = this.GetComponent <InputField>(); Debug.Log("defaultName:" + defaultName); if (_inputField != null) { var userString = storage.GetValue("Name"); if (userString != "null") { // Auth'ed User defaultName = userString; Debug.Log("defaultName:" + defaultName); } else { if (PlayerPrefs.HasKey(playerNamePrefKey)) { defaultName = PlayerPrefs.GetString(playerNamePrefKey); Debug.Log("defaultName:" + defaultName); } else { var rnd = new System.Random(); defaultName = "GuestUser#" + rnd.Next(1, 9000); Debug.Log("defaultName:" + defaultName); } } } Debug.Log("defaultName:" + defaultName); _inputField.text = defaultName; PhotonNetwork.playerName = defaultName; }
public void Start() { DepenencyInjector.SetupInjection(); if (playerPrefab == null) { Debug.LogError("<Color=Red><a>Missing</a></Color> playerPrefab Reference. Please set it up in GameObject 'Game Manager'", this); } else { Debug.Log("We are Instantiating LocalPlayer from " + Application.loadedLevelName); if (PlayerMovementManager.LocalPlayerInstance == null) { Debug.Log("We are Instantiating LocalPlayer from " + Application.loadedLevelName); // we're in a room. spawn a character for the local player. it gets synced by using PhotonNetwork.Instantiate GameObject go = PhotonNetwork.Instantiate(this.playerPrefab.name, new Vector3(0f, 5f, 0f), Quaternion.identity, 0); } else { Debug.Log("Ignoring scene load for " + Application.loadedLevelName); } normalCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); overheadCamera = GameObject.FindGameObjectWithTag("OverheadCamera").GetComponent <Camera>(); } }
private void SetUserName() { var userController = DepenencyInjector.Resolve <IUserController>(); PhotonNetwork.playerName = userController.GetUsername(); }