getIconScale() public method

public getIconScale ( ) : float
return float
Ejemplo n.º 1
0
    public void OnGUI()
    {
        GUI.skin = menuSkin;
        int width        = (int)(Screen.width * menuWidth);
        int height       = (int)(Screen.height * menuHeight);
        int offTop       = (int)(Screen.height * offsetTop);
        int buttonHeight = height / 4;

        // Set name.
        int setNameHeight = (int)(Screen.height * 0.12f);
        int setNameOffTop = (int)(Screen.height * 0.01f);

        GUILayout.BeginArea(new Rect(Screen.width / 2 - width / 2, setNameOffTop, width, setNameHeight));
        playerName = GUILayout.TextField(playerName, 35, GUILayout.Height(setNameHeight));
        GUILayout.EndArea();

        // Animal selection.
        int     animSelHeight = Screen.height / 2;
        int     animSelWidth  = (int)(Screen.width * 0.9f);
        int     animSelOffTop = setNameOffTop + (int)(Screen.height * 0.32f);
        int     arrowSize     = animSelHeight / 2;
        Texture icon          = animalSprites[curAnimal].texture;
        int     iconSize      = (int)(animSelHeight * anim.getIconScale());

        GUI.backgroundColor = Color.clear;

        // Draw the arrows.
        GUILayout.BeginArea(new Rect(Screen.width / 2 - animSelWidth / 2, animSelOffTop, animSelWidth, animSelHeight));
        GUILayout.BeginHorizontal();
        if (GUILayout.Button(arrowFlippedIcon, GUILayout.Height(arrowSize), GUILayout.Width(arrowSize)))
        {
            ChangeAnimal(1);
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button(arrowIcon, GUILayout.Height(arrowSize), GUILayout.Width(arrowSize)))
        {
            ChangeAnimal(-1);
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        // Draw the animal icon.
        GUILayout.BeginArea(new Rect(Screen.width / 2 - animSelWidth / 2, animSelOffTop - iconSize / 4, animSelWidth, iconSize));
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button(icon, GUILayout.Height(iconSize), GUILayout.Width(iconSize)))
        {
            anim.setAnimation(true);
            AudioSource.PlayClipAtPoint(cries[curAnimal], new Vector3(0, 0, 0));
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        GUI.backgroundColor = Color.white;

        // Back button.
        GUILayout.BeginArea(new Rect(Screen.width / 2 - width / 2, Screen.height / 2 - height / 2 + offTop, width, height));
        GUILayout.FlexibleSpace();
        string animalName = animalSprites[curAnimal].name;

        if (GUILayout.Button("Yeah! " + animalName + "s!", GUILayout.Height(buttonHeight)))
        {
            SafeSettings();
            GoBack();
        }
        GUILayout.EndArea();
    }
Ejemplo n.º 2
0
    public void OnGUI()
    {
        GUI.skin = menuSkin;

        int width  = (int)(Screen.width * menuWidth);
        int height = (int)(Screen.height * menuHeight);
        int offTop = (int)(Screen.height * offsetTop);

        int logoWidth  = (int)(((float)(width * logoScale) / logo.width) * logo.width);
        int logoHeight = (int)(((float)(width * logoScale) / logo.width) * logo.height);

        int buttonHeight = height / 4;

        switch (this.menuView)
        {
        /*Menu buttons*/
        case menuView_t.MENU:
        {
            menuSkin.button.padding.bottom = 0;
            GUI.DrawTexture(new Rect(Screen.width / 2 - logoWidth / 2, 15, logoWidth, logoHeight), logo);
            GUILayout.BeginArea(new Rect(Screen.width / 2 - width / 2, Screen.height / 2 - height / 2 + offTop, width, height));
            GUILayout.FlexibleSpace();
            if (isGameHosted())
            {
                if (GUILayout.Button("Visit Party", GUILayout.Height(buttonHeight)))
                {
                    Join();
                }
            }
            else
            {
                if (GUILayout.Button("Host Party", GUILayout.Height(buttonHeight)))
                {
                    Host();
                }
            }
            if (GUILayout.Button("Customize", GUILayout.Height(buttonHeight)))
            {
                GotoMenu <SettingsMenu> ();
            }
            if (GUILayout.Button("Exit", GUILayout.Height(buttonHeight)))
            {
                Application.Quit();
            }
            GUILayout.EndArea();

            break;
        }

        /*Credits Window*/
        case menuView_t.CREDITS:
        {
            windowPosition_t windowCredits = new windowPosition_t(2 * Screen.width / 3, 2 * Screen.height / 3, Screen.height / 6, Screen.width / 6);
            menuSkin.box.alignment = TextAnchor.MiddleCenter;
            //menuSkin.box.fontSize = 30;
            string creditsText = "Matchimals, 2016 (public alpha)\n\n\n" +
                                 "Developed by RuggedStudio \n([email protected])\n\n" +
                                 "Rijksuniversiteit Groningen \n(University of Groningen, NL)\n\n " +
                                 "Authors:\n Sietze Houwink, Matteo Corradini, \n" +
                                 "the impeccable Luc van den Brand, \n" +
                                 "Twan Schoonen and Dan Chirtoaca";

            GUILayout.BeginArea(new Rect(windowCredits.windowOffLeft, windowCredits.windowOffTop, Screen.width, Screen.height));
            GUI.Box(new Rect(0, 0, windowCredits.windowWidth, windowCredits.windowHeight), creditsText);
            GUILayout.EndArea();

            break;
        }

        /*Rules window*/
        case menuView_t.RULE:
        {
            windowPosition_t windowRules = new windowPosition_t(2 * Screen.width / 3, 2 * Screen.height / 3, Screen.height / 6, Screen.width / 6);
            menuSkin.box.alignment = TextAnchor.UpperCenter;
            int       tmpPaddingTop            = menuSkin.box.padding.top;
            Texture2D tmpNormalBackgroudButton = menuSkin.button.normal.background;
            Texture2D tmpActiveBackgroudButton = menuSkin.button.active.background;
            menuSkin.box.padding.top = Screen.height / 20;
            windowPosition_t windowIstrutionText = new windowPosition_t(windowRules.windowWidth, windowRules.windowHeight - Screen.height / 6,
                                                                        menuSkin.box.fontSize, 0);
            string instructionText = this.instructionPages [this.indexInstructionPage];

            GUILayout.BeginArea(new Rect(windowRules.windowOffLeft, windowRules.windowOffTop,
                                         windowRules.windowWidth, windowRules.windowHeight));
            GUI.Box(new Rect(0, 0, windowRules.windowWidth, windowRules.windowHeight),
                    "Instructions (" + (this.indexInstructionPage + 1) + "/" + NUMBER_INSTRUCTION_PAGES + ")");
            GUI.Label(new Rect(windowIstrutionText.windowOffLeft, windowIstrutionText.windowOffTop,
                               windowIstrutionText.windowWidth, windowIstrutionText.windowHeight), instructionText);
            GUILayout.EndArea();

            /*Arrow Area*/
            windowPosition_t windowArrow = new windowPosition_t(windowRules.windowWidth, Screen.height / 6,
                                                                Screen.height - windowRules.windowOffTop - Screen.height / 6, windowRules.windowOffLeft);

            Texture arrowIcon, arrowFlippedIcon;
            arrowIcon        = Resources.Load <Texture>("Menu/arrow");
            arrowFlippedIcon = Resources.Load <Texture>("Menu/arrow-flipped");
            int arrowSize = windowArrow.windowHeight / 2;
            menuSkin.button.normal.background = null;
            menuSkin.button.active.background = null;

            GUILayout.BeginArea(new Rect(windowArrow.windowOffLeft, windowArrow.windowOffTop, windowArrow.windowWidth, windowArrow.windowHeight));
            GUILayout.BeginHorizontal();
            if (this.indexInstructionPage != 0)
            {
                if (GUILayout.Button(arrowFlippedIcon, GUILayout.Height(arrowSize), GUILayout.Width(arrowSize)))
                {
                    this.indexInstructionPage--;
                }
            }
            GUILayout.FlexibleSpace();
            if (this.indexInstructionPage != NUMBER_INSTRUCTION_PAGES - 1)
            {
                if (GUILayout.Button(arrowIcon, GUILayout.Height(arrowSize), GUILayout.Width(arrowSize)))
                {
                    this.indexInstructionPage++;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            menuSkin.box.padding.top          = tmpPaddingTop;
            menuSkin.button.normal.background = tmpNormalBackgroudButton;
            menuSkin.button.active.background = tmpActiveBackgroudButton;
            break;
        }
        }

        menuSkin.button.padding.bottom = 10;
        windowPosition_t windowRuleCredit = new windowPosition_t(Screen.width / 3, Screen.height / 7,
                                                                 Screen.height - Screen.height / 7, Screen.width / 20);

        int iconAnimalSize = (int)((Screen.height / 8) * anim.getIconScale());
        int iconSize       = Screen.height / 8;

        /*Credits and info area*/
        GUI.backgroundColor = Color.clear;
        GUILayout.BeginArea(new Rect(windowRuleCredit.windowOffLeft, windowRuleCredit.windowOffTop, windowRuleCredit.windowWidth, windowRuleCredit.windowHeight));
        GUILayout.BeginHorizontal();
        int blankSpaceAmongIcons = Screen.width / 20;

        for (int i = 1; i < icons.Length; i++)
        {
            if (GUILayout.Button(this.icons [i], GUILayout.Height(iconSize), GUILayout.Width(iconSize)))
            {
                switch (i)
                {
                case 1:
                    if (this.menuView != menuView_t.RULE)
                    {
                        this.menuView = this.menuView == menuView_t.CREDITS ? menuView_t.MENU : menuView_t.CREDITS;
                    }
                    break;

                case 2:
                    if (this.menuView != menuView_t.CREDITS)
                    {
                        this.indexInstructionPage = 0;
                        this.menuView             = this.menuView == menuView_t.RULE ? menuView_t.MENU : menuView_t.RULE;
                    }
                    break;
                }
            }
            GUILayout.Space(blankSpaceAmongIcons);
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
        GUI.backgroundColor = Color.white;

        windowPosition_t windowIconAnimal = new windowPosition_t(windowRuleCredit.windowWidth, windowRuleCredit.windowHeight,
                                                                 windowRuleCredit.windowOffTop, 5 * Screen.width / 6);

        /*Animal area*/
        GUILayout.BeginArea(new Rect(windowIconAnimal.windowOffLeft, windowIconAnimal.windowOffTop, windowIconAnimal.windowWidth, windowIconAnimal.windowHeight));
        GUILayout.BeginHorizontal();
        GUI.backgroundColor = Color.clear;
        if (GUILayout.Button(this.icons [0], GUILayout.Height(iconAnimalSize), GUILayout.Width(iconAnimalSize)))
        {
            anim.setAnimation(true);
            AudioClip[] cries;
            cries = Resources.LoadAll <AudioClip> ("AnimalSounds");
            AudioSource.PlayClipAtPoint(cries [this.curAnimal], new Vector3(0, 0, 0));
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }