/// Logs in the player identified /// /// @param chilliConnectId /// The players chilliConnectId /// /// @param chilliConnectSecret /// The players chilliConnectSecret /// private void Login(string chilliConnectId, string chilliConnectSecret) { var loginDesc = new LogInUsingChilliConnectRequestDesc(chilliConnectId, chilliConnectSecret); m_chilliConnect.PlayerAccounts.LogInUsingChilliConnect(loginDesc, (loginRequest, loginResponse) => OnChilliConnectLoggedIn(chilliConnectId, chilliConnectSecret), (loginRequest, error) => Debug.LogError(error.ErrorDescription)); }
/// Called when player creation has completed allowing us to log the /// player in /// /// @param request /// Info on request made to create player /// @param response /// Holds the id and secret to log the player in /// private void OnPlayerCreated(CreatePlayerRequest request, CreatePlayerResponse response) { Debug.Log("Player created. Logging in"); //Save the credentials so we don't create a new player next time we launch the app PlayerPrefs.SetString("CCId", response.ChilliConnectId); PlayerPrefs.SetString("CCSecret", response.ChilliConnectSecret); PlayerPrefs.Save(); var loginRequestDesc = new LogInUsingChilliConnectRequestDesc(response.ChilliConnectId, response.ChilliConnectSecret); m_chilliConnect.PlayerAccounts.LogInUsingChilliConnect(loginRequestDesc, (loginRequest, loginResponse) => OnLoggedIn(), (loginRequest, error) => Debug.LogError(error.ErrorDescription)); }
void LoginPlayer() { System.Action <LogInUsingChilliConnectRequest, LogInUsingChilliConnectResponse> successCallback = (LogInUsingChilliConnectRequest request, LogInUsingChilliConnectResponse response) => { UnityEngine.Debug.Log("Player logged in"); }; System.Action <LogInUsingChilliConnectRequest, LogInUsingChilliConnectError> errorCallback = (LogInUsingChilliConnectRequest request, LogInUsingChilliConnectError error) => { UnityEngine.Debug.Log("An error occurred while logging in: " + error.ErrorDescription); }; var requestDesc = new LogInUsingChilliConnectRequestDesc(ChilliConnectId, ChilliConnectSecret); chilliConnect.PlayerAccounts.LogInUsingChilliConnect(requestDesc, successCallback, errorCallback); }
/// Initialised ChilliConnect, create and log in a player. /// private void Awake() { // Initialise ChilliConnect. Game token can be found on the game dashboard of ChilliConnect m_chilliConnect = new ChilliConnectSdk(GAME_TOKEN, true); // Create a new ChilliConnect player with the given display name if we don't have any credentials saved for the local player if (PlayerPrefs.HasKey("CCId") == true && PlayerPrefs.HasKey("CCSecret") == true) { Debug.Log("Player already exists. Logging in"); var loginRequestDesc = new LogInUsingChilliConnectRequestDesc(PlayerPrefs.GetString("CCId"), PlayerPrefs.GetString("CCSecret")); m_chilliConnect.PlayerAccounts.LogInUsingChilliConnect(loginRequestDesc, (loginRequest, loginResponse) => OnLoggedIn(), (loginRequest, error) => Debug.LogError(error.ErrorDescription)); } else { Debug.Log("Creating Player"); var requestDesc = new CreatePlayerRequestDesc(); requestDesc.DisplayName = "TestyMcTestface"; m_chilliConnect.PlayerAccounts.CreatePlayer(requestDesc, OnPlayerCreated, (AddEventRequest, error) => Debug.LogError(error.ErrorDescription)); } }
// Login to ChilliConnect, then start deltaDNA SDK private void LogIn(string chilliConnectId, string chilliConnectSecret) { var loginRequest = new LogInUsingChilliConnectRequestDesc(chilliConnectId, chilliConnectSecret); chilliConnect.PlayerAccounts.LogInUsingChilliConnect(loginRequest, (LogInUsingChilliConnectRequest request, LogInUsingChilliConnectResponse response) => { Debug.Log("Login using ChilliConnect OK"); // Start the deltaDNA SDK using the chilliConnectIs as the deltaDNA userID DeltaDNAInit(chilliConnectId); GetChilliGameConfig(); }, (LogInUsingChilliConnectRequest request, LogInUsingChilliConnectError error) => { Debug.Log("An error occurred during ChilliConnect Player Login : "******"\n Data : " + error.ErrorData); Debug.Log("Quitting"); Application.Quit(); } ); }