Пример #1
0
    public void Scores(int score, int time)
    {
        GameObject   apiMangager = GameObject.FindGameObjectWithTag("ApiManager");
        LoginManager lMang       = apiMangager.GetComponent <LoginManager>();

        if (lMang.loginType == 2)
        {
            try
            {
                new GameSparks.Api.Requests.LogEventRequest_postScore().Set_score(score).Set_time(time).Send((response) =>
                {
                    if (response.HasErrors)
                    {
                        Debug.Log("Failed");
                    }
                    else
                    {
                        Debug.Log("Successful");
                    }
                });
                ShowLeaderboard(true);
                ShowSubMenu();
            }
            catch
            {
                _dataPersistInstance.writeStringToFile("Player," + score.ToString() + "," + time.ToString(), "scores");
                ShowLeaderboard(false);
                ShowSubMenu();
            }
        }
        else if (lMang.loginType == 1)
        {
            // Report Google Play Score to Leaderboard
            Social.ReportScore(score, "CgkI7eKGgfsHEAIQAA", (bool success) => {
                if (success)
                {
                    //empty
                }
            });
            Social.ShowLeaderboardUI();
            ShowSubMenu();
        }
        else
        {
            _dataPersistInstance.writeStringToFile("Player," + score.ToString() + "," + time.ToString(), "scores");
            ShowLeaderboard(false);
            ShowSubMenu();
        }
    }