public EditorLocalUser(EGCLocalUser _localUser) { // Initialize properties m_userInfo = new EditorUser(_localUser.Info); IsAuthenticated = _localUser.IsAuthenticated; Friends = null; }
protected override void OnInitSuccess() { EGCLocalUser _localUser = m_authResponseData.GetIfAvailable <EGCLocalUser>(EditorGameCenter.kLocalUserInfoKey); // Update properties m_userInfo = new EditorUser(_localUser.Info); // Reset needless data m_authResponseData = null; base.OnInitSuccess(); }
public void Authenticate() { // Check if user has already authenticated if (m_localUser != null && m_localUser.IsAuthenticated) { OnAuthenticationFinished(m_localUser, null); return; } // As user isnt logged in, show login prompt NPBinding.UI.ShowLoginPromptDialog("Editor Game Center", "Login to start using Game Center.", "user identifier", "password", new string[] { "Log in", "Cancel" }, (string _button, string _loginID, string _password) => { string _error = null; if (_button.Equals("Cancel")) { DebugPRO.Console.LogWarning(Constants.kDebugTag, "[GameServices] User cancelled login prompt."); _error = "The operation couldnot be completed because user cancelled the login prompt."; } else { if (string.IsNullOrEmpty(_loginID)) { _loginID = "urgent_user"; } EGCUser _regUserInfo = GetUserWithID(_loginID); // Copy details of logged in user if (_regUserInfo == null) { _regUserInfo = new EGCUser(_loginID); // Add it to registered user list m_registeredUsers.Add(_regUserInfo); } // Update local user info m_localUser = new EGCLocalUser(_regUserInfo, true); } OnAuthenticationFinished(m_localUser, _error); return; }); }
private void OnAuthenticationFinished(EGCLocalUser _localUserInfo, string _error) { IDictionary _dataDict = new Dictionary <string, object>(); if (_error != null) { _dataDict[kErrorKey] = _error; } if (_localUserInfo != null) { _dataDict[kLocalUserInfoKey] = _localUserInfo; } if (NPBinding.GameServices != null) { NPBinding.GameServices.InvokeMethod(kAuthenticationFinishedEvent, new object[] { _dataDict }, new Type[] { typeof(IDictionary) }); } }
protected override void AuthenticationFinished(IDictionary _dataDict) { // Update properties using received information bool _isAuthenticated = IsAuthenticated; if (_isAuthenticated) { EGCLocalUser _localUserData = _dataDict.GetIfAvailable <EGCLocalUser>(EditorGameCenter.kLocalUserInfoKey); m_userInfo = new EditorUser(_localUserData.Info); Friends = null; } else { m_userInfo = null; Friends = null; } // Invoke auth finished handler string _error = _dataDict.GetIfAvailable <string>(EditorGameCenter.kErrorKey); AuthenticationFinished(_isAuthenticated, _error); }
public void Authenticate(Action <EditorLocalUser> _onCompletion) { // Check if user has already authenticated if (m_localUser != null && m_localUser.IsAuthenticated) { if (_onCompletion != null) { _onCompletion(m_localUser.GetEditorFormatData()); } return; } // As user isnt logged in, show login prompt NPBinding.UI.ShowLoginPromptDialog("Editor Game Center", "Login to start using Game Center.", "user identifier", "password", new string[] { "Log in", "Cancel" }, (string _button, string _loginID, string _password) => { bool _failedToLogin = false; if (_button.Equals("Cancel")) { DebugPRO.Console.LogWarning(Constants.kDebugTag, "[GameServices] User cancelled login prompt."); _failedToLogin = true; } else if (string.IsNullOrEmpty(_loginID)) { DebugPRO.Console.LogWarning(Constants.kDebugTag, "[GameServices] Login identifier is null/empty."); _failedToLogin = true; } else { EGCUser _regUserInfo = GetUserWithID(_loginID); // Copy details of logged in user if (_regUserInfo == null) { _regUserInfo = new EGCUser(_loginID); // Add it to registered user list m_registeredUsers.Add(_regUserInfo); } // Update local user info m_localUser = new EGCLocalUser(_regUserInfo, true); } if (_failedToLogin) { if (_onCompletion != null) { _onCompletion(null); } return; } else { if (_onCompletion != null) { _onCompletion(m_localUser.GetEditorFormatData()); } return; } }); }