Exemplo n.º 1
0
    public void SetBestScore()
    {
        int previousBestScore = PlayerPrefsController.GetBestScore();
        int newBestScore      = Mathf.Max(previousBestScore, currentScore);

        PlayerPrefsController.SetBestScore(newBestScore);
    }
Exemplo n.º 2
0
 private void DisplayBestScore()
 {
     if (PlayerPrefsController.GetBestScore() > 0)
     {
         gameObject.GetComponent <TextMeshProUGUI>().text = PlayerPrefsController.GetBestScore().ToString();
     }
     else
     {
         gameObject.GetComponent <TextMeshProUGUI>().text = 0.ToString();
     }
 }
Exemplo n.º 3
0
    public void ReplaceLifePicture()
    {
        int        lastLife    = lifes.Count - 1;
        GameObject lifePicture = lifes[lifes.Count - 1];

        lifePicture.GetComponent <Image>().sprite = deathSprite;
        lifes.RemoveAt(lastLife);
        if (lifes.Count == 0)
        {
            ShowGameOverPanel();
            resultScoreText.text = currentScore.ToString();
            if (currentScore > PlayerPrefsController.GetBestScore())
            {
                PlayerPrefsController.SetBestScore(currentScore);
            }
            GameManager.instance.PlayerDeath();
        }
    }
Exemplo n.º 4
0
    // Start is called before the first frame update
    void Start()
    {
        var client                     = UM_GameService.LeaderboardsClient;
        var signInClient               = UM_GameService.SignInClient;
        var bestScoreLeaderboardId     = "CgkItt_m-csZEAIQAA";
        var bouncingSpreeLeaderboardId = "CgkItt_m-csZEAIQDA";
        int bestScore                  = PlayerPrefsController.GetBestScore();
        int bestBouncingSpree          = PlayerPrefsController.GetBestBouncingSpree();
        int context                    = 0;

        if (bestScore >= 5)
        {
            if (signInClient.PlayerInfo.State == UM_PlayerState.SignedIn)
            {
                client.SubmitScore(bestScoreLeaderboardId, bestScore, context, (result) => {
                    if (result.IsSucceeded)
                    {
                        Debug.Log("Score submitted successfully");
                    }
                    else
                    {
                        Debug.Log("Failed to submit score: " + result.Error.FullMessage);
                    }
                });
            }
        }

        if (bestBouncingSpree >= 5)
        {
            if (signInClient.PlayerInfo.State == UM_PlayerState.SignedIn)
            {
                client.SubmitScore(bouncingSpreeLeaderboardId, bestBouncingSpree, context, (result) => {
                    if (result.IsSucceeded)
                    {
                        Debug.Log("Score submitted successfully");
                    }
                    else
                    {
                        Debug.Log("Failed to submit score: " + result.Error.FullMessage);
                    }
                });
            }
        }
    }
Exemplo n.º 5
0
    // Unity methods
    void Start()
    {
        scoreText   = GetComponent <TextMeshProUGUI>();
        gameSession = FindObjectOfType <GameSession>();
        bestScore   = PlayerPrefsController.GetBestScore();

        difficultySetting = PlayerPrefsController.GetDifficulty();
        if (difficultySetting == 0)
        {
            difficultySettingName = "Calm";
        }
        else if (difficultySetting == 1)
        {
            difficultySettingName = "Normal";
        }
        else
        {
            difficultySettingName = "Fishy";
        }
    }
Exemplo n.º 6
0
    public void OnClickShare()
    {
        var client  = UM_SocialService.SharingClient;
        var builder = new UM_ShareDialogBuilder();

#if PLATFORM_ANDROID
        builder.SetUrl("https://play.google.com/store/apps/details?id=com.saiked.headbouncer");
        builder.SetText("I have achived a high score of " + PlayerPrefsController.GetBestScore() + " in #HeadBouncer. Will you do better ? You can find this game on Google Play");
#elif PLATFORM_UNITY
        builder.SetUrl("https://apps.apple.com/us/app/head-bouncer/id1471767673");
        builder.SetText("I have achived a high score of " + PlayerPrefsController.GetBestScore() + " in #HeadBouncer. Will you do better ? You can find this game on App Store");
#endif

        client.SystemSharingDialog(builder, (result) => {
            if (result.IsSucceeded)
            {
                Debug.Log("Sharing started ");
            }
            else
            {
                Debug.Log("Failed to share: " + result.Error.FullMessage);
            }
        });
    }
Exemplo n.º 7
0
 // Update is called once per frame
 void Update()
 {
     if (PlayerPrefsController.GetBestScore() >= 25 &&
         PlayerPrefsController.GetPoints25() == false &&
         Application.internetReachability != NetworkReachability.NotReachable)
     {
         Unlock25Points();
     }
     else if (PlayerPrefsController.GetBestScore() >= 50 &&
              PlayerPrefsController.GetPoints50() == false &&
              Application.internetReachability != NetworkReachability.NotReachable)
     {
         Unlock50Points();
     }
     else if (PlayerPrefsController.GetBestScore() >= 100 &&
              PlayerPrefsController.GetPoints100() == false &&
              Application.internetReachability != NetworkReachability.NotReachable)
     {
         Unlock100Points();
     }
     else if (PlayerPrefsController.GetBestScore() >= 200 &&
              PlayerPrefsController.GetPoints200() == false &&
              Application.internetReachability != NetworkReachability.NotReachable)
     {
         Unlock200Points();
     }
     else if (PlayerPrefsController.GetBestScore() >= 500 &&
              PlayerPrefsController.GetPoints500() == false &&
              Application.internetReachability != NetworkReachability.NotReachable)
     {
         Unlock500Points();
     }
     else if (PlayerPrefsController.GetCharacters().Length >= 3 &&
              PlayerPrefsController.GetCharacters2() == false &&
              Application.internetReachability != NetworkReachability.NotReachable)
     {
         Unlock2Characters();
     }
     else if (PlayerPrefsController.GetCharacters().Length >= 6 &&
              PlayerPrefsController.GetCharacters5() == false &&
              Application.internetReachability != NetworkReachability.NotReachable)
     {
         Unlock5Characters();
     }
     else if (PlayerPrefsController.GetCharacters().Length >= 11 &&
              PlayerPrefsController.GetCharacters10() == false &&
              Application.internetReachability != NetworkReachability.NotReachable)
     {
         Unlock10Characters();
     }
     else if (PlayerPrefsController.GetCharacters().Length >= 21 &&
              PlayerPrefsController.GetCharacters20() == false &&
              Application.internetReachability != NetworkReachability.NotReachable)
     {
         Unlock20Characters();
     }
     else if (PlayerPrefsController.GetCharacters().Length >= 31 &&
              PlayerPrefsController.GetCharacters30() == false &&
              Application.internetReachability != NetworkReachability.NotReachable)
     {
         Unlock30Characters();
     }
 }
Exemplo n.º 8
0
    private void ShowBestResult()
    {
        TextMeshProUGUI bestResultText = bestResult.GetComponent <TextMeshProUGUI>();

        bestResultText.text = PlayerPrefsController.GetBestScore().ToString();
    }