示例#1
0
        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);
        }
示例#2
0
        public void LeaveRoom()
        {
            var userControler = DepenencyInjector.Resolve <IUserController>();
            var discordApi    = DepenencyInjector.Resolve <IDiscordApi>();

            PhotonNetwork.LeaveRoom();
            StartCoroutine(discordApi.PlayerLeft(userControler.GetUsername()));
        }
示例#3
0
 /// <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);
 }
示例#4
0
        /// <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;
        }
示例#5
0
 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>();
     }
 }
示例#6
0
        private void SetUserName()
        {
            var userController = DepenencyInjector.Resolve <IUserController>();

            PhotonNetwork.playerName = userController.GetUsername();
        }