From 87dd5042e65adb727ed4a58de5a2178f9eda509c Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 25 Apr 2019 18:09:28 +0300 Subject: [PATCH] (bc52b535a) Added: Highlighting to order options in Captain's tutorial --- .../Source/GameSession/CrewManager.cs | 9 ++++++ .../GameModes/Tutorials/CaptainTutorial.cs | 31 +++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index 932a2caf8..8d1b7f83a 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -65,6 +65,8 @@ namespace Barotrauma } } + public List OrderOptionButtons = new List(); + #endregion #region Constructors @@ -914,9 +916,12 @@ namespace Barotrauma if (Character.Controlled == null) return false; SetCharacterOrder(character, userData as Order, option, Character.Controlled); orderTargetFrame = null; + OrderOptionButtons.Clear(); return true; } }; + + OrderOptionButtons.Add(optionButton); } } @@ -949,9 +954,13 @@ namespace Barotrauma if (Character.Controlled == null) return false; SetCharacterOrder(character, userData as Order, option, Character.Controlled); orderTargetFrame = null; + OrderOptionButtons.Clear(); return true; } }; + + OrderOptionButtons.Add(optionButton); + //lines between the order buttons if (i < order.Options.Length - 1) { diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/CaptainTutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/CaptainTutorial.cs index 35520cad9..a7e82cfff 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/CaptainTutorial.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/CaptainTutorial.cs @@ -165,8 +165,9 @@ namespace Barotrauma.Tutorials { yield return new WaitForSeconds(1.5f); GameMain.GameSession.CrewManager.HighlightOrderButton(captain_mechanic, "repairsystems", highlightColor, new Vector2(5, 5)); + HighlightOrderOption("jobspecific"); } - while (!HasOrder(captain_mechanic, "repairsystems")); + while (!HasOrder(captain_mechanic, "repairsystems", "jobspecific")); RemoveCompletedObjective(segments[1]); yield return new WaitForSeconds(2f); TriggerTutorialSegment(2); @@ -175,8 +176,9 @@ namespace Barotrauma.Tutorials { yield return new WaitForSeconds(1.5f); GameMain.GameSession.CrewManager.HighlightOrderButton(captain_security, "operateweapons", highlightColor, new Vector2(5, 5)); + HighlightOrderOption("fireatwill"); } - while (!HasOrder(captain_security, "operateweapons")); + while (!HasOrder(captain_security, "operateweapons", "fireatwill")); RemoveCompletedObjective(segments[2]); yield return new WaitForSeconds(4f); TriggerTutorialSegment(3); @@ -185,6 +187,7 @@ namespace Barotrauma.Tutorials { yield return new WaitForSeconds(1.5f); GameMain.GameSession.CrewManager.HighlightOrderButton(captain_engineer, "operatereactor", highlightColor, new Vector2(5, 5)); + HighlightOrderOption("powerup"); } while (!HasOrder(captain_engineer, "operatereactor", "powerup")); RemoveCompletedObjective(segments[3]); @@ -236,6 +239,30 @@ namespace Barotrauma.Tutorials CoroutineManager.StartCoroutine(TutorialCompleted()); } + private void HighlightOrderOption(string option) + { + if (GameMain.GameSession.CrewManager.OrderOptionButtons.Count == 0) return; + var order = GameMain.GameSession.CrewManager.OrderOptionButtons[0].UserData as Order; + + int orderIndex = 0; + for (int i = 0; i < GameMain.GameSession.CrewManager.OrderOptionButtons.Count; i++) + { + if (orderIndex >= order.Options.Length) + { + orderIndex = 0; + } + if (order.Options[orderIndex] == option) + { + if (GameMain.GameSession.CrewManager.OrderOptionButtons[i].Frame.FlashTimer <= 0) + { + GameMain.GameSession.CrewManager.OrderOptionButtons[i].Frame.Flash(highlightColor); + } + } + + orderIndex++; + } + } + private bool IsSelectedItem(Item item) { return captain?.SelectedConstruction == item;