Exemplo n.º 1
0
        /// <summary>
        /// Draws the Buttons and shows how many clients are connected to this players initialised server.
        /// </summary>
        public void OnGUI()
        {
            GUI.skin = _zodiacStyle;
            float    labelWidth   = Screen.width / 3;
            float    labelHeight  = Screen.width / 10;
            float    buttonWidth  = Screen.width / 5;
            float    buttonHeight = Screen.width / 10;
            float    buttonTop    = Screen.height * (2f / 3);
            float    buttonLeft   = Screen.width * (1f / 3);
            float    IPLabelTop   = Screen.height / 10;
            float    IPLabelLeft  = Screen.width / 10;
            float    NoLabelTop   = IPLabelTop;
            float    NoLabelLeft  = Screen.width * (2f / 3);
            float    sliderWidth  = Screen.width / 3;
            float    sliderHeight = Screen.height / 10;
            GUIStyle labelStyle   = new GUIStyle(GUI.skin.label);

            labelStyle.fontSize = (int)(labelHeight * 0.2f);

            string[] ip  = _net.Ip.Split(':');
            string   ip2 = ip[1].StartsWith("UN") ? "" : "\r\n local: \r\n" + ip[1];

            GUI.Label(new Rect(IPLabelLeft, IPLabelTop, labelWidth, labelHeight), "Your IP is: \r\n " + ip[0] + ip2, labelStyle);
            GUI.Label(new Rect(NoLabelLeft, NoLabelTop, labelWidth, labelHeight), "There are " + _net.NumOfConnections + " Players Connected", labelStyle);

            _connections   = Mathf.Round(GUIOperations.LabeledSlider(new Rect(NoLabelLeft * 0.8f, IPLabelTop + sliderHeight, sliderWidth, sliderHeight), "Maximum Players: " + _connections.ToString(), _connections, 2, NetworkController.REALMAXIMUMOFPLAYER));
            _net.MaxPlayer = (int)_connections; // dat's rly ugly ...is called every OnGUI() :/

            if (GUI.Button(new Rect(Screen.width - (Screen.width / 7), Screen.height * (8.5f / 14), (5 * buttonWidth) / 8, (3 * buttonHeight) / 4), "Back"))
            {
                _net.Disconnect();
                Application.LoadLevel("SMHostJoin");
            }

            if (_net.Ready != _net.MaxPlayer)
            { // SUBJECT TO CHANGE
                GUI.enabled = false;
            }

            if (GUI.Button(new Rect(buttonLeft, buttonTop, buttonWidth, buttonHeight), "Start"))
            {
                GameManager.GetInstance().ResetLevel();
                _manager.Difficulty     = 0;
                _manager.HeroCount      = 1;
                _manager.PlayerCount    = 1;
                _manager.MercenaryCount = 0;
                _manager.SectionNo      = 1;
                _manager.TeamCount      = 2;
                Application.LoadLevel("CharacterSelection");
            }

            GUI.enabled = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Draw all Video options on GUI Screen
        /// </summary>
        /// <param name="offsetVideoWidth">Top point of the Video box</param>
        /// <param name="offsetVideo">Left point of the Video box</param>
        /// <param name="boxWidth">width of the video box</param>
        /// <param name="boxHeight">height of the video box</param>
        protected void GUIVideoOptions(float offsetVideoWidth, float offsetVideo, float boxWidth, float boxHeight)
        {
            ////// Video Options //////
            GUI.Box(new Rect(offsetVideoWidth, offsetVideo, boxWidth, boxHeight), "Video");

            // Resolution box
            GUI.Button(new Rect(offsetVideoWidth, offsetVideo + (boxHeight / 2), boxWidth, boxHeight), "Resolution");

            // Resolution slider
            _resolution = Mathf.Round(GUIOperations.LabeledSlider(new Rect(offsetVideoWidth + boxWidth, offsetVideo + (boxHeight / 2), boxWidth, boxHeight), string.Empty, _resolution, 0, 3));
            GUI.Button(new Rect(offsetVideoWidth + (19 * boxWidth / 10), offsetVideo + (boxHeight / 2), boxWidth, boxHeight), Enum.GetNames(typeof(Resolution))[(int)_resolution].Substring(1));

            // Quality box
            GUI.Button(new Rect(offsetVideoWidth, offsetVideo + (5 * boxHeight / 4), boxWidth, boxHeight), "Quality");

            // Quality slider
            _quality = Mathf.Round(GUIOperations.LabeledSlider(new Rect(offsetVideoWidth + boxWidth, offsetVideo + (5 * boxHeight / 4), boxWidth, boxHeight), string.Empty, _quality, 0, 2));
            GUI.Button(new Rect(offsetVideoWidth + (19 * boxWidth / 10), offsetVideo + (5 * boxHeight / 4), boxWidth, boxHeight), Enum.GetNames(typeof(Quality))[(int)_quality]);
            //////////////////////////
        }
Exemplo n.º 3
0
        /// <summary>
        /// Prints the Play setting menu and the connected screen from
        /// </summary>
        public void OnGUI()
        {
            GUI.skin = Myskin;
            float boxHeight         = Screen.height / 10;
            float boxWidth          = Screen.width / 6;
            float buttonWidth       = Screen.width / 9;
            float sliderWidth       = Screen.width / 3;
            float buttonHeight      = Screen.height / 10;
            float offsetAudioHeight = Screen.height / 8;
            float offsetAudioWidth  = Screen.width / 3;
            float offsetVideo       = 3 * Screen.height / 5;
            float offsetVideoWidth  = Screen.width / 6;

            ////// Audio Options //////
            GUI.Box(new Rect(offsetAudioWidth, offsetAudioHeight, 2 * boxWidth, boxHeight), "Audio and Stuff");

            // Sound Effect box
            GUI.Button(new Rect(offsetAudioWidth, offsetAudioHeight + (boxHeight / 2), boxWidth, boxHeight), "Sound Effects");

            // Sound Effect slider
            _sfxLevelNew = Mathf.Round(GUIOperations.LabeledSlider(new Rect(offsetAudioWidth + boxWidth, offsetAudioHeight + (boxHeight / 2), sliderWidth, boxHeight), string.Empty, _sfxLevelOld, 0, 100));

            // Sound Effect info box
            GUI.Button(new Rect(offsetAudioWidth + (2 * boxWidth / 3) + sliderWidth, offsetAudioHeight + (boxHeight / 2), boxWidth, boxHeight), _sfxLevelNew + "%");

            if (_sfxLevelNew != _sfxLevelOld)
            {
                ConfigManager.GetInstance().SoundLevel = _sfxLevelNew;
                _sfxLevelOld    = _sfxLevelNew;
                _aSource        = GetComponents <AudioSource>()[0];
                _aSource.volume = ConfigManager.GetInstance().SoundLevel / 100;
                if (!_aSource.isPlaying)
                {
                    _aSource.Play();
                }
            }

            // Music box
            GUI.Button(new Rect(offsetAudioWidth, offsetAudioHeight + (5 * boxHeight / 4), boxWidth, boxHeight), "Music");

            // Music slider
            _musicLevel = Mathf.Round(GUIOperations.LabeledSlider(new Rect(offsetAudioWidth + boxWidth, offsetAudioHeight + (5 * boxHeight / 4), sliderWidth, boxHeight), string.Empty, _musicLevel, 0, 100));
            ConfigManager.GetInstance().MusicLevel = _musicLevel;
            GameObject go = GameObject.Find("GameMusic"); // Finds the game object called Game Music, if it goes by a different name, change this.

            go.audio.volume = ConfigManager.GetInstance().MusicLevel / 100.0f;

            // Sound Effect info box
            GUI.Button(new Rect(offsetAudioWidth + (2 * boxWidth / 3) + sliderWidth, offsetAudioHeight + (5 * boxHeight / 4), boxWidth, boxHeight), _musicLevel + "%");

            // Awesomeness box
            GUI.Button(new Rect(offsetAudioWidth, offsetAudioHeight + (8 * boxHeight / 4), boxWidth, boxHeight), "Awesomeness");

            // Awesomeness slider
            _awesomeness = Mathf.Round(GUIOperations.LabeledSlider(new Rect(offsetAudioWidth + boxWidth, offsetAudioHeight + (8 * boxHeight / 4), sliderWidth, boxHeight), string.Empty, _awesomenessMin, 42, 10042));
            if (_awesomenessMin > _awesomeness)
            {
                _awesomeness = _awesomenessMin;
            }
            else
            {
                _awesomenessMin = _awesomeness;
            }

            GameManager.GetInstance().Awesomeness = _awesomeness;

            // Awesomeness info box
            GUI.Button(new Rect(offsetAudioWidth + (3 * boxWidth / 4) + sliderWidth, offsetAudioHeight + (8 * boxHeight / 4), boxWidth, boxHeight), _awesomeList[(int)((_awesomeness / 10042.0f) * (_awesomeList.Count - 1))]);

            /*
             * GUIVideoOptions(offsetVideoWidth, offsetVideo, boxWidth, boxHeight);
             *
             * //Buttons for applying video settings, switching to key bindings or main menu
             *
             *
             * if (GUI.Button(new Rect(offsetVideoWidth + 3 * boxWidth / 2, offsetVideo + 12 * boxHeight / 5, 3 * boxWidth / 4, 3 * boxHeight / 4), "Apply"))
             * {
             *  //Change Resolutions
             *  GameManager.GetInstance().VideoQuality = (int)_quality;
             *  GameManager.GetInstance().Resolution = (int)_resolution;
             * }
             */
            GUI.skin = Myskin2;
            float fontSize = 0.03f * Screen.height;

            GUI.skin.button.fontSize = (int)fontSize;
            if (GUI.Button(new Rect((Screen.width / 6) - (7 * buttonWidth / 5), Screen.height - (Screen.height * (3.5f / 14)), 7 * buttonWidth / 5, buttonHeight), "Main Menu"))
            {
                // TODO: Error checking!
                ConfigManager.GetInstance().SaveConfig();
                Application.LoadLevel("MainMenu");
            }

            if (GUI.Button(new Rect(Screen.width - (Screen.width / 6), Screen.height - (Screen.height * (3.5f / 14)), 7 * buttonWidth / 5, buttonHeight), "Key Bindings"))
            {
                Application.LoadLevel("KeySettings");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Draw the character selection screen and sets gameoptions.
        /// calculates the box sizes
        /// </summary>
        public void OnGUI()
        {
            GUI.skin = _myskin2;
            if (manager.GameMode == GameManager.Mode.PLAY)
            {
                // all values are calculated relativ to screen in order to fit the Background
                float boxHeight              = Screen.height / 10;
                float boxWidth               = Screen.width / 6;
                float sliderWidth            = Screen.width / 3;
                float buttonWidth            = Screen.width / 9;
                float buttonHeight           = Screen.height / 10;
                float offsetDifficultyWidth  = 3 * Screen.width / 5;
                float offsetDifficultyHeight = Screen.width / 20;
                float offsetSectionWidth     = Screen.width / 20;
                float offsetSectionHeight    = Screen.width / 20;
                float offsetHeroWidth        = Screen.width / 9;
                float offsetHeroHeight       = 3 * Screen.height / 5;
                float offsetAIWidth          = Screen.width / 3;
                float offsetAIHeight         = 3 * Screen.height / 4;

                _maxHumans = 2;
                _maxHeroes = 8;

                // The Difficulty and Level sliders are drawn here
                switch ((int)_difficulty)
                {
                case 0:
                    _difficultyString = "N00b";
                    break;

                case 1:
                    _difficultyString = "Easy going";
                    break;

                case 2:
                    _difficultyString = "Come get some";
                    break;

                case 3:
                    _difficultyString = "Hurt me plently";
                    break;

                case 4:
                    _difficultyString = "Kick ass!";
                    break;

                case 5:
                    _difficultyString = "Insane";
                    break;

                default:
                    break;
                }

                // Difficulty box and slider
                GUI.Box(new Rect(offsetDifficultyWidth, offsetDifficultyHeight, 2 * boxWidth, boxHeight), "Difficulty");
                _difficulty = Mathf.Round(GUIOperations.LabeledSlider(new Rect(offsetDifficultyWidth, offsetDifficultyHeight + (boxHeight / 3), sliderWidth, boxHeight), string.Empty, _difficulty, 0, _maxDifficulty));
                GUI.Button(new Rect(offsetDifficultyWidth, offsetDifficultyHeight + (2 * boxHeight / 3), 2 * boxWidth, boxHeight), _difficultyString);

                // Difficulty box and slider
                GUI.Box(new Rect(offsetSectionWidth, offsetSectionHeight, 2 * boxWidth, boxHeight), "Section");
                _section = Mathf.Round(GUIOperations.LabeledSlider(new Rect(offsetSectionWidth, offsetSectionHeight + (boxHeight / 3), sliderWidth, boxHeight), string.Empty, _section, 1, _maxSection));
                GUI.Button(new Rect(offsetSectionWidth, offsetSectionHeight + (2 * boxHeight / 3), 2 * boxWidth, boxHeight), _section.ToString());

                // Hero box and slider
                GUI.Box(new Rect(offsetHeroWidth, offsetHeroHeight, 2 * boxWidth, boxHeight), "Humans");
                _humans = Mathf.Round(GUIOperations.LabeledSlider(new Rect(offsetHeroWidth + (sliderWidth / 4), offsetHeroHeight + (boxHeight / 3), sliderWidth / 2, boxHeight), string.Empty, _humans, 1, _maxHumans));
                GUI.Button(new Rect(offsetHeroWidth, offsetHeroHeight + (2 * boxHeight / 3), 2 * boxWidth, boxHeight), _humans.ToString());

                if ((int)_heroes > ((int)_maxHeroes - (int)_humans))
                {
                    _heroes = (float)((int)_maxHeroes - (int)_humans);
                }

                // AI-Hero box and slider
                GUI.Box(new Rect(offsetAIWidth, offsetAIHeight, 2 * boxWidth, boxHeight), "AI-Heroes");
                _heroes = Mathf.Round(GUIOperations.LabeledSlider(new Rect(offsetAIWidth, offsetAIHeight + (boxHeight / 3), sliderWidth, boxHeight), string.Empty, _heroes, 0, (float)((int)_maxHeroes - (int)_humans)));
                GUI.Button(new Rect(offsetAIWidth, offsetAIHeight + (2 * boxHeight / 3), 2 * boxWidth, boxHeight), _heroes.ToString());

                // Skin for Menu-Buttons
                GUI.skin = Myskin;
                float fontSize = 0.03f * Screen.height;
                GUI.skin.button.fontSize = (int)fontSize;

                // Both menu buttons
                if (GUI.Button(new Rect((Screen.width / 6) - (7 * buttonWidth / 5), Screen.height - (Screen.height * (3.5f / 14)), 7 * buttonWidth / 5, buttonHeight), "Back"))
                {
                    Application.LoadLevel("MainMenu");
                }

                if (GUI.Button(new Rect(Screen.width - (Screen.width / 6), Screen.height - (Screen.height * (3.5f / 14)), 7 * buttonWidth / 5, buttonHeight), "Continue"))
                {
                    GameManager.GetInstance().ResetLevel();
                    manager.HeroCount   = (int)_heroes;
                    manager.PlayerCount = (int)_humans;
                    manager.Difficulty  = (int)_difficulty;
                    manager.SectionNo   = (int)_section;
                    manager.TeamCount   = 1;
                    Application.LoadLevel("CharacterSelection");
                }
            }
            else if (manager.GameMode == GameManager.Mode.SPECIAL)
            {
                // all values are calculated relativ to screen in order to fit the Background
                float offset       = Screen.width / 30;
                float boxHeight    = Screen.height / 10;
                float boxWidth     = Screen.width / 5;
                float buttonWidth  = Screen.width / 9;
                float buttonHeight = Screen.height / 10;
                if (!_net.IsServer && !_net.IsClient)
                { // only needed for the shortcut
                    _maxHumans = 8;
                    _maxHeroes = 8;

                    // offset for the hero/merc/team settings
                    float offHumanTop = (Screen.height / 2) + (3f * offset);

                    // sliders for the hero/merc/team settings;
                    _humans = Mathf.Round(GUIOperations.LabeledSlider(new Rect((1 * offset) + (boxWidth / 2), offHumanTop + (boxHeight / 2), boxWidth + 50, boxHeight), "Number of Humans: " + (int)_humans, _humans, 2, _maxHumans));

                    // _mercs = Mathf.Round(GUIOperations.LabeledSlider(new Rect(3 * offset + boxWidth / 2, offHumanTop - boxHeight, boxWidth + 50, boxHeight), "Number of Mercs: " + (int)_mercs, _mercs, 0, _maxMercs));
                    if ((int)_heroes > ((int)_maxHeroes - (int)_humans))
                    {
                        _heroes = (float)((int)_maxHeroes - (int)_humans);
                    }

                    _heroes  = GUIOperations.LabeledSlider(new Rect(offset + (3 * boxWidth / 2), offHumanTop + (2 * boxHeight), boxWidth + 50, boxHeight), "Number of AI-Heroes: " + (int)_heroes, _heroes, 0, (float)((int)_maxHeroes - (int)_humans));
                    GUI.skin = Myskin;
                    float fontSize = 0.03f * Screen.height;
                    GUI.skin.button.fontSize = (int)fontSize;
                    if (GUI.Button(new Rect(Screen.width - (Screen.width / 7), Screen.height * (8.5f / 14), 6 * buttonWidth / 5, buttonHeight), "Main Menu"))
                    {
                        Application.LoadLevel("MainMenu");
                    }

                    if (GUI.Button(new Rect(Screen.width - (Screen.width / 7), Screen.height - (Screen.height * (3.5f / 14)), 6 * buttonWidth / 5, buttonHeight), "Continue"))
                    {
                        manager.Difficulty     = 0;
                        manager.HeroCount      = (int)_heroes;
                        manager.PlayerCount    = (int)_humans;
                        manager.MercenaryCount = (int)_mercs;
                        manager.SectionNo      = 1;
                        manager.TeamCount      = 2;
                        Application.LoadLevel("CharacterSelection");
                    }
                }

                if (_net.IsClient)
                {
                    _firstBackground.GetComponent <GUITexture>().gameObject.SetActive(false);
                    _secondBackground.GetComponent <GUITexture>().gameObject.SetActive(true);
                    manager.Difficulty     = 0;
                    manager.HeroCount      = (int)_heroes;
                    manager.PlayerCount    = (int)_humans;
                    manager.MercenaryCount = (int)_mercs;
                    manager.SectionNo      = 1;
                    manager.TeamCount      = 2;
                    GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
                    labelStyle.normal.textColor = Color.green;
                    float labelWidth  = Screen.width / 3;
                    float labelHeight = Screen.height / 7;
                    labelStyle.fontSize = (int)(0.15 * labelWidth);
                    GUI.Label(new Rect(Screen.width / 3, Screen.height - (Screen.height / 4) - (Screen.height / 8), labelWidth, labelHeight), "Connected", labelStyle);
                    GUIStyle buttonStyle = new GUIStyle(Myskin.button);
                    buttonStyle.fontSize = (int)(0.3f * buttonHeight);
                    if (GUI.Button(new Rect(Screen.width - (Screen.width / 7), Screen.height - (Screen.height * (3.5f / 14)), 6 * buttonWidth / 5, buttonHeight), "Continue", buttonStyle))
                    {
                        Application.LoadLevel("CharacterSelection");
                    }
                }
            }
        }