/// <summary> /// Checks if login was successful /// </summary> /// <returns>true/false based on success</returns> public bool IsLoginSuccessful() { EnjinEditor.CurrentUser = Enjin.StartPlatform(LoginInfo.apiurl, LoginInfo.username, LoginInfo.password); if (EnjinEditor.CurrentUser == null) { _loginState = Enjin.LoginState; return(false); } return(true); }
// Upon project start, execute the battery of Enjin SDK runtime function tests. void Start() { Debug.Log("=== Executing Enjin SDK runtime tests. ==="); Enjin.IsDebugLogActive = DEBUG; Debug.Log("(1/8) Initializing the platform for use as game server ... "); Enjin.StartPlatform(PLATFORM_URL, SERVER_EMAIL, SERVER_PASSWORD, APP_ID); DEVELOPER_TOKEN = Enjin.AccessToken; Debug.Log(" ... PASSED."); Debug.Log("(2/8) Creating a new testing account ... "); long timestamp = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; string testName = "test" + timestamp; string testEmail = testName + "@mail.com"; string testPassword = "******"; User testUser = new User { name = testName, email = testEmail, password = testPassword }; Enjin.CreateUser(testUser.name, testUser.email, testUser.password, "Platform Owner"); if (Enjin.ServerResponse == ResponseCodes.SUCCESS) { Debug.Log(" ... PASSED."); Debug.Log("(3/8) Verifying login credentials for the testing account ... "); loginUser = Enjin.VerifyLogin(testEmail, testPassword); LoginState loginState = Enjin.LoginState; if (loginState == LoginState.VALID) { Debug.Log(" ... PASSED."); TESTER_TOKEN = loginUser.access_token; foreach (Identity identity in loginUser.identities) { if (identity.app_id == APP_ID) { Debug.Log("****** " + identity.app_id + " / " + APP_ID + ": " + identity.linking_code); testingIdentityID = identity.id; } } testingIdentity = Enjin.GetIdentity(testingIdentityID); string linkingCode = testingIdentity.linking_code; Debug.Log("(4/8) Establishing wallet link for the testing account. Please link with code " + linkingCode + " ... "); Enjin.ListenForLink(testingIdentityID, linkingData => { USER_ADDRESS = linkingData.data.ethereum_address; Debug.Log(" ... PASSED."); sequenceOne = true; }); } else { Debug.LogError(" ... FAILED."); } } else { Debug.LogError(" ... FAILED."); } }
// Initialize the game state on start. private void Start() { pendingActions = new List <System.Action>(); score = 0; linkingCode = ""; identityId = -1; userAddress = ""; user = null; count = 0; pending = 0; tokenName = ""; // Initialize references to scene objects. status = GameObject.Find("Status").GetComponent <Text>(); tutorial = GameObject.Find("Tutorial").GetComponent <Text>(); authenticationPanel = GameObject.Find("Authentication Panel"); registrationPanel = GameObject.Find("Registration Panel"); registrationEmail = registrationPanel.transform.Find("Email").GetComponent <InputField>(); proceedToLoginPanel = GameObject.Find("Proceed to Login Panel"); loginPanel = GameObject.Find("Login Panel"); loginEmail = loginPanel.transform.Find("Email").GetComponent <InputField>(); loginPassword = loginPanel.transform.Find("Password").GetComponent <InputField>(); gamePanel = GameObject.Find("Game Panel"); inventory = gamePanel.transform.Find("Inventory").GetComponent <Text>(); rewardTokenImage = gamePanel.transform.Find("Reward Image").GetComponent <Image>(); rewardMask = gamePanel.transform.Find("Reward Mask").gameObject; rewardMaskImage = rewardMask.GetComponent <Image>(); panelList = new List <GameObject> { authenticationPanel, registrationPanel, proceedToLoginPanel, loginPanel, gamePanel }; // Prepare the first scene. ShowPanel(authenticationPanel); tutorial.text = Resources.Load <TextAsset>("auth-method-tutorial").text; // Start the Enjin SDK. Enjin.StartPlatform(PLATFORM_URL, DEVELOPER_USERNAME, DEVELOPER_PASSWORD, APP_ID); Debug.Log("<color=aqua>[Simple Game]</color> Using app with ID " + Enjin.AppID); // Retrieve the specified reward token's metadata. CryptoItem rewardToken = Enjin.GetCryptoItem(REWARD_TOKEN_ID); StartCoroutine(rewardToken.GetMetadata((metadataInfo) => { // Handle any potential errors in metadata retrieval. MetadataInfo.MetadataRequestState requestState = metadataInfo.state; switch (requestState) { case MetadataInfo.MetadataRequestState.PARSE_FAILED: SetStatus("Unable to parse the reward item's metadata."); break; case MetadataInfo.MetadataRequestState.RETRIEVAL_FAILED: SetStatus("Unable to retrieve the reward item's metadata."); break; case MetadataInfo.MetadataRequestState.SUCCESS: { tokenName = metadataInfo.metadata.name; StartCoroutine(rewardToken.GetImage((imageInfo) => { // Handle any potential errors with retrieving the item image. ImageInfo.ImageRequestState imageRequestState = imageInfo.state; switch (imageRequestState) { case ImageInfo.ImageRequestState.BAD_METADATA: SetStatus("Unable to handle item metadata for the image."); break; case ImageInfo.ImageRequestState.RETRIEVAL_FAILED: SetStatus("Unable to retrieve the reward item's image."); break; case ImageInfo.ImageRequestState.SUCCESS: rewardTokenImage.sprite = imageInfo.image; break; } })); break; } } })); }