示例#1
0
    public void CreateScore()
    {
        string[,] scores = ScoreLogic.StringToList(PlayerPrefs.GetString("HighScore"));

        string[] tempUser = new string[2] {
            writtenName.text, currentScore.text
        };
        for (int i = 0; i < scores.GetLength(0); i++)
        {
            listedUser[0] = scores[i, 0];
            listedUser[1] = scores[i, 1];

            if (listedUser[1].Equals("") || Int16.Parse(tempUser[1]) > Int16.Parse(listedUser[1]))
            {
                scores[i, 0] = tempUser[0];
                scores[i, 1] = tempUser[1];

                tempUser[0] = listedUser[0];
                tempUser[1] = listedUser[1];
            }
        }

        PlayerPrefs.SetString("HighScore", ScoreLogic.ListToString(scores));
        StaticData.ResetScores();
        SceneManager.LoadScene("TheHub", LoadSceneMode.Single);
    }
示例#2
0
    void Start()
    {
        ShowCurrentScore();

        CheckValidFormat();

        string[,] score = ScoreLogic.StringToList(PlayerPrefs.GetString("HighScore"));

        for (int i = 0; i < 10; i++)
        {
            line = i % 5;
            row  = Mathf.FloorToInt(i / 5);

            GameObject newPanel = Instantiate(scorePanel);
            newPanel.transform.SetParent(GameObject.Find("/Canvases/HighScoreCanvas/HighScorePanel").transform);
            newPanel.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = (i + 1).ToString() + ". " + score[i, 0] + " " + score[i, 1];
            newPanel.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);

            RectTransform rect = newPanel.GetComponent <RectTransform>();
            rect.anchoredPosition3D = new Vector3(0, 0, 0);
            rect.offsetMin          = new Vector2(2 + 93 * row, rect.offsetMin.y);
            rect.offsetMax          = new Vector2(-95 + 93 * row, rect.offsetMax.y);
            rect.offsetMax          = new Vector2(rect.offsetMax.x, -13 - 17 * line);
            rect.offsetMin          = new Vector2(rect.offsetMin.x, 70 - 17 * line);
            rect.Rotate(new Vector3(0, 90, 0));
        }
    }