Esempio n. 1
0
    private void Update()
    {
        if (!manageCar.endGame)
        {
            createCentralLines();
            createBatteries();
            createObstacles();
            UpdateTraveledDistance();
        }

        else
        {
            count++;
            if (count == 1)
            {
                playfabManager.GetLeaderboard();
                ActiveLeaderboard();
                playfabManager.GetLeaderboard();
            }
        }

        restartGame();
    }
    // Use this for initialization
    public void ShowLeaderboard(string boardName, string boardTitle, string valueName)
    {
        // Remove any existing entries
        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }

        // Get the leaderboard data
        var leaderboards = PlayfabManager.GetLeaderboard(boardName);

        if (leaderboards.Any())
        {
            // Create UI entries for each
            foreach (var leaderboard in leaderboards)
            {
                var entry = Instantiate(entryPrefab, transform, false);
                entry.Set(new EntryModel(
                              (leaderboard.Position + 1).ToString(),
                              leaderboard.DisplayName ?? leaderboard.PlayFabId,
                              leaderboard.StatValue.ToString()
                              ));
            }
        }
        else
        {
            var entry = Instantiate(entryPrefab, this.transform, false);
            entry.Set(new EntryModel(
                          "Leaderboard is empty",
                          "",
                          ""
                          ));
        }

        // Set the label text
        titlePanelText.text  = boardTitle;
        headerPanelText.text = valueName;
    }
Esempio n. 3
0
    // Use this for initialization
    public void ShowLeaderboard(string boardName, string boardTitle, string valueName)
    {
        // Remove any existing entries
        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }

        // Get the leaderboard data
        var leaderboards = PlayfabManager.GetLeaderboard(boardName);

        if (leaderboards.Count > 0)
        {
            // Create UI entries for each
            foreach (var leaderboard in leaderboards)
            {
                var entry = Instantiate(EntryPrefab);

                entry.transform.SetParent(this.transform, false);
                entry.transform.Find("Player").GetComponent <Text>().text = leaderboard.DisplayName ?? leaderboard.PlayFabId;
                entry.transform.Find("Rank").GetComponent <Text>().text   = (leaderboard.Position + 1).ToString();
                entry.transform.Find("Value").GetComponent <Text>().text  = leaderboard.StatValue.ToString();
            }
        }
        else
        {
            var entry = Instantiate(EntryPrefab);
            entry.transform.SetParent(this.transform, false);
            entry.transform.Find("Player").GetComponent <Text>().text = "Leaderboard is empty";
            entry.transform.Find("Rank").GetComponent <Text>().text   = String.Empty;
            entry.transform.Find("Value").GetComponent <Text>().text  = String.Empty;
        }

        // Set the label text
        GameObject.Find("Title Panel").transform.Find("Title").GetComponent <Text>().text          = boardTitle;
        GameObject.Find("Header Panel").transform.Find("Header: Value").GetComponent <Text>().text = valueName;
    }
Esempio n. 4
0
    public void ManageData()
    {
        //compare if the score obtained is higer to the personal best
        if (scoreCounter > PlayerPrefs.GetFloat("bestScore", 0))
        {
            PlayerPrefs.SetFloat("bestScore", scoreCounter);
            PlayerPrefs.SetInt("bestStage", currentStage);
            SendDataToServer();
        }

        //send the current data to the interface
        if (LenguajeAdmid.sharedInstance.currentLenguage == LenguajeAdmid.Lenguage.English)
        {
            scoreTextUI[1].text     = scoreFormatEnglish + " " + scoreCounter.ToString("f2");
            bestScoreTextUI[1].text = bestScoreFormatEnglish + " " + PlayerPrefs.GetFloat("bestScore", 0).ToString("f2");
        }
        else
        {
            scoreTextUI[1].text     = scoreFormatEspañol + " " + scoreCounter.ToString("f2");
            bestScoreTextUI[1].text = bestScoreFormatEspañol + " " + PlayerPrefs.GetFloat("bestScore", 0).ToString("f2");
        }

        playfabManager.GetLeaderboard();
    }
 private void Start()
 {
     ScoreScript.scoreVal = -1;
     getSide = false;
     playfabManager.GetLeaderboard();
 }
Esempio n. 6
0
    private void Update()
    {
        if (!Cursor.visible && SceneManager.GetActiveScene().buildIndex != 0)
        {
            currentTime = Time.time - startTime;

            string minutes = ((int)currentTime / 60).ToString();
            string seconds = (currentTime % 60).ToString("f2");



            if ((int)currentTime / 60 == 0)
            {
                levelTimer = seconds;
            }
            else
            {
                levelTimer = minutes + ":" + seconds;
            }

            timerText.GetComponent <UnityEngine.UI.Text>().text = levelTimer;
        }
        else if (SceneManager.GetActiveScene().buildIndex != 0)
        {
            if (playfab.IsSent())
            {
                playfab.GetLeaderboard(levelName);
                playfab.HasBeenSent();
            }


            if (playfab.IsLeaderboardUpdated())
            {
                List <string> leaderboardName = playfab.GetCurrentLeaderboard(1);
                List <string> leaderboardTime = playfab.GetCurrentLeaderboard(2);

                for (int i = 0; i < leaderboardName.Count; i++)
                {
                    leaderboardNumberText.GetComponent <UnityEngine.UI.Text>().text += i + 1 + "\n";
                    leaderboardText.GetComponent <UnityEngine.UI.Text>().text       += leaderboardName[i] + "\n";
                    leaderboardTimeText.GetComponent <UnityEngine.UI.Text>().text   += leaderboardTime[i] + "\n";
                }

                personalHighScoreText.GetComponent <UnityEngine.UI.Text>().text         = playfab.GetCurrectPlayerRecord();
                personalHighScorePositionText.GetComponent <UnityEngine.UI.Text>().text = "#" + playfab.GetCurrectPlayerPosition();

                loadingGifs[0].SetActive(false);
                loadingGifs[1].SetActive(false);

                playfab.LeaderboardIsUpdated();
            }
        }
        else
        {
            Cursor.visible = true;
            if (playfab.GetDisplayName() == "" && playfab.GetIsNameUpdated() && !NowUpdated)
            {
                loadingPage.gameObject.SetActive(false);
                usernameScreen.GetComponent <DisplayName>().OpenPlayerNameSubmit();
                NowUpdated = true;
            }
            else if (playfab.GetDisplayName() != "" && playfab.GetIsNameUpdated() && !NowUpdated)
            {
                loadingPage.gameObject.SetActive(false);
                NowUpdated = true;
            }
            else
            {
            }
        }
    }