Skip to content

Instantly share code, notes, and snippets.

@TobiasBerg
Created February 9, 2021 09:21
Show Gist options
  • Save TobiasBerg/ee35ab5d18c43dea68f013c3ffcb30db to your computer and use it in GitHub Desktop.
Save TobiasBerg/ee35ab5d18c43dea68f013c3ffcb30db to your computer and use it in GitHub Desktop.
public class LootLocker : MonoBehaviour
{
// Configuration
private string LootLockerAPIKey = ""; // Found in settings @ my.lootlocker.io
private string PlayerIdentifier = ""; // In this case, your 64-bit steam ID - Looks like this: 76561298123001763 (Use https://steamid.io/lookup to find it)
private string baseUrl = "https://api.lootlocker.io/game/v1/";
// State
private bool loginDone = false;
private bool loginStarted = false;
private bool loginFailed = false;
private string sessionToken = "";
PlayerController playerController;
void Awake()
{
// Get an instance of the PlayerController so we can change the sprite color later on
playerController = GetComponent<Platformer.Mechanics.PlayerController>();
}
IEnumerator Start()
{
StartCoroutine(Login());
while (!loginDone)
{
Debug.Log("Waiting for login to complete...");
yield return new WaitForSecondsRealtime(1);
}
if (loginFailed)
{
Debug.Log("Login failed. See error logged above this statement.");
}
else
{
StartCoroutine(GetPlayerStorage());
InvokeRepeating("RunUpdatePlayerStorage", 15.0f, 15.0f);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment