protected override MenuScreen ProtectedUpdate(MenuScreen.ScreenLayout layout) { elapsed += Time.deltaTime; if (elapsed >= WorldConstants.MatchEndWaitTIme.TotalSeconds) { return(new MatchStatsScreen(MatchData, Consts, Owner)); } return(this); }
protected override MenuScreen ProtectedUpdate(MenuScreen.ScreenLayout layout) { if (!started) { manager.StartWorld(false); started = true; Owner.MusicLooper.EndLoop(); Owner.MusicLooper = new FadeLoopNoise(Owner.MatchMusic, "Music"); Owner.MusicLooper.StartLoop(); } else { Owner.MusicLooper.UpdateLoop(); if (manager.GameOver) { return(new MatchEndScreen(MatchData, Consts, Owner)); } } return(this); }
protected override MenuScreen ProtectedUpdate(MenuScreen.ScreenLayout layout) { //Process bool flags. if (waitACycle) { waitACycle = false; return(this); } if (regenerate) { manager = WorldConstants.Creator.CreateMatchController().GetComponent <LevelManager>(); manager.StartWorld(true); regenerate = false; waitACycle = true; return(this); } if (!wasUpdated) { wasUpdated = true; GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), Owner.BackgroundTexture); } if (startGame) { return(new MatchScreen(MatchData, Consts, Owner)); } DrawTitleString("Choose a level", layout.Title); return(DrawButtonMenu(layout.ButtonMenu, new GUIContent[] { new GUIContent("Back"), new GUIContent("Re-generate"), new GUIContent("Start match"), }, new GetData <MenuScreen>[] { () => { Owner.DestroyMatch(false); return new LobbyMenuScreen(MatchData, Consts, Owner); }, () => { Owner.DestroyMatch(false); MatchData.GenerateLevelAndSpawns(); regenerate = true; return this; }, () => { Owner.DestroyMatch(false); waitACycle = true; startGame = true; return this; }, }, this)); }
protected override MenuScreen ProtectedUpdate(MenuScreen.ScreenLayout layout) { //Title and "back" button. DrawTitleString("Stats", layout.Title); MenuScreen scr = DrawButtonMenu(layout.ButtonMenu, new GUIContent[] { new GUIContent("Main Menu"), }, new GetData <MenuScreen>[] { () => { Owner.DestroyMatch(); return(new MainMenuScreen(MatchData, Consts, Owner)); }, }, null); if (scr != null) { return(scr); } //Get screen layout data. Rect area = layout.Body; Vector2 sViewportSize, sStatsOffset; float sCategorySpacing, sLineSpacing; Vector2 sButtonSize; float sButtonYOffset; sViewportSize = new Vector2((guiViewSizesByPlayers[players.Count].x - Consts.Stats_PlayerXBorder) * area.width, guiViewSizesByPlayers[players.Count].y * area.height); sStatsOffset = new Vector2(Consts.Stats_Offset.x * sViewportSize.x, Consts.Stats_Offset.y * sViewportSize.y); sCategorySpacing = sViewportSize.y * Consts.Stats_CategorySpacing; sLineSpacing = sViewportSize.y * Consts.Stats_LineSpacing; sButtonSize = new Vector2(Screen.width * Consts.Stats_ButtonSize.x, Screen.height * Consts.Stats_ButtonSize.y); sButtonYOffset = Screen.height * Consts.Stats_ButtonYOffset; //Output each players' stats. Vector2 lookupOffset, sPlayerOffset, tempTextPos; Color old; foreach (StateMachine st in players) { //Get the offset for the player's box. lookupOffset = guiOffsetsByPlayersAndID[players.Count][st.ActorData.PlayerID]; sPlayerOffset = new Vector2(area.width * lookupOffset.x, area.height * lookupOffset.y); sPlayerOffset += new Vector2(area.xMin, area.yMin); if (lookupOffset.x == 0.0f) { sPlayerOffset.x += (Consts.Stats_PlayerXBorder * area.width); } tempTextPos = sPlayerOffset + sStatsOffset; GUI.Box(new Rect(sPlayerOffset.x, sPlayerOffset.y, sViewportSize.x, sViewportSize.y), ""); old = GUI.color; GUI.color = st.ActorData.Team; GUI.DrawTexture(new Rect(sPlayerOffset.x + (sViewportSize.x * Consts.Stats_ImageOffset), sPlayerOffset.y + (sViewportSize.y * Consts.Stats_ImageOffset), Owner.PlayerTexture.width * Consts.Lobby_PlayerBox_ImageScale, Owner.PlayerTexture.height * Consts.Lobby_PlayerBox_ImageScale), Owner.PlayerTexture); GUI.color = old; foreach (List <string> category in statsToDisplay[st]) { foreach (string stat in category) { float f; string s; if (Single.TryParse(stat, out f)) { s = System.Math.Round(f, 2).ToString(); } else { s = stat; } GUI.Label(new Rect(tempTextPos.x, tempTextPos.y, sViewportSize.x - sStatsOffset.x, MyGUI.LabelHeight), s, WorldConstants.GUIStyles.GameStatsText); tempTextPos.y += sLineSpacing; } tempTextPos.y -= sLineSpacing; tempTextPos.y += sCategorySpacing; } } return(this); }
protected override MenuScreen ProtectedUpdate(MenuScreen.ScreenLayout layout) { DrawTitleString("Choose a game-type and level:", layout.Title); #region Draw matches and levels. //Some layout data. Rect body = layout.Body; float sSubtitleYOffset = body.height * Consts.Settings_SubtitleYOffset, sSubtitleHeight = body.height * Consts.Settings_SubtitleHeight; float sListYOffset = body.height * Consts.Settings_List_YOffset; float sListXOffset = body.width * Consts.Settings_List_XOffset; float sListSpacing = body.height * Consts.Settings_List_Spacing; Vector2 sListButtonSize = new Vector2(body.width * Consts.Settings_List_ButtonSize.x, body.height * Consts.Settings_List_ButtonSize.y); float sTooltipXOffset = body.width * Consts.Settings_TooltipXOffset, sTooltipYOffset = body.height * Consts.Settings_TooltipYOffset, sTooltipWidth = body.width * Consts.Settings_TooltipWidth; //Some layout rectangles. Rect matchesSubtitleRect = new Rect(body.xMin + sListXOffset, body.yMin + sSubtitleYOffset, sListButtonSize.x, sSubtitleHeight), levelsSubtitleRect = new Rect(body.xMax - sListXOffset - sListButtonSize.x, matchesSubtitleRect.yMin, matchesSubtitleRect.width, matchesSubtitleRect.height); MyGUI.RadioButtonsLayout matchesLayout = Consts.Settings_List_Layout(new Vector2(matchesSubtitleRect.xMin, matchesSubtitleRect.yMax + sListYOffset), body), levelsLayout = Consts.Settings_List_Layout(new Vector2(levelsSubtitleRect.xMin, levelsSubtitleRect.yMax + sListYOffset), body); Rect tooltipRect = new Rect(matchesSubtitleRect.xMax + sTooltipXOffset, body.yMin + sTooltipYOffset, sTooltipWidth, body.height - sTooltipYOffset); //Display the matches. if (matches == null) { GUI.color = Color.black; GUI.Label(body, "XML error when reading match settings:\n\"" + matchSettings.ErrorMessage + "\"."); } else { GUI.Label(matchesSubtitleRect, "Game-types", WorldConstants.GUIStyles.SubtitleLabels); selectedMatchIndex = MyGUI.RadioButtons(matches, selectedMatchIndex, matchesLayout, false, WorldConstants.GUIStyles.SettingsRadioButtons); selectedMatch = matches[selectedMatchIndex].text; MatchData.MatchSettings = matchSets[selectedMatchIndex]; } //Display the levels. if (levels == null) { GUI.color = Color.black; GUI.Label(body, "XML error when reading level settings:\n\"" + levelGeneration.ErrorMessage + "\"."); } else { GUI.Label(levelsSubtitleRect, "Levels", WorldConstants.GUIStyles.SubtitleLabels); int old = selectedLevelGenIndex; selectedLevelGenIndex = MyGUI.RadioButtons(levels, selectedLevelGenIndex, levelsLayout, false, WorldConstants.GUIStyles.SettingsRadioButtons); selectedLevelGen = levels[selectedLevelGenIndex].text; if (selectedLevelGen == "Open") { MatchStartData.IsGeneratingOpen = true; } else { MatchStartData.IsGeneratingOpen = false; } if (old != selectedLevelGenIndex) { MatchData.GeneratedLevel = levelGens[selectedLevelGenIndex]; MatchData.GenerateLevelAndSpawns(); } } GUI.color = Color.white; GUI.Label(tooltipRect, GUI.tooltip, WorldConstants.GUIStyles.SettingsTooltip); #endregion return(DrawButtonMenu(layout.ButtonMenu, new GUIContent[] { new GUIContent("Back"), new GUIContent("Continue") }, new GetData <MenuScreen>[] { () => new MainMenuScreen(MatchData, Consts, Owner), () => new LobbyMenuScreen(MatchData, Consts, Owner) }, this)); }
protected override MenuScreen ProtectedUpdate(MenuScreen.ScreenLayout layout) { if (advance) { GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), Owner.BackgroundTexture); return(new GenerateLevelMenuScreen(MatchData, Consts, Owner)); } //If the players just confirmed merging teams, exit. if (nextScreen != null) { return(nextScreen); } //If the players don't need to confirm merging teams, do the normal display. if (!confirmMergeTeams) { DrawTitleString("Lobby", layout.Title); //Buttons. MenuScreen vale; vale = DrawButtonMenu(layout.ButtonMenu, new GUIContent[] { new GUIContent("Back"), new GUIContent("Continue"), }, new GetData <MenuScreen>[] { () => { return(new CreateMatchMenuScreen(MatchData, Consts, Owner)); }, () => { //Try to build the match data. if (TryBuildMatchData(true)) { advance = true; return(this); } else { confirmMergeTeams = true; nextScreen = null; return(this); } }, }, null); if (vale != null) { return(vale); } //Players. for (int i = 0; i < 4; ++i) { playerDatas[i] = PlayerGUI(i, playerDatas[i]); } } //Otherwise, show the confirmation window. else { Vector2 sWndSize = new Vector2(Screen.width * Consts.Lobby_MergeTeamWarning_WindowSize.x, Screen.height * Consts.Lobby_MergeTeamWarning_WindowSize.y); Vector2 sWndPos = (new Vector2(Screen.width, Screen.height) - sWndSize) * 0.5f; Rect windBounds = new Rect(sWndPos.x, sWndPos.y, sWndSize.x, sWndSize.y); GUI.Window(1, windBounds, MergeTeamsWarningWindow, "Team merge warning"); } return(this); }