public CrewManagement(CampaignUI campaignUI, GUIComponent parentComponent) { this.campaignUI = campaignUI; this.parentComponent = parentComponent; CreateUI(); UpdateLocationView(campaignUI.Campaign.Map.CurrentLocation, true); campaignUI.Campaign.Map.OnLocationChanged += (prevLocation, newLocation) => UpdateLocationView(newLocation, true, prevLocation); }
private void InitCampaignUI() { campaignUIContainer = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: "InnerGlow", color: Color.Black); CampaignUI = new CampaignUI(this, campaignUIContainer) { StartRound = () => { GameMain.Client.RequestStartRound(); } }; }
partial void InitProjSpecific() { var buttonContainer = new GUILayoutGroup(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.ButtonAreaTop, GUICanvas.Instance), isHorizontal: true, childAnchor: Anchor.CenterRight) { CanBeFocused = false }; int buttonHeight = (int)(GUI.Scale * 40); int buttonWidth = GUI.IntScale(450); endRoundButton = new GUIButton(HUDLayoutSettings.ToRectTransform(new Rectangle((GameMain.GraphicsWidth / 2) - (buttonWidth / 2), HUDLayoutSettings.ButtonAreaTop.Center.Y - (buttonHeight / 2), buttonWidth, buttonHeight), GUICanvas.Instance), TextManager.Get("EndRound"), textAlignment: Alignment.Center, style: "EndRoundButton") { Pulse = true, TextBlock = { Shadow = true, AutoScaleHorizontal = true }, OnClicked = (btn, userdata) => { var availableTransition = GetAvailableTransition(out _, out _); if (Character.Controlled != null && availableTransition == TransitionType.ReturnToPreviousLocation && Character.Controlled?.Submarine == Level.Loaded?.StartOutpost) { GameMain.Client.RequestStartRound(); } else if (Character.Controlled != null && availableTransition == TransitionType.ProgressToNextLocation && Character.Controlled?.Submarine == Level.Loaded?.EndOutpost) { GameMain.Client.RequestStartRound(); } else { ShowCampaignUI = true; if (CampaignUI == null) { InitCampaignUI(); } CampaignUI.SelectTab(InteractionType.Map); } return(true); } }; buttonContainer.Recalculate(); }
private void InitUI() { int buttonHeight = (int)(GUI.Scale * 40); int buttonWidth = GUI.IntScale(450); endRoundButton = new GUIButton(HUDLayoutSettings.ToRectTransform(new Rectangle((GameMain.GraphicsWidth / 2) - (buttonWidth / 2), HUDLayoutSettings.ButtonAreaTop.Center.Y - (buttonHeight / 2), buttonWidth, buttonHeight), GUICanvas.Instance), TextManager.Get("EndRound"), textAlignment: Alignment.Center, style: "EndRoundButton") { Pulse = true, TextBlock = { Shadow = true, AutoScaleHorizontal = true }, OnClicked = (btn, userdata) => { var availableTransition = GetAvailableTransition(out _, out _); if (Character.Controlled != null && availableTransition == TransitionType.ReturnToPreviousLocation && Character.Controlled?.Submarine == Level.Loaded?.StartOutpost) { TryEndRound(); } else if (Character.Controlled != null && availableTransition == TransitionType.ProgressToNextLocation && Character.Controlled?.Submarine == Level.Loaded?.EndOutpost) { TryEndRound(); } else { ShowCampaignUI = true; CampaignUI.SelectTab(InteractionType.Map); } return(true); } }; campaignUIContainer = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: "InnerGlow", color: Color.Black); CampaignUI = new CampaignUI(this, campaignUIContainer) { StartRound = () => { TryEndRound(); } }; }
public override void Select() { base.Select(); CampaignMode campaign = GameMain.GameSession.GameMode as CampaignMode; if (campaign == null) { return; } locationTitle.Text = "Location: " + campaign.Map.CurrentLocation.Name; bottomPanel.ClearChildren(); campaignUI = new CampaignUI(campaign, bottomPanel); campaignUI.StartRound = StartRound; campaignUI.OnLocationSelected = SelectLocation; campaignUI.UpdateCharacterLists(); }
private bool TryEndRound() { var transitionType = GetAvailableTransition(out LevelData nextLevel, out Submarine leavingSub); if (leavingSub == null || transitionType == TransitionType.None) { return(false); } if (nextLevel == null) { //no level selected -> force the player to select one CampaignUI.SelectTab(InteractionType.Map); map.SelectLocation(-1); ForceMapUI = true; return(false); } else if (transitionType == TransitionType.ProgressToNextEmptyLocation) { Map.SetLocation(Map.Locations.IndexOf(Level.Loaded.EndLocation ?? Map.CurrentLocation)); } var subsToLeaveBehind = GetSubsToLeaveBehind(leavingSub); if (subsToLeaveBehind.Any()) { string msg = TextManager.Get(subsToLeaveBehind.Count == 1 ? "LeaveSubBehind" : "LeaveSubsBehind"); var msgBox = new GUIMessageBox(TextManager.Get("Warning"), msg, new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); msgBox.Buttons[0].OnClicked += (btn, userdata) => { LoadNewLevel(); return(true); }; msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[0].UserData = Submarine.Loaded.FindAll(s => !subsToLeaveBehind.Contains(s)); msgBox.Buttons[1].OnClicked += msgBox.Close; } else { LoadNewLevel(); } return(true); }
public override void Select() { base.Select(); CampaignMode campaign = GameMain.GameSession.GameMode as CampaignMode; if (campaign == null) { return; } locationTitle.Text = TextManager.Get("Location") + ": " + campaign.Map.CurrentLocation.Name; bottomPanel.ClearChildren(); campaignUI = new CampaignUI(campaign, bottomPanel); campaignUI.StartRound = StartRound; campaignUI.OnLocationSelected = SelectLocation; campaignUI.UpdateCharacterLists(); GameAnalyticsManager.SetCustomDimension01("singleplayer"); }
public override void Select() { base.Select(); CampaignMode campaign = GameMain.GameSession.GameMode as CampaignMode; if (campaign == null) { return; } campaign.Map.SelectLocation(-1); campaignUIContainer.ClearChildren(); campaignUI = new CampaignUI(campaign, campaignUIContainer) { StartRound = StartRound, OnLocationSelected = SelectLocation }; campaignUI.UpdateCharacterLists(); GameAnalyticsManager.SetCustomDimension01("singleplayer"); }
public override void Update(float deltaTime) { if (CoroutineManager.IsCoroutineRunning("LevelTransition") || Level.Loaded == null) { return; } if (ShowCampaignUI || ForceMapUI) { if (CampaignUI == null) { InitCampaignUI(); } Character.DisableControls = true; } base.Update(deltaTime); if (PlayerInput.SecondaryMouseButtonClicked() || PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.Escape)) { ShowCampaignUI = false; if (GUIMessageBox.VisibleBox?.UserData is RoundSummary roundSummary && roundSummary.ContinueButton != null && roundSummary.ContinueButton.Visible) { GUIMessageBox.MessageBoxes.Remove(GUIMessageBox.VisibleBox); } } if (!GUI.DisableHUD && !GUI.DisableUpperHUD) { endRoundButton.UpdateManually(deltaTime); ReadyCheckButton?.UpdateManually(deltaTime); if (CoroutineManager.IsCoroutineRunning("LevelTransition") || ForceMapUI) { return; } } if (Level.Loaded.Type == LevelData.LevelType.Outpost) { if (wasDocked) { var connectedSubs = Submarine.MainSub.GetConnectedSubs(); bool isDocked = Level.Loaded.StartOutpost != null && connectedSubs.Contains(Level.Loaded.StartOutpost); if (!isDocked) { //undocked from outpost, need to choose a destination ForceMapUI = true; if (CampaignUI == null) { InitCampaignUI(); } CampaignUI.SelectTab(InteractionType.Map); } } else { //wasn't initially docked (sub doesn't have a docking port?) // -> choose a destination when the sub is far enough from the start outpost if (!Submarine.MainSub.AtStartPosition) { ForceMapUI = true; if (CampaignUI == null) { InitCampaignUI(); } CampaignUI.SelectTab(InteractionType.Map); } } if (CampaignUI == null) { InitCampaignUI(); } } else { var transitionType = GetAvailableTransition(out _, out _); if (transitionType == TransitionType.None && CampaignUI?.SelectedTab == InteractionType.Map) { ShowCampaignUI = false; } } }
public override void Update(float deltaTime) { if (CoroutineManager.IsCoroutineRunning("LevelTransition") || CoroutineManager.IsCoroutineRunning("SubmarineTransition") || gameOver) { return; } base.Update(deltaTime); if (PlayerInput.SecondaryMouseButtonClicked() || PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.Escape)) { ShowCampaignUI = false; if (GUIMessageBox.VisibleBox?.UserData is RoundSummary roundSummary && roundSummary.ContinueButton != null && roundSummary.ContinueButton.Visible) { GUIMessageBox.MessageBoxes.Remove(GUIMessageBox.VisibleBox); } } #if DEBUG if (PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.R)) { if (GUIMessageBox.MessageBoxes.Any()) { GUIMessageBox.MessageBoxes.Remove(GUIMessageBox.MessageBoxes.Last()); } GUIFrame summaryFrame = GameMain.GameSession.RoundSummary.CreateSummaryFrame(GameMain.GameSession, "", null); GUIMessageBox.MessageBoxes.Add(summaryFrame); GameMain.GameSession.RoundSummary.ContinueButton.OnClicked = (_, __) => { GUIMessageBox.MessageBoxes.Remove(summaryFrame); return(true); }; } #endif if (ShowCampaignUI || ForceMapUI) { Character.DisableControls = true; } if (!GUI.DisableHUD && !GUI.DisableUpperHUD) { endRoundButton.UpdateManually(deltaTime); if (CoroutineManager.IsCoroutineRunning("LevelTransition") || ForceMapUI) { return; } } if (Level.Loaded.Type == LevelData.LevelType.Outpost) { KeepCharactersCloseToOutpost(deltaTime); if (wasDocked) { var connectedSubs = Submarine.MainSub.GetConnectedSubs(); bool isDocked = Level.Loaded.StartOutpost != null && connectedSubs.Contains(Level.Loaded.StartOutpost); if (!isDocked) { //undocked from outpost, need to choose a destination ForceMapUI = true; CampaignUI.SelectTab(InteractionType.Map); } } else { //wasn't initially docked (sub doesn't have a docking port?) // -> choose a destination when the sub is far enough from the start outpost if (!Submarine.MainSub.AtStartPosition) { ForceMapUI = true; CampaignUI.SelectTab(InteractionType.Map); } } } else { var transitionType = GetAvailableTransition(out _, out Submarine leavingSub); if (transitionType == TransitionType.End) { EndCampaign(); } if (transitionType == TransitionType.ProgressToNextLocation && Level.Loaded.EndOutpost != null && Level.Loaded.EndOutpost.DockedTo.Contains(leavingSub)) { LoadNewLevel(); } else if (transitionType == TransitionType.ReturnToPreviousLocation && Level.Loaded.StartOutpost != null && Level.Loaded.StartOutpost.DockedTo.Contains(leavingSub)) { LoadNewLevel(); } else if (transitionType == TransitionType.None && CampaignUI.SelectedTab == InteractionType.Map) { ShowCampaignUI = false; } } if (!crewDead) { if (!CrewManager.GetCharacters().Any(c => !c.IsDead)) { crewDead = true; } } else { endTimer -= deltaTime; if (endTimer <= 0.0f) { GameOver(); } } }