Пример #1
0
    void OnGUI()
    {
        GUI.skin = skin;

        GUI.BeginGroup(new Rect(0, 0, Screen.width, Screen.height));

        // Display
        float padding     = ResourceManager.Padding;
        float itemHeight  = ResourceManager.ButtonHeight;
        float buttonWidth = ResourceManager.ButtonWidth;
        float leftPos     = padding;
        float topPos      = padding;

        GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "");

        string message = "Game Over";

        if (winner)
        {
            message = "Congratulations " + winner.username + "! You have won by " + metVictoryCondition.GetDescription();
        }

        GUI.Label(new Rect(leftPos, topPos, Screen.width - 2 * padding, itemHeight), message);
        leftPos = Screen.width / 2 - padding / 2 - buttonWidth;
        topPos += itemHeight + padding;

        if (GUI.Button(new Rect(leftPos, topPos, buttonWidth, itemHeight), "New Game"))
        {
            PlayClick();
            // Makes sure that the loaded level runs at normal speed
            Time.timeScale           = 1.0f;
            ResourceManager.MenuOpen = false;
            Application.LoadLevel("Map");
        }

        leftPos += padding + buttonWidth;
        if (GUI.Button(new Rect(leftPos, topPos, buttonWidth, itemHeight), "Main Menu"))
        {
            PlayClick();
            ResourceManager.LevelName = "";
            Application.LoadLevel("MainMenu");
            Screen.showCursor = true;
        }

        GUI.EndGroup();
    }