Example #1
0
 void Awake()
 {
     groundScript  = GameObject.Find("GroundTriggerCollider").GetComponent <GroundScript> ();
     highScoreText = GameObject.Find("highScoreText").GetComponent <LeaderBoardScript> ();
     // PreLoad PlayerPrefs to cut down loadtime when checking the HighScore.
     highScoreText.LeaderBoard();
 }
    public void ResetHighScore()
    {
        PlayerPrefs.DeleteAll();
        LeaderBoardScript updateLeaderBoard = GameObject.Find("txt_highScores").GetComponent <LeaderBoardScript>();

        updateLeaderBoard.highScoreText.text = ("No High Scores.");
        GetComponent <AudioSource>().Play();
    }
Example #3
0
    private void OnGUI()
    {
        caterpillar = GameObject.FindGameObjectWithTag("CaterpillarManager");
        // PlayerPrefs.DeleteAll();
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(Screen.width), GUILayout.Height(Screen.height));
        GUIStyle myStyle    = new GUIStyle();
        GUIStyle titleStyle = new GUIStyle();
        Font     myFont     = (Font)Resources.Load("Fonts/CODERS_CRUX", typeof(Font));

        myStyle.font                = myFont;
        myStyle.fontSize            = 32;
        myStyle.normal.textColor    = Color.white;
        titleStyle.font             = myFont;
        titleStyle.fontSize         = 48;
        titleStyle.normal.textColor = Color.white;
        GUILayout.Space(20);
        GUILayout.Label("                    Results", titleStyle);
        GUILayout.Space(25);
        // Display high scores!
        for (int i = 0; i < LeaderBoardScript.EntryCount; ++i)
        {
            var entry = LeaderBoardScript.GetEntry(i);
            GUILayout.Label("                    " + (i + 1) + ". Name: " + entry.name + ", Time: " + entry.score, myStyle);
        }

        // Interface for reporting test scores.
        //GUILayout.Space(Screen.height - 300);

        //_nameInput = GUILayout.TextField(_nameInput);
        //_scoreInput = GUILayout.TextField(_scoreInput);

        int score;

        int.TryParse(_scoreInput, out score);
        if (rec < 1)
        {
            LeaderBoardScript.Record(_nameInput, score);
            caterpillar.GetComponent <CaterpillarLeaderboard>().Talk(Time.time - StartGame.startTime,
                                                                     LeaderBoardScript.EntryCount,
                                                                     LeaderBoardScript.GetTotalScore());
            // Reset for next input.
            _nameInput  = "";
            _scoreInput = "0";
            rec         = 1;
            //StartCoroutine(Wait(5.0f));
        }

        //Wait 25 seconds to go back to name screen.
        Invoke("DelayedFunction", 25.0f);
        GUILayout.EndArea();
    }
Example #4
0
	void Awake(){
		if(Instance==null)
			Instance=this;
		else
			Destroy(this.gameObject);
	}