/// <summary> /// Draws the Loading Screen /// </summary> public void OnGUI() { GUI.skin = _zodiacStyle; GUIOperations.DrawLabelCenteredAt(Screen.width / 2, Screen.height * 5 / 6, (int)(0.1f * Screen.width), "Loading"); int top = (int)(Screen.height * 0.15f); int topoffset = (int)(0.05f * Screen.height); int left; int leftoffset = Screen.width / 3; if (GameManager.GetInstance().PlayerCount == 1) { left = Screen.width / 2; } else { left = Screen.width / 3; } for (int i = 1; i <= GameManager.GetInstance().PlayerCount; i++) { ControlKeysManager c = ConfigManager.GetInstance().GetControlKeysForPlayer(i); GUIOperations.DrawLabelCenteredAt(left, top - topoffset, (int)(0.04f * Screen.width), "Player " + i); GUIOperations.DrawLabelCenteredAt(left, top + topoffset, (int)(0.02f * Screen.width), "Walk up: " + ConfigManager.KeyToString(c.ForwardKey)); GUIOperations.DrawLabelCenteredAt(left, top + (2 * topoffset), (int)(0.02f * Screen.width), "Walk down: " + ConfigManager.KeyToString(c.BackwardKey)); GUIOperations.DrawLabelCenteredAt(left, top + (3 * topoffset), (int)(0.02f * Screen.width), "Walk left: " + ConfigManager.KeyToString(c.LeftKey)); GUIOperations.DrawLabelCenteredAt(left, top + (4 * topoffset), (int)(0.02f * Screen.width), "Walk right: " + ConfigManager.KeyToString(c.RightKey)); GUIOperations.DrawLabelCenteredAt(left, top + (5 * topoffset), (int)(0.02f * Screen.width), "Attack: " + ConfigManager.KeyToString(c.AttackKey)); GUIOperations.DrawLabelCenteredAt(left, top + (6 * topoffset), (int)(0.02f * Screen.width), "Defend: " + ConfigManager.KeyToString(c.DefendKey)); GUIOperations.DrawLabelCenteredAt(left, top + (7 * topoffset), (int)(0.02f * Screen.width), "Jump: " + ConfigManager.KeyToString(c.JumpKey)); GUIOperations.DrawLabelCenteredAt(left, top + (8 * topoffset), (int)(0.02f * Screen.width), "Pickup & Use: " + ConfigManager.KeyToString(c.PickupKey)); GUIOperations.DrawLabelCenteredAt(left, top + (9 * topoffset), (int)(0.02f * Screen.width), "Drop: " + ConfigManager.KeyToString(c.DropItemKey)); left += leftoffset; } }
/// <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; }
/// <summary> /// Draws the GUI elements /// </summary> public void OnGUI() { GUI.skin = _mySkin; if (GUIOperations.DrawButtonCenteredAt(11 * Screen.width / 16, 7 * Screen.height / 16, Screen.width / 6, Screen.height / 15, 1f, 0.7f, "Play again")) { Application.LoadLevel("GameSelection"); } if (GUIOperations.DrawButtonCenteredAt(13 * Screen.width / 16, 9 * Screen.height / 16, Screen.width / 6, Screen.height / 15, 1f, 0.7f, "Main Menu")) { Application.LoadLevel("MainMenu"); } if (GUIOperations.DrawButtonCenteredAt(35 * Screen.width / 64, 13 * Screen.height / 16, Screen.width / 6, Screen.height / 15, 1f, 0.7f, "Quit")) { Application.Quit(); } }
/// <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]); ////////////////////////// }
/// <summary> /// Draws the TeamBoxes for the Special mode /// </summary> private void DrawTeamBoxesSpecial() { float teamAreaLeft = _displayLeft; float teamAreaTop = _displayTop; _infoPercentage = 0; _teamAreaWidth = _displayWidth * (1 - _infoPercentage); GUIStyle teamLabelStyle = new GUIStyle(GUI.skin.label); GUIStyle baseLabelStyle = new GUIStyle(GUI.skin.label); GUIStyle infoTextStyle = new GUIStyle(GUI.skin.label); baseLabelStyle.alignment = TextAnchor.MiddleLeft; teamLabelStyle.alignment = TextAnchor.UpperLeft; infoTextStyle.alignment = TextAnchor.MiddleCenter; float teamWidth = _teamAreaWidth / _teamList.Count; float teamHeight = Screen.height * _fillingLevel * (2f / 3); teamLabelStyle.fontSize = (int)(teamWidth * .02f); // the height of the Team area is determined by the filling level (it is 2/3 because the mercenary boxes also have to fit) for (int i = 0; i < _teamList.Count; i++) { Texture2D barTexture = (i == 0) ? _manaBarTexture : _healthBarTexture; List <Character> characterList = _teamList[i].GetAllTeamMembers(); int mCount = _teamList[i].GetMercenaryTeamMembers().Count + _teamList[i].GetMobTeamMembers().Count; float teamXPos = _displayLeft + (i * teamWidth); GUI.Label(new Rect(teamXPos, teamAreaTop, teamWidth, teamHeight), "Team " + _teamList[i].TeamNo + ":", teamLabelStyle); float boxOffset = 1f / 10 * teamWidth; float boxWidth = teamWidth - boxOffset; float baseLabelWidth = boxWidth / 8; float baseLabelLeft = (teamXPos + boxOffset) + (boxOffset / 10); float barWidth = (boxWidth / 2) - baseLabelWidth; float barFactor = ((float)_teamList[i].Base.HP) / _teamList[i].Base.MaxHP; string infoString = "Captured " + _teamList[i].CapturedCheckpoints.Count + " Checkpoint\r\n" + "Received " + _teamList[i].Points + " Points\r\n" + "There are " + mCount + " servants"; GUI.Box(new Rect(teamXPos + boxOffset, teamAreaTop, boxWidth, teamHeight), string.Empty); GUI.Label(new Rect(baseLabelLeft, teamAreaTop, baseLabelWidth, teamHeight), "Base: ", baseLabelStyle); GUI.DrawTexture(new Rect(baseLabelLeft + baseLabelWidth, teamAreaTop + (teamHeight / 3), barFactor * barWidth, teamHeight / 3), barTexture); GUI.Label(new Rect(baseLabelLeft + baseLabelWidth + barWidth + (boxOffset / 10), teamAreaTop, (teamWidth / 2) - (boxOffset / 10), teamHeight), infoString, baseLabelStyle); } int c = 0; if (_net.IsServer) { c = GameObject.Find("HeroServer").GetComponent <Hero>().RespawnCountdown; } else if (_net.IsClient) { c = GameObject.Find("HeroClient" + _net.ClientNumber).GetComponent <Hero>().RespawnCountdown; } else { c = GameObject.Find("Hero1").GetComponent <Hero>().RespawnCountdown; } if (c > 0) { GUIStyle labelStyle = new GUIStyle(GUI.skin.label); labelStyle.normal.textColor = Color.red; labelStyle.fontSize = (int)(0.2 * Screen.width); GUIOperations.DrawLabelCenteredAt(Screen.width / 2, Screen.height / 3, (int)(0.05 * Screen.width), "Respawning in:"); GUIOperations.DrawLabelCenteredAt(Screen.width / 2, 2 * Screen.height / 3, (int)(0.2 * Screen.width), c.ToString(), labelStyle); } }
/// <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"); } }
/// <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"); } } } }