Esempio n. 1
0
    void OnGUI()
    {
        //set demensions of the buttons
        float buttonW = Screen.width / 3;
        float buttonH = Screen.height / 16;
        float halfScreenW, halfScreenH;
        //set the prebuilt button

        GUIStyle style = new GUIStyle(GUI.skin.button);

        style.fontSize = (int)(buttonH / 2);

        // -430 -290 -170 -50 70 190 310
        for (int i = 0; i < 7; i++)
        {
            halfScreenW = (Screen.width / 2) - buttonW / 2;
            halfScreenH = Screen.height / 6 + (buttonH * 1.5f) * i;
            if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Level: " + (i + 1), style))
            {
                GlobalFlags.setLevel(i + 1);
                Application.LoadLevel("game");
            }
        }

        //set the back button
        halfScreenW = (Screen.width / 2) - buttonW / 2;
        halfScreenH = Screen.height / 6 + (buttonH * 1.5f) * 7;
        if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Back", style))
        {
            Application.LoadLevel("ModeSelectMenu");
        }
    }
Esempio n. 2
0
    void OnGUI()
    {
        //set demensions of the buttons

        if (Resources.Load("levels/level" + (GlobalFlags.getLevel() + 1)))
        {
            //System.IO.File.ReadAllLines("assets/levels/level" + (GlobalFlags.getLevel() + 1) + ".txt");
            //GlobalFlags.setLevel(GlobalFlags.getLevel() + 1);

            float buttonW = Screen.width / 2.8f;
            float buttonH = Screen.width / 6;

            GUIStyle style = new GUIStyle(GUI.skin.button);
            style.fontSize = (int)(buttonH / 2.8);

            //set the play game button
            float halfScreenW = (Screen.width / 4) - buttonW / 2;
            float halfScreenH = (Screen.height / 2) + 0;
            if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Replay", style))
            {
                Application.LoadLevel("game");
            }

            halfScreenW = (3 * Screen.width / 4) - buttonW / 2;
            halfScreenH = (Screen.height / 2) + 0;
            if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Play Next", style))
            {
                GlobalFlags.setLevel(GlobalFlags.getLevel() + 1);
                Application.LoadLevel("game");
            }

            //set the exit button
            halfScreenW = (Screen.width / 4) - buttonW / 2;
            halfScreenH = Screen.height / 2 + buttonH * 1.5f;
            if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Level Select", style))
            {
                Application.LoadLevel("LevelSelectPreMenu");
            }

            //set the exit button
            halfScreenW = (3 * Screen.width / 4) - buttonW / 2;
            halfScreenH = Screen.height / 2 + buttonH * 1.5f;
            if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Main Menu", style))
            {
                Application.LoadLevel("ModeSelectMenu");
            }
        }
        else
        {
            float buttonW = Screen.width / 2.8f;
            float buttonH = Screen.width / 6;

            GUIStyle style = new GUIStyle(GUI.skin.button);
            style.fontSize = (int)(buttonH / 2.8);

            //set the play game button
            float halfScreenW = (Screen.width / 4) - buttonW / 2;
            float halfScreenH = (Screen.height / 2) + 0;
            if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Replay", style))
            {
                Application.LoadLevel("game");
            }

            halfScreenW = (3 * Screen.width / 4) - buttonW / 2;
            halfScreenH = (Screen.height / 2) + 0;
            if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Main Menu", style))
            {
                Application.LoadLevel("ModeSelectMenu");
            }
        }
    }