예제 #1
0
	public void SignIn()
	{
		Debug.Log("Sign In. Click to see source.");

		var user = new GameJolt.API.Objects.User(userNameField.text, userTokenField.text);
		user.SignIn((bool success) => {
			AddConsoleLine(string.Format("Sign In {0}.", success ? "Succeesful" : "Failed"));
		});
	}
예제 #2
0
    public void SignIn()
    {
        Debug.Log("Sign In. Click to see source.");

        var user = new GameJolt.API.Objects.User(userNameField.text, userTokenField.text);

        user.SignIn((bool success) => {
            AddConsoleLine(string.Format("Sign In {0}.", success ? "Succeesful" : "Failed"));
        });
    }
예제 #3
0
파일: Manager.cs 프로젝트: Alan-Baylis/VOX
        void AutoConnectWebPlayer()
        {
#if UNITY_WEBPLAYER || UNITY_WEBGL
        #if UNITY_EDITOR
            if (DebugAutoConnect)
            {
                if (DebugUser != string.Empty && DebugToken != string.Empty)
                {
                    var user = new Objects.User(DebugUser, DebugToken);
                    user.SignIn((bool success) => { Debug.Log(string.Format("AutoConnect: " + success)); });
                }
                else
                {
                    Debug.LogWarning("Cannot simulate WebPlayer AutoConnect. Missing user and/or token in debug settings.");
                }
            }
        #else
            var uri = new Uri(Application.absoluteURL);
            if (uri.Host.EndsWith("gamejolt.net") || uri.Host.EndsWith("gamejolt.com"))
            {
                                #if UNITY_WEBPLAYER
                Application.ExternalCall("GJAPI_AuthUser", this.gameObject.name, "OnAutoConnectWebPlayer");
                                #elif UNITY_WEBGL
                Application.ExternalEval(string.Format(@"
var qs = location.search;
var params = {{}};
var tokens;
var re = /[?&]?([^=]+)=([^&]*)/g;

while (tokens = re.exec(qs)) {{
	params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
}}

var message;
if ('gjapi_username' in params && params.gjapi_username !== '' && 'gjapi_token' in params && params.gjapi_token !== '') {{
	message = params.gjapi_username + ':' + params.gjapi_token;	
}}
else {{
	message = '';
}}

SendMessage('{0}', 'OnAutoConnectWebPlayer', message);
		"        , this.gameObject.name));
                                #endif
            }
            else
            {
                Debug.Log("Cannot AutoConnect, the game is not hosted on GameJolt.");
            }
        #endif
#endif
        }
예제 #4
0
 public void SignIn(string username, string token, APILoginController loginMenu)
 {
     GameJolt.API.Objects.User user = new GameJolt.API.Objects.User(username, token);
     user.SignIn((bool success) => {
         if (success)
         {
             signedIn = true;
             loginMenu.ToggleLoginButton(true);
             loginMenu.CloseLoginMenu();
         }
         else
         {
             loginMenu.SetErrorText("api.txt.noconnection");
         }
     });
 }
예제 #5
0
 public void OnAutoConnectWebPlayer(string response)
 {
     if (response != string.Empty)
     {
         var credentials = response.Split(new[] { ':' }, 2);
         if (credentials.Length == 2)
         {
             var user = new Objects.User(credentials[0], credentials[1]);
             user.SignIn();
             // TODO: Prompt "Welcome Back <username>!"
         }
         else
         {
             LogHelper.Info("Cannot AutoConnect.");
         }
     }
     else
     {
         // This is a Guest.
         // TODO: Prompt "Hello Guest!" and encourage to signup/signin?
     }
 }
예제 #6
0
 public void OnAutoConnectWebPlayer(string response)
 {
     if (response != string.Empty)
     {
         var credentials = response.Split(new[] { ':' }, 2);
         if (credentials.Length == 2)
         {
             var user = new Objects.User(credentials[0], credentials[1]);
             user.SignIn(success => AutoLoginEvent.Invoke(success ? AutoLoginResult.Success : AutoLoginResult.Failed));
             // TODO: Prompt "Welcome Back <username>!"
         }
         else
         {
             LogHelper.Info("Cannot AutoConnect.");
             AutoLoginEvent.Invoke(AutoLoginResult.MissingCredentials);
         }
     }
     else
     {
         // This is a Guest.
         // TODO: Prompt "Hello Guest!" and encourage to signup/signin?
         AutoLoginEvent.Invoke(AutoLoginResult.MissingCredentials);
     }
 }