Created
June 11, 2022 10:01
-
-
Save fallenblood7080/21ce315f33eb6dafd4cc5b849262b311 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using LootLocker.Requests; | |
using TMPro; | |
using System; | |
public class LootlockerProgression : MonoBehaviour | |
{ | |
public TMP_Text LevelText; | |
public TMP_Text XpText; | |
public TMP_InputField XpField; | |
void Start() | |
{ | |
CheckSession(); | |
} | |
private void GetXP() | |
{ | |
LootLockerSDKManager.GetPlayerInfo((response) => | |
{ | |
if (!response.success) return; | |
int level = (int)((response.level != null) ? response.level : 0); | |
int xp = (int)((response.xp != null) ? response.xp : 0); | |
LevelText.text = $"Level:{level}"; | |
XpText.text =$"XP:{xp}"; | |
}); | |
} | |
public void SubmitXp() | |
{ | |
int xpToSumbit = Int32.Parse(XpField.text); | |
LootLockerSDKManager.SubmitXp(xpToSumbit, (response) => | |
{ | |
if (!response.success) return; | |
GetXP(); | |
Debug.Log("Done"); | |
}); | |
} | |
#region AuthStuffs | |
public GameObject gameCanvas; | |
public GameObject AuthCanvas; | |
private string emailId = "[email protected]"; | |
private string password = "1234567890"; | |
private void CheckSession() | |
{ | |
LootLockerSDKManager.CheckWhiteLabelSession((response) => | |
{ | |
if (response) | |
{ | |
AuthCanvas.SetActive(false); | |
gameCanvas.SetActive(true); | |
GetXP(); | |
} | |
else | |
{ | |
AuthCanvas.SetActive(true); | |
} | |
}); | |
} | |
public void Signup() | |
{ | |
LootLockerSDKManager.WhiteLabelSignUp(emailId, password, (response) => | |
{ | |
if (!response.success) return; | |
Login(); | |
}); | |
} | |
public void Login() | |
{ | |
LootLockerSDKManager.WhiteLabelLogin(emailId, password, true, (response) => | |
{ | |
if (!response.success) return; | |
LootLockerSDKManager.StartWhiteLabelSession((response) => | |
{ | |
if (!response.success) return; | |
AuthCanvas.SetActive(false); | |
gameCanvas.SetActive(true); | |
}); | |
}); | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment