Exemple #1
0
    void OnGUI()
    {
        float y = Screen.height / 2.0f - 45;
        float x = Screen.width / 2.0f - 50;

        // Napis: "type your name"
        GUIStyle centeredStyle = GUI.skin.GetStyle("Label");

        centeredStyle.alignment = TextAnchor.UpperCenter;

        if (GameGUI.English())
        {
            GUI.Label(new Rect(Screen.width / 2.0f - 100, y, 200, 30), "Type your name", centeredStyle);
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2.0f - 100, y, 200, 30), "Wpisz swoje imie", centeredStyle);
        }
        y += 30;

        // Pole tekstowe
        yourName = GUI.TextField(new Rect(x, y, 100, 20), yourName);

        y += 30;

        // Rozpocznij gre
        if (GUI.Button(new Rect(x, y, 100, 30), "START!"))
        {
            Time.timeScale = 1.0f;

            this.enabled = false;
        }
    }
Exemple #2
0
    void OnGUI()
    {
        float y = Screen.height / 2.0f - 45;
        float x = Screen.width / 2.0f - 50;

        // Wyswietlenie podsumowania

        GUIStyle centeredStyle = GUI.skin.GetStyle("Label");

        centeredStyle.alignment = TextAnchor.UpperCenter;

        GameObject  timeText = GameObject.Find("timeText");
        TimeCounter counter  = timeText.GetComponent <TimeCounter>();
        int         intTime  = (int)(counter.elapsedTime * 10);

        string name = GameObject.Find("typeYourName").GetComponent <TypeYourName>().yourName;

        if (GameGUI.English())
        {
            GUI.Label(new Rect(Screen.width / 2.0f - 100, y, 200, 30),
                      "Your time " + name + ": " + (intTime / 10) + "." + (intTime % 10) + "s", centeredStyle);
        }
        else
        {
            GUI.Label(new Rect(Screen.width / 2.0f - 100, y, 200, 30),
                      "Twoj czas " + name + ": " + (intTime / 10) + "." + (intTime % 10) + "s", centeredStyle);
        }
        y += 30;

        // Restart
        if (GUI.Button(new Rect(x, y, 100, 30), "Restart"))
        {
            Application.LoadLevel("AdRally");
        }

        y += 30;

        // Powrot do menu
        if (GUI.Button(new Rect(x, y, 100, 30), GameGUI.English() ? "Back to menu" : "Wroc do menu"))
        {
            Application.LoadLevel("menu");
        }
    }
Exemple #3
0
    void Update()
    {
        // Dodaj czas tej klatki
        elapsedTime += Time.deltaTime;

        int intTime = (int)(elapsedTime * 10);

        // Wyswietl aktualny czas
        if (GameGUI.English())
        {
            guiText.text = "TIME " + (intTime / 10) + "." + (intTime % 10);
        }
        else
        {
            guiText.text = "CZAS " + (intTime / 10) + "." + (intTime % 10);
        }

        // Jesli gra zawieszona to nie wyswietlaj czasu
        if (Time.timeScale == 0.0f)
        {
            guiText.text = "";
        }
    }