Esempio n. 1
0
    public Text listeScores;                            //Text pour la liste des scores
    //variable à transformer en % NiveauOxygene



    void Start()
    {
        //ChangementScenePortail.leNomDuJoueur = "Kim";
        //ControlerPersonnage.NiveauOxygene=10;

        PlayerPrefs.DeleteKey("FichierScores");                  //Effacer les données précédemment enregistrées
        PlayerPrefs.DeleteKey("FichierNoms");                    //Effacer les données précédemment enregistrées

        bool infoExisteDeja = PlayerPrefs.HasKey("FichierNoms"); //Regarde si valeurs présentes

        //si valeurs trouvées on affiche
        if (infoExisteDeja == true)
        {
            //lecture des données
            tableauValeursScore = PlayerPrefsX.GetFloatArray("FichierScores");
            tableauNoms         = PlayerPrefsX.GetStringArray("FichierNoms");
        }

        tableauNoms[3] = ChangementScenePortail.leNomDuJoueur;

        tableauValeursScore[3] = ControlerPersonnage.NiveauOxygene;
        //listeScores.text = tableauValeursScore[0].ToString();

        //Trier le tableau selon le score
        System.Array.Sort(tableauValeursScore, tableauNoms);
        System.Array.Reverse(tableauValeursScore); //
        System.Array.Reverse(tableauNoms);         //

        AfficherElements();
        //Écriture des données
        PlayerPrefsX.SetFloatArray("FichierScores", tableauValeursScore);
        PlayerPrefsX.SetStringArray("FichierNoms", tableauNoms);
    }
Esempio n. 2
0
    void Update()
    {
        if (PlayerPrefs.GetInt("Gaming") == 1)
        {
            timeLeft     += Time.deltaTime;
            timeText.text = timeLeft.ToString("F1");
        }

        else
        {
            PlayerPrefs.SetFloat("TimeLeft", timeLeft);
            PlayerPrefs.Save();
            for (int num = 9; num > 0; num--)
            {
                lastscores[num] = lastscores[num - 1];
            }

            lastscores[0] = timeLeft;
            PlayerPrefsX.SetFloatArray("ScoresLast", lastscores);



            if (timeLeft < PlayerPrefs.GetFloat("bestTime", 500f))
            {
                PlayerPrefs.SetFloat("bestTime", timeLeft);
                PlayerPrefs.Save();
            }
        }
    }
Esempio n. 3
0
    private void OnGUI()
    {
        if (EditorApplication.isPaused)
        {
            print("pause");
            int     bestcheckpoint = -1;
            IAInput bestcart       = null;
            for (int i = 0; i < karts; i++)
            {
                if (bestcheckpoint < iaKarts[i].checkpoint)
                {
                    bestcheckpoint = iaKarts[i].checkpoint;
                    bestcart       = iaKarts[i];
                }
            }
            if (bestcheckpoint > 0)
            {
                print("salvando melhor");


                var cubeRenderer = bestcart.gameObject.GetComponentInChildren <Renderer>();
                cubeRenderer.material.SetColor("_Color", Color.red);
                bestiaturnDNA = bestcart.GetDNA();
                PlayerPrefsX.SetFloatArray("BestIA", bestiaturnDNA);
            }
        }
    }
Esempio n. 4
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            float[] leaderboard        = PlayerPrefsX.GetFloatArray("Leaderboard");
            float[] updatedLeaderboard = new float[leaderboard.Length + 1];
            for (int i = 0; i < leaderboard.Length; i++)
            {
                updatedLeaderboard[i] = leaderboard[i];
            }
            updatedLeaderboard[updatedLeaderboard.Length - 1] = 10.00f;
            PlayerPrefsX.SetFloatArray("Leaderboard", updatedLeaderboard);
            m_leaderboard.text = "";
            foreach (float f in updatedLeaderboard)
            {
                m_leaderboard.text += f.ToString("00.00\n");
            }
        }

        if (Input.GetButtonDown("Reload"))
        {
            float[] reset = new float[0];
            PlayerPrefsX.SetFloatArray("Leaderboard", reset);
            m_leaderboard.text = "";
        }
    }
Esempio n. 5
0
    // Save the color array and the currentDay value to the Player Prefs
    public bool saveSettings()
    {
        PlayerPrefs.SetInt(currentDayKey, currentDay);
        bool savedTimes  = PlayerPrefsX.SetFloatArray(timeKey, times);
        bool savedColors = PlayerPrefsX.SetColorArray(colorsKey, colors);

        return(savedTimes && savedColors);
    }
Esempio n. 6
0
        public override void saveGame()
        {
            Debug.Log("saveGame");
            PlayerPrefsX.SetBool("_isMusicOff", isMusicOff);
            PlayerPrefsX.SetStringArray("_highScoreName", highScoreName);
            PlayerPrefsX.SetFloatArray("_highScore", highScore);

            PreviewLabs.PlayerPrefs.Flush();
        }
Esempio n. 7
0
    // Use this for initialization
    void Start()
    {
        ResetColorsButton = false;
        colors            = PlayerPrefsX.GetColorArray(colorsKey);
        times             = PlayerPrefsX.GetFloatArray(timeKey);
        currentDay        = PlayerPrefs.GetInt(currentDayKey);

        if (!cam)
        {
            cam = FindObjectOfType <Camera>();
        }

        if (colors.Length < 1 || times.Length < 1)
        {
            Debug.Log("Initializing Colors!");
            colors = new Color[365];
            times  = new float[365];
            for (int i = 0; i < 365; i++)
            {
                colors[i] = new Color(1, 1, 1);
                times[i]  = 0;
            }
            currentDay = 0;
            PlayerPrefsX.SetColorArray(colorsKey, colors);
            PlayerPrefsX.SetFloatArray(timeKey, times);
            PlayerPrefs.SetInt(currentDayKey, 0);
        }

        //printColors();

        //visController.enabled = false;

        //printColors();

        //float bonus = 0.1f;

        //float RMin = 0.7f + bonus;
        //float RMax = 0.9f + bonus;
        //float GMin = 0.32f + bonus;
        //float GMax = 0.6f + bonus;
        //float BMin = 0.0f + bonus;
        //float BMax = 0.39f + bonus;

        //for (int j = 0; j < colors.Length; j++)
        //{
        //    if (j % 2 == 0)
        //        colors[j] = new Color(Random.Range(RMin, RMax), Random.Range(GMin, GMax), Random.Range(BMin, BMax), 1);
        //    else
        //        colors[j] = new Color(Random.Range(1 - RMin, 1 - RMax), Random.Range(1 - GMin, 1 - GMax), Random.Range(1 - BMin, 1 - BMax), 1);
        //}

        //for (int i = 0; i < times.Length; i++)
        //{
        //    times[i] = Random.Range(240, 375);
        //}
    }
Esempio n. 8
0
 public static void ClearRank()
 {
     float[] data = PlayerPrefsX.GetFloatArray("Rank", 0, 10);
     for (int i = 0; i < data.Length; i++)
     {
         data[i] = 0f;
     }
     PlayerPrefsX.SetFloatArray("Rank", data);
     Debug.Log("Complete! ");
 }
Esempio n. 9
0
 public void Save()
 {
     float[] leaderboard        = PlayerPrefsX.GetFloatArray("Leaderboard");
     float[] updatedLeaderboard = new float[leaderboard.Length + 1];
     for (int i = 0; i < leaderboard.Length; i++)
     {
         updatedLeaderboard[i] = leaderboard[i];
     }
     updatedLeaderboard[updatedLeaderboard.Length - 1] = float.Parse(m_timeScore.text);
     PlayerPrefsX.SetFloatArray("Leaderboard", updatedLeaderboard);
 }
Esempio n. 10
0
    // Start is called before the first frame update
    void Start()
    {
        playerHSList = new List <playerHighScores>();
        gm           = GameObject.Find("GameManager").GetComponent <GameManager>();
        names        = PlayerPrefsX.GetStringArray("Names", "", 1);
        scores       = PlayerPrefsX.GetIntArray("Scores", 0, 1);
        times        = PlayerPrefsX.GetFloatArray("Times", 0f, 1);

        if (names[0] == "")
        {
            names[0]  = gm.username;
            scores[0] = gm.score;
            times[0]  = gm.time;

            PlayerPrefsX.SetStringArray("Names", names);
            PlayerPrefsX.SetIntArray("Scores", scores);
            PlayerPrefsX.SetFloatArray("Times", times);
        }
        else
        {
            playerHS = new playerHighScores();
            for (int i = 0; i < names.Length; i++)
            {
                playerHS   = new playerHighScores();
                playerHS.n = names[i];
                playerHS.s = scores[i];
                playerHS.t = times[i];
                playerHSList.Add(playerHS);
            }



            playerHS   = new playerHighScores();
            playerHS.n = gm.username;
            playerHS.s = gm.score;
            playerHS.t = gm.time;

            playerHSList.Add(playerHS);

            System.Array.Resize(ref names, names.Length + 1);
            System.Array.Resize(ref scores, scores.Length + 1);
            System.Array.Resize(ref times, times.Length + 1);

            names[names.Length - 1]   = gm.username;
            scores[scores.Length - 1] = gm.score;
            times[times.Length - 1]   = gm.time;

            PlayerPrefsX.SetStringArray("Names", names);
            PlayerPrefsX.SetIntArray("Scores", scores);
            PlayerPrefsX.SetFloatArray("Times", times);
        }
        sortList();
        Scoreboard();
    }
Esempio n. 11
0
    void SaveList()
    {
        highScoreList = new List <HighScore> {
        };
        gameManager   = FindObjectOfType <GameManager>();
        names         = PlayerPrefsX.GetStringArray("PlayerNames", "", 1);
        playtimes     = PlayerPrefsX.GetFloatArray("PlayerTimes", 0f, 1);


        if (names[0] == "")
        {
            names[0]     = gameManager.username;
            playtimes[0] = gameManager.time;


            PlayerPrefsX.SetStringArray("PlayerNames", names);
            PlayerPrefsX.SetFloatArray("PlayerTimes", playtimes);
        }
        else
        {
            myHighScores = new HighScore();
            for (int i = 0; i < names.Length; i++)
            {
                //Loading myHighScores with current saved playerPrefs
                myHighScores            = new HighScore();
                myHighScores.playername = names[i];
                myHighScores.playtime   = playtimes[i];
                highScoreList.Add(myHighScores);
            }
            //Adding new values to list
            myHighScores            = new HighScore();
            myHighScores.playername = gameManager.username;
            myHighScores.playtime   = gameManager.time;

            highScoreList.Add(myHighScores);

            //Resizing arrays to fit new data
            //print("BUG before resize" + names.Length);
            System.Array.Resize(ref names, names.Length + 1);
            //print("BUG after resize" + names.Length);
            System.Array.Resize(ref playtimes, playtimes.Length + 1);

            //Adding current vallues to array
            names[names.Length - 1]         = gameManager.username;
            playtimes[playtimes.Length - 1] = gameManager.time;

            //Overwritting playerprefs with new data
            PlayerPrefsX.SetStringArray("PlayerNames", names);
            PlayerPrefsX.SetFloatArray("PlayerTimes", playtimes);
        }
        SortList();
        DisplayData();
    }
Esempio n. 12
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "goal")
        {
            if (time <= Maxtime)
            {
                Debug.Log("最高スコア更新!");
                PlayerPrefsX.SetFloatArray("timeX", timeNow);
                PlayerPrefsX.SetIntArray("keyX", inkey);
                PlayerPrefs.SetFloat("Maxtime", time);

                PlayerPrefs.Save();
            }
        }
    }
Esempio n. 13
0
    void SaveList()
    {
        string[] names       = new string[myHighScores.Count];
        float[]  playertimes = new float[myHighScores.Count];

        int counter = 0;

        foreach (HighScore s in myHighScores)
        {
            names[counter]       = s.playername;
            playertimes[counter] = s.playtime;
            counter++;
        }

        PlayerPrefsX.SetStringArray("PlayerNames", names);
        PlayerPrefsX.SetFloatArray("PlayerTimes", playertimes);
    }
Esempio n. 14
0
    // Update is called once per frame
    void Update()
    {
        /*現在進行形で行動を保存*/
        time = canvas2Script.timer;        //常に時間は動くように

        //ボタンの種類と押した時の時間をそれぞれ保存
        //右が押されたら1,左が押されたら-1,キーが離されたら0
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            timeNow[i] = time;
            inkey[i]   = 1;
            i++;
        }
        if (Input.GetKeyUp(KeyCode.RightArrow))
        {
            timeNow[i] = time;
            inkey[i]   = 0;
            i++;
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            timeNow[i] = time;
            inkey[i]   = -1;
            i++;
        }
        if (Input.GetKeyUp(KeyCode.LeftArrow))
        {
            timeNow[i] = time;
            inkey[i]   = 0;
            i++;
        }

        /*
         *      if(Input.GetButtonDown("jumpbutton")){
         *              timeNow[i] = time;
         *              inkey[i] = 2;
         *              i++;
         *      }
         */
        PlayerPrefsX.SetFloatArray("timeX", timeNow);
        PlayerPrefsX.SetIntArray("keyX", inkey);
    }
    public bool CheckHighscore()
    {
        float[] highscores = new float[10] {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        };
        string[] highscoreNames = new string[10] {
            "", "", "", "", "", "", "", "", "", ""
        };
        if (PlayerPrefsX.GetFloatArray("Scores").Length == 0)
        {
            PlayerPrefsX.SetStringArray("Names", highscoreNames);
            PlayerPrefsX.SetFloatArray("Scores", highscores);
            showSubmit();
            return(true);
        }
        else
        {
            highscores     = PlayerPrefsX.GetFloatArray("Scores");
            highscoreNames = PlayerPrefsX.GetStringArray("Names");
            int index = -1;

            for (int i = 0; i < highscores.Length; i++)
            {
                if (Score > highscores [i])
                {
                    index = i;
                    break;
                }
            }

            if (index != -1)
            {
                showSubmit();
                return(true);
            }
            else
            {
                FillHighscoreList(PlayerPrefsX.GetStringArray("Names"), PlayerPrefsX.GetFloatArray("Scores"));
            }
        }
        return(false);
    }
Esempio n. 16
0
    void cardComparison(List <int> list)
    {
        cardScript.canPlayCard = false;

        int x = 0;

        // if the 2 flipped cards are the same
        if (cards [list[0]].GetComponent <cardScript> ().cardValue == cards [list[1]].GetComponent <cardScript> ().cardValue)
        {
            x = 2;             // card are the same

            // Hide the cards
            (cards [list[0]]).transform.localScale = new Vector3(0, 0, 0);
            (cards [list[1]]).transform.localScale = new Vector3(0, 0, 0);

            GameObject.Find("musicManager").GetComponent <musicPlayer> ().matchSound.Play();
            _matches--;             // decrement left matches
            matchText.text = _matches.ToString();

            if (_matches == 0)               // game is over
            // Add highscore
            {
                var highScores = new List <float>();
                highScores = PlayerPrefsX.GetFloatList("highScore");
                highScores.Add(gameTime);
                PlayerPrefsX.SetFloatArray("highScore", highScores.ToArray());
                Debug.Log(((PlayerPrefsX.GetFloatArray("highScore")[0]).ToString()));

                // Load win scene
                SceneManager.LoadScene("winScene");
            }
        }

        for (int i = 0; i < list.Count; i++)
        {
            // if the the 2 cards are the same state = 2
            // Cards won't flip again
            // Else state = 0
            cards [list[i]].GetComponent <cardScript> ().state = x;
            cards [list [i]].GetComponent <cardScript> ().check();
        }
    }
Esempio n. 17
0
    void StopScrolling(int i)
    {
        float distance = PlayerPrefs.GetFloat("Farthest");

        if (distance < mileage)
        {
            PlayerPrefs.SetFloat("Farthest", mileage);
        }
        float[] data = PlayerPrefsX.GetFloatArray("Rank", 0, 10);
        for (int k = 0; k < data.Length; k++)
        {
            if (data[k] < mileage)
            {
                for (int j = data.Length - 1; j > k; j--)
                {
                    data[j] = data[j - 1];
                }
                data[k] = mileage;
                rank    = k + 1;
                Debug.Log("set rank");
                break;
            }
        }

        //for (int k = 0; k < data.Length; k++) {
        //    print(data[k]);
        //}
        PlayerPrefsX.SetFloatArray("Rank", data);
        if (i == 0)
        {
            Debug.Log("stop");
            StopAllCoroutines();
            curspeed = 0;
            SetSpeed(0);
        }
        else
        {
            StopAllCoroutines();
            StartCoroutine(ChangeSpeed(0f, 0.5f));
        }
    }
    public void SaveHighScore()
    {
        string PlayerName = nameText.text;

        float[]  highscores     = PlayerPrefsX.GetFloatArray("Scores");
        string[] highscoreNames = PlayerPrefsX.GetStringArray("Names");

        int index = -1;

        for (int i = 0; i < highscores.Length; i++)
        {
            if (Score > highscores [i])
            {
                index = i;
                break;
            }
        }

        if (index >= 0)
        {
            if (index == 9)
            {
                highscoreNames [index] = PlayerName;
                highscores [index]     = TotalScore;
            }
            else
            {
                for (int changeIndex = 8; changeIndex >= index; changeIndex--)
                {
                    highscoreNames [changeIndex + 1] = highscoreNames [changeIndex];
                    highscores [changeIndex + 1]     = highscores [changeIndex];
                }
                highscoreNames [index] = PlayerName;
                highscores [index]     = Score;
            }
        }
        PlayerPrefsX.SetStringArray("Names", highscoreNames);
        PlayerPrefsX.SetFloatArray("Scores", highscores);

        FillHighscoreList(highscoreNames, highscores);
    }
Esempio n. 19
0
    public void RecordScore(int score)
    {
        List <float> highScores = new List <float>(PlayerPrefsX.GetFloatArray(HIGH_SCORE_KEY));

        highScores.Add(score);
        highScores.Sort((a, b) => - 1 * a.CompareTo(b));
        PlayerPrefsX.SetFloatArray(HIGH_SCORE_KEY, highScores.ToArray());
        for (int i = 0; i < highScoreTexts.Length; i++)
        {
            if (i < highScores.Count)
            {
                highScoreTexts[i].text = highScores[i].ToString();
            }
            else
            {
                highScoreTexts[i].text = "";
            }
        }

        scoreText.text = "Score: " + score.ToString();
        SetRankText(score);
    }
Esempio n. 20
0
    public void SaveScore()
    {
        userTime = (EndUserTime - startUserTime);

        float[]  oldTime = PlayerPrefsX.GetFloatArray("HighscoresTimes", 900, 100);
        string[] oldName = PlayerPrefsX.GetStringArray("HighscoresNames", "AI 1.2", 100);

        for (int i = 0; i < oldTime.Length; i++)
        {
            float  oldT = oldTime[i];
            string oldN = oldName [i];
            if (userTime < oldTime[i])
            {
                oldTime[i]  = userTime;
                oldName [i] = userName;
                userTime    = oldT;
                userName    = oldN;
            }
        }

        PlayerPrefsX.SetFloatArray("HighscoresTimes", oldTime);
        PlayerPrefsX.SetStringArray("HighscoresNames", oldName);
    }
Esempio n. 21
0
    void SaveBest()
    {
        int     bestcheckpoint = -1;
        IAInput bestcart       = null;

        for (int i = 0; i < karts; i++)
        {
            if (bestcheckpoint < iaKarts[i].checkpoint)
            {
                bestcheckpoint = iaKarts[i].checkpoint;
                bestcart       = iaKarts[i];
            }
        }
        if (bestcheckpoint > 0)
        {
            print("salvando melhor");
            var cubeRenderer = bestcart.gameObject.GetComponentInChildren <Renderer>();
            cubeRenderer.material.SetColor("_Color", Color.red);
            bestiaturnDNA = bestcart.GetDNA();
            PlayerPrefsX.SetFloatArray("BestIA", bestiaturnDNA);
        }

        SceneManager.LoadScene("SampleScene");
    }
Esempio n. 22
0
 private void Update()
 {
     currentLevelNS             = GlobalValues.currentLevel;
     currentMaxLevelNS          = GlobalValues.currentMaxLevel;
     currentScreenNS            = GlobalValues.currentScreen;
     totalLevelCountNS          = GlobalValues.totalLevelCount;
     gameModeNS                 = GlobalValues.gameMode;
     recordedTimesNS            = GlobalValues.recordedTimes;
     topRecordedTimesNS         = GlobalValues.topRecordedTimes;
     timedLevelsBeatNS          = GlobalValues.timedLevelsBeat;
     GlobalValues.timesToBeatPS = timesToBeatP;
     if (GlobalValues.currentMaxLevel > PlayerPrefs.GetInt("Levels Completed"))
     {
         PlayerPrefs.SetInt("Levels Completed", GlobalValues.currentMaxLevel);
     }
     if (GlobalValues.mainLevelsCompleted > PlayerPrefs.GetInt("Main Levels Completed"))
     {
         PlayerPrefs.SetInt("Main Levels Completed", GlobalValues.mainLevelsCompleted);
     }
     if (GlobalValues.mainLevelsCompleted == 1 && GlobalValues.hasDisplayedWin1 == 0)
     {
         PlayerPrefs.SetInt("Has Displayed Win Message", 1);
     }
     if (GlobalValues.currentScreen == 4)
     {
         if (GlobalValues.gameMode == 2 && GlobalValues.recordNewTopTime)
         {
             if (!GlobalValues.forceRecord)
             {
                 if (GlobalValues.recordedTimes[GlobalValues.currentLevel - 1] < GlobalValues.topRecordedTimes[GlobalValues.currentLevel - 1])
                 {
                     GlobalValues.topRecordedTimes[GlobalValues.currentLevel - 2] = GlobalValues.recordedTimes[GlobalValues.currentLevel - 2];
                     topRecordedTimesNS[GlobalValues.currentLevel - 2]            = GlobalValues.recordedTimes[GlobalValues.currentLevel - 2];
                     PlayerPrefsX.SetFloatArray("Top Recorded Times", GlobalValues.topRecordedTimes);
                 }
                 if (GlobalValues.recordedTimes[GlobalValues.currentLevel - 1] < timesToBeatP[GlobalValues.currentLevel - 1])
                 {
                     GlobalValues.timedLevelsBeat[GlobalValues.currentLevel - 2] = true;
                     PlayerPrefsX.SetBoolArray("Completed Timed Levels", GlobalValues.timedLevelsBeat);
                 }
             }
             GlobalValues.recordNewTopTime = false;
         }
         if (GlobalValues.recordTimedLevelBeat)
         {
             GlobalValues.recordTimedLevelBeat = false;
         }
     }
     if (GlobalValues.forceRecord)
     {
         if (GlobalValues.recordedTimes[GlobalValues.currentLevel - 1] < GlobalValues.topRecordedTimes[GlobalValues.currentLevel - 1])
         {
             GlobalValues.topRecordedTimes[GlobalValues.currentLevel - 1] = GlobalValues.recordedTimes[GlobalValues.currentLevel - 1];
             topRecordedTimesNS[GlobalValues.currentLevel - 1]            = GlobalValues.recordedTimes[GlobalValues.currentLevel - 1];
             PlayerPrefsX.SetFloatArray("Top Recorded Times", GlobalValues.topRecordedTimes);
         }
         if (GlobalValues.recordedTimes[GlobalValues.currentLevel - 1] < timesToBeatP[GlobalValues.currentLevel - 1])
         {
             GlobalValues.timedLevelsBeat[GlobalValues.currentLevel - 1] = true;
             PlayerPrefsX.SetBoolArray("Completed Timed Levels", GlobalValues.timedLevelsBeat);
         }
         GlobalValues.forceRecord = false;
     }
     if (GlobalValues.clearTimes)
     {
         ClearTimes();
         GlobalValues.clearTimes = false;
     }
 }
Esempio n. 23
0
 static void registerScores()
 {
     PlayerPrefsX.SetFloatArray("scores", scoreList.ToArray());
 }
 public static void ClearFloatArray(string key)      // PELLE FEZ ESSE
 {
     PlayerPrefsX.SetFloatArray(key, new float[0]);
 }
Esempio n. 25
0
    // Start is called before the first frame update
    void Start()
    {
        gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();

        names = PlayerPrefsX.GetStringArray("names", "", 1);
        times = PlayerPrefsX.GetFloatArray("times", 0f, 1);

        if (names[0] == "")
        {
            names[0] = gameManager.playerName;
            times[0] = gameManager.completetimervalue;

            PlayerPrefsX.SetStringArray("names", names);
            PlayerPrefsX.SetFloatArray("times", times);

            winText.text = "You Win " + gameManager.playerName;;


            timerText.text = "You finished at: " + gameManager.completetimervalue;


            leaderboard1.text = names[0] + " " + times[0];
            leaderboard2.text = "No Users yet entered";
            leaderboard3.text = "No Users yet entered";
        }
        else
        {
            p = new PlayerScores();

            List <PlayerScores> playerScore = new List <PlayerScores>();

            for (int x = 0; x < names.Length; x++)
            {
                p         = new PlayerScores();
                p.playerN = names[x];
                p.timeN   = times[x];

                playerScore.Add(p);
                playerScore.Sort((p1, p2) => p1.timeN.CompareTo(p2.timeN));
            }

            p         = new PlayerScores();
            p.playerN = gameManager.playerName;
            p.timeN   = gameManager.completetimervalue;

            playerScore.Add(p);

            System.Array.Resize(ref names, names.Length + 1);
            System.Array.Resize(ref times, times.Length + 1);

            names[names.Length - 1] = gameManager.playerName;
            times[times.Length - 1] = gameManager.completetimervalue;

            PlayerPrefsX.SetStringArray("names", names);
            PlayerPrefsX.SetFloatArray("times", times);

            winText.text = "You Win " + p.playerN;

            timerText.text = "You finished at: " + p.timeN;


            if (names.Length <= 2)
            {
                playerScore.Sort((p1, p2) => p1.timeN.CompareTo(p2.timeN));

                leaderboard1.text = playerScore[0].playerN + " " + playerScore[0].timeN;
                leaderboard2.text = playerScore[1].playerN + " " + playerScore[1].timeN;
                leaderboard3.text = "No Users yet entered";
            }

            if (names.Length > 2)
            {
                playerScore.Sort((p1, p2) => p1.timeN.CompareTo(p2.timeN));

                leaderboard1.text = playerScore[0].playerN + " " + playerScore[0].timeN;
                leaderboard2.text = playerScore[1].playerN + " " + playerScore[1].timeN;
                leaderboard3.text = playerScore[2].playerN + " " + playerScore[2].timeN;
            }
        }
    }