Add user authentication and leaderboard to a 2d snake game

Hi,
i’ll be using this cool 2D snake game project made by Daniel Zduniak on github to add backend support, i’ve been hesitating between Playfab and Nucle cloud, eventually i’ll go with Nucle in this project

i’ll be adding

  • Anonymous users authentication,
  • HighScore saved on the cloud instead of the player device,
  • High Score Leaderboard
  • Events( mesure how many times the game was played per day, retries included )

i’ll post my work progress here

I have started first with anonymous users authentication, it’s the recommended way to go about user profiles creation.
the first thing i did when game is opened was to check if there are any anonymous user accounts associated with the current device id since anonymous users is identified by their device id, if none is found then this means that the game is being opened for the first time on the current device,
the next step is to show the player a display name input field menu,



the player can chose not to enter any display name and hit save to continue, in this case the player will be automatically given the display name “Guest”.
the purpose is to make the account creation process the most discreet possible.

Sign up method

    public static async void SignUp(string displayName)
    {
        try
        {
            //show please wait menu while sendind requests to the server
            Game.Instance.ShowWaitingPanel();

            //if no display name value was provided by the player set it to Guest
            if (string.IsNullOrWhiteSpace(displayName)) displayName = "Guest";
            // Create new anonymous user
            await Anonymous.Create( projectId, SystemInfo.deviceUniqueIdentifier, displayName);

            //login anonymous user
            var loginResult = await Anonymous.Login(projectId, SystemInfo.deviceUniqueIdentifier);
            if (loginResult != null)
            {
                Game.Instance.UserToken = loginResult.userToken;
                Game.Instance.DisplayName = loginResult.user.displayName;
                //show main menu
                Game.Instance.ShowMenu();
            }
        }
        catch (Exception ex)
        {
            Game.Instance.ShowDisconnectedPanel();
            Debug.Log(ex.Message);
        }
    }

the next step is to save and retrieve highScore value from the cloud