(bc52b535a) Added: Highlighting to order options in Captain's tutorial

This commit is contained in:
Joonas Rikkonen
2019-04-25 18:09:28 +03:00
parent 64cf732dc6
commit 87dd5042e6
2 changed files with 38 additions and 2 deletions
@@ -65,6 +65,8 @@ namespace Barotrauma
} }
} }
public List<GUIButton> OrderOptionButtons = new List<GUIButton>();
#endregion #endregion
#region Constructors #region Constructors
@@ -914,9 +916,12 @@ namespace Barotrauma
if (Character.Controlled == null) return false; if (Character.Controlled == null) return false;
SetCharacterOrder(character, userData as Order, option, Character.Controlled); SetCharacterOrder(character, userData as Order, option, Character.Controlled);
orderTargetFrame = null; orderTargetFrame = null;
OrderOptionButtons.Clear();
return true; return true;
} }
}; };
OrderOptionButtons.Add(optionButton);
} }
} }
@@ -949,9 +954,13 @@ namespace Barotrauma
if (Character.Controlled == null) return false; if (Character.Controlled == null) return false;
SetCharacterOrder(character, userData as Order, option, Character.Controlled); SetCharacterOrder(character, userData as Order, option, Character.Controlled);
orderTargetFrame = null; orderTargetFrame = null;
OrderOptionButtons.Clear();
return true; return true;
} }
}; };
OrderOptionButtons.Add(optionButton);
//lines between the order buttons //lines between the order buttons
if (i < order.Options.Length - 1) if (i < order.Options.Length - 1)
{ {
@@ -165,8 +165,9 @@ namespace Barotrauma.Tutorials
{ {
yield return new WaitForSeconds(1.5f); yield return new WaitForSeconds(1.5f);
GameMain.GameSession.CrewManager.HighlightOrderButton(captain_mechanic, "repairsystems", highlightColor, new Vector2(5, 5)); 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]); RemoveCompletedObjective(segments[1]);
yield return new WaitForSeconds(2f); yield return new WaitForSeconds(2f);
TriggerTutorialSegment(2); TriggerTutorialSegment(2);
@@ -175,8 +176,9 @@ namespace Barotrauma.Tutorials
{ {
yield return new WaitForSeconds(1.5f); yield return new WaitForSeconds(1.5f);
GameMain.GameSession.CrewManager.HighlightOrderButton(captain_security, "operateweapons", highlightColor, new Vector2(5, 5)); 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]); RemoveCompletedObjective(segments[2]);
yield return new WaitForSeconds(4f); yield return new WaitForSeconds(4f);
TriggerTutorialSegment(3); TriggerTutorialSegment(3);
@@ -185,6 +187,7 @@ namespace Barotrauma.Tutorials
{ {
yield return new WaitForSeconds(1.5f); yield return new WaitForSeconds(1.5f);
GameMain.GameSession.CrewManager.HighlightOrderButton(captain_engineer, "operatereactor", highlightColor, new Vector2(5, 5)); GameMain.GameSession.CrewManager.HighlightOrderButton(captain_engineer, "operatereactor", highlightColor, new Vector2(5, 5));
HighlightOrderOption("powerup");
} }
while (!HasOrder(captain_engineer, "operatereactor", "powerup")); while (!HasOrder(captain_engineer, "operatereactor", "powerup"));
RemoveCompletedObjective(segments[3]); RemoveCompletedObjective(segments[3]);
@@ -236,6 +239,30 @@ namespace Barotrauma.Tutorials
CoroutineManager.StartCoroutine(TutorialCompleted()); 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) private bool IsSelectedItem(Item item)
{ {
return captain?.SelectedConstruction == item; return captain?.SelectedConstruction == item;