Round summary screen, GUIMessageBoxes disable other UI elements, renamed quests as missions

This commit is contained in:
Regalis11
2015-12-23 22:18:02 +02:00
parent c7e7b3909f
commit b2d5704f7e
22 changed files with 357 additions and 153 deletions

Binary file not shown.

View File

@@ -102,6 +102,8 @@
<Compile Include="Source\GameSession\GameModes\GameModePreset.cs" />
<Compile Include="Source\GameSession\GameModes\QuestMode.cs" />
<Compile Include="Source\GameSession\GameModes\TutorialMode.cs" />
<Compile Include="Source\GameSession\InfoTextManager.cs" />
<Compile Include="Source\GameSession\ShiftSummary.cs" />
<Compile Include="Source\GUI\GUIDropDown.cs" />
<Compile Include="Source\GUI\GUIMessage.cs" />
<Compile Include="Source\GUI\TitleScreen.cs" />
@@ -391,6 +393,9 @@
<Content Include="Content\Characters\TigerThresher\damagedtigerthresher.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\InfoTexts.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Artifacts\artifact.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -831,7 +836,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</Content>
<Content Include="Content\Quests.xml">
<Content Include="Content\Missions.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\waterbump.png">

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<infotexts>
<progress>[sub] has made its way from [location1] to [location2].</progress>
<progress>[sub] has arrived at [location2].</progress>
<return>[sub] has returned to [location1].</return>
<gameover>The ocean has claimed [sub] and its crew.</gameover>
<CauseOfDeath.Damage>Succumbed to their injuries</CauseOfDeath.Damage>
<CauseOfDeath.Bloodloss>Bled out</CauseOfDeath.Bloodloss>
<CauseOfDeath.Drowning>Drowned</CauseOfDeath.Drowning>
<CauseOfDeath.Suffocation>Suffocated</CauseOfDeath.Suffocation>
<CauseOfDeath.Pressure>Crushed by water pressure</CauseOfDeath.Pressure>
<CauseOfDeath.Burn>Burned to death</CauseOfDeath.Burn>
<Self_CauseOfDeath.Damage>You have succumbed to your injuries.</Self_CauseOfDeath.Damage>
<Self_CauseOfDeath.Bloodloss>You have bled out.</Self_CauseOfDeath.Bloodloss>
<Self_CauseOfDeath.Drowning>You have drowned.</Self_CauseOfDeath.Drowning>
<Self_CauseOfDeath.Suffocation>You have suffocated.</Self_CauseOfDeath.Suffocation>
<Self_CauseOfDeath.Pressure>You have been crushed by water pressure.</Self_CauseOfDeath.Pressure>
<Self_CauseOfDeath.Burn>You have burned to death.</Self_CauseOfDeath.Burn>
</infotexts>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<Quests>
<SalvageQuest
<Missions>
<SalvageMission
name="Salvaging an artifact"
description="Researchers of [location1] have picked up an infrasonic signal highly similar to those emitted by alien artifacts previously discovered on Europa. Investigate the signal and retrieve the potential artifact."
commonness="10"
@@ -10,9 +10,9 @@
successmessage="The artifact has been succesfully retrieved"
itemname="Skyholder Artifact">
<message header="Artifact collected" text="The artifact is now on board. Navigate the submarine out of the cavern to claim the reward."/>
</SalvageQuest>
</SalvageMission>
<SalvageQuest
<SalvageMission
name="Salvaging an artifact"
description="Researchers of [location1] have picked up an infrasonic signal highly similar to those emitted by alien artifacts previously discovered on Europa. Investigate the signal and retrieve the potential artifact."
commonness="10"
@@ -22,9 +22,9 @@
successmessage="The artifact has been succesfully retrieved"
itemname="Thermal Artifact">
<message header="Artifact collected" text="The artifact is now on board. Navigate the submarine out of the cavern to claim the reward."/>
</SalvageQuest>
</SalvageMission>
<MonsterQuest
<MonsterMission
name="Killing a Moloch"
description="A particularly aggressive Moloch has been terrorizing vessels traveling between [location1] and [location2]. A reward of 1000 credits has been promised to those who kill the creature."
commonness="10"
@@ -33,9 +33,9 @@
successmessage="The Moloch has been killed."
monsterfile="Content/Characters/Moloch/moloch.xml">
<message header="Target terminated" text="The moloch is dead. Navigate the submarine out of the cavern to claim the reward."/>
</MonsterQuest>
</MonsterMission>
<MonsterQuest
<MonsterMission
name="Killing a Tiger Thresher"
description="A particularly aggressive Tiger Thresher has been terrorizing vessels traveling between [location1] and [location2]. A reward of 800 credits has been promised to those who kill the creature."
commonness="10"
@@ -44,9 +44,9 @@
successmessage="The Tiger Thresher has been killed."
monsterfile="Content/Characters/TigerThresher/tigerthresher.xml">
<message header="Target terminated" text="The thresher is dead. Navigate the submarine out of the cavern to claim the reward."/>
</MonsterQuest>
</MonsterMission>
<MonsterQuest
<MonsterMission
name="Salvaging an artifact"
description="Researchers of [location1] have picked up an infrasonic signal highly similar to those emitted by alien artifacts previously discovered on Europa. Investigate the signal and retrieve the potential artifact."
commonness="5"
@@ -54,5 +54,5 @@
radarlabel="Infrasonic signal"
successmessage="It turns out the signal was emitted by a Moloch. The researchers of [location1] have agreed to pay you the reward nevertheless for killing the Moloch."
monsterfile="Content/Characters/Moloch/moloch.xml">
</MonsterQuest>
</Quests>
</MonsterMission>
</Missions>

View File

@@ -17,8 +17,6 @@ namespace Barotrauma
class Character : Entity, IDamageable, IPropertyObject
{
public static string[] DeathMsg = new string[Enum.GetNames(typeof(CauseOfDeath)).Length];
public static List<Character> CharacterList = new List<Character>();
public static Queue<CharacterInfo> NewCharacterQueue = new Queue<CharacterInfo>();
@@ -282,16 +280,9 @@ namespace Barotrauma
{
get { return AnimController.RefLimb.Position; }
}
static Character()
{
DeathMsg[(int)CauseOfDeath.Damage] = "succumbed to your injuries";
DeathMsg[(int)CauseOfDeath.Bloodloss] = "bled out";
DeathMsg[(int)CauseOfDeath.Drowning] = "drowned";
DeathMsg[(int)CauseOfDeath.Suffocation] = "suffocated";
DeathMsg[(int)CauseOfDeath.Pressure] = "been crushed by water pressure";
DeathMsg[(int)CauseOfDeath.Burn] = "burnt to death";
}
public delegate void OnDeathHandler(Character character, CauseOfDeath causeOfDeath);
public OnDeathHandler OnDeath;
public static Character Create(string file, Vector2 position)
{
@@ -1159,7 +1150,7 @@ namespace Barotrauma
//if the Character is controlled by this client/server, let others know that the Character has died
if (Character.controlled == this)
{
string chatMessage = "You have " + DeathMsg[(int)causeOfDeath] + ".";
string chatMessage = InfoTextManager.GetInfoText("Self_CauseOfDeath." + causeOfDeath.ToString());
if (GameMain.Client!=null) chatMessage += " Your chat messages will only be visible to other dead players.";
GameMain.NetworkMember.AddChatMessage(chatMessage, ChatMessageType.Dead);
@@ -1179,6 +1170,8 @@ namespace Barotrauma
}
}
if (OnDeath != null) OnDeath(this, causeOfDeath);
CoroutineManager.StartCoroutine(DeathAnim(GameMain.GameScreen.Cam));
health = 0.0f;

View File

@@ -1,14 +1,9 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using System.Xml.Linq;
namespace Barotrauma
{
class MonsterQuest : Quest
class MonsterMission : Mission
{
private string monsterFile;
@@ -21,7 +16,7 @@ namespace Barotrauma
get { return monster.Position; }
}
public MonsterQuest(XElement element)
public MonsterMission(XElement element)
: base(element)
{
monsterFile = ToolBox.GetAttributeString(element, "monsterfile", "");
@@ -48,12 +43,8 @@ namespace Barotrauma
public override void End()
{
if (!monster.IsDead)
{
new GUIMessageBox("Quest failed", failureMessage);
return;
}
if (!monster.IsDead) return;
GiveReward();
completed = true;

View File

@@ -3,16 +3,15 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma
{
class Quest
class Mission
{
private static List<Quest> list = new List<Quest>();
private static List<Mission> list = new List<Mission>();
private static string configFile = "Content/Quests.xml";
private static string configFile = "Content/Missions.xml";
private string name;
@@ -60,7 +59,17 @@ namespace Barotrauma
get { return Vector2.Zero; }
}
public Quest(XElement element)
public string SuccessMessage
{
get { return successMessage; }
}
public string FailureMessage
{
get { return failureMessage; }
}
public Mission(XElement element)
{
name = ToolBox.GetAttributeString(element, "name", "");
@@ -68,8 +77,10 @@ namespace Barotrauma
reward = ToolBox.GetAttributeInt(element, "reward", 1);
successMessage = ToolBox.GetAttributeString(element, "successmessage", "");
failureMessage = ToolBox.GetAttributeString(element, "failuremessage", "");
successMessage = ToolBox.GetAttributeString(element, "successmessage",
"Mission completed successfully");
failureMessage = ToolBox.GetAttributeString(element, "failuremessage",
"Mission failed");
radarLabel = ToolBox.GetAttributeString(element, "radarlabel", "");
@@ -83,7 +94,7 @@ namespace Barotrauma
}
}
public static Quest LoadRandom(Location[] locations, Random rand)
public static Mission LoadRandom(Location[] locations, Random rand)
{
XDocument doc = ToolBox.TryLoadXml(configFile);
if (doc == null) return null;
@@ -119,32 +130,32 @@ namespace Barotrauma
t = Type.GetType("Barotrauma." + type, true, true);
if (t == null)
{
DebugConsole.ThrowError("Error in " + configFile + "! Could not find a quest class of the type ''" + type + "''.");
DebugConsole.ThrowError("Error in " + configFile + "! Could not find a mission class of the type ''" + type + "''.");
continue;
}
}
catch
{
DebugConsole.ThrowError("Error in " + configFile + "! Could not find a an event class of the type ''" + type + "''.");
DebugConsole.ThrowError("Error in " + configFile + "! Could not find a mission class of the type ''" + type + "''.");
continue;
}
ConstructorInfo constructor = t.GetConstructor(new[] { typeof(XElement) });
object instance = constructor.Invoke(new object[] { element });
Quest quest = (Quest)instance;
Mission mission = (Mission)instance;
for (int n = 0; n<2; n++)
{
quest.description = quest.description.Replace("[location"+(n+1)+"]", locations[n].Name);
mission.description = mission.description.Replace("[location"+(n+1)+"]", locations[n].Name);
quest.successMessage = quest.successMessage.Replace("[location" + (n + 1) + "]", locations[n].Name);
quest.failureMessage = quest.failureMessage.Replace("[location" + (n + 1) + "]", locations[n].Name);
mission.successMessage = mission.successMessage.Replace("[location" + (n + 1) + "]", locations[n].Name);
mission.failureMessage = mission.failureMessage.Replace("[location" + (n + 1) + "]", locations[n].Name);
}
return quest;
return mission;
}
randomNumber -= eventProbability[i];
@@ -168,9 +179,8 @@ namespace Barotrauma
}
/// <summary>
/// End the quest and give a reward if it was completed successfully
/// End the mission and give a reward if it was completed successfully
/// </summary>
/// <returns>whether the quest was completed or not</returns>
public virtual void End()
{
completed = true;
@@ -180,11 +190,6 @@ namespace Barotrauma
public void GiveReward()
{
if (!string.IsNullOrWhiteSpace(successMessage))
{
new GUIMessageBox("Quest completed successfully", successMessage);
}
var mode = GameMain.GameSession.gameMode as SinglePlayerMode;
if (mode == null) return;

View File

@@ -8,7 +8,7 @@ using System.Xml.Linq;
namespace Barotrauma
{
class SalvageQuest : Quest
class SalvageMission : Mission
{
private ItemPrefab itemPrefab;
@@ -24,7 +24,7 @@ namespace Barotrauma
}
}
public SalvageQuest(XElement element)
public SalvageMission(XElement element)
: base(element)
{
string itemName = ToolBox.GetAttributeString(element, "itemname", "");
@@ -33,7 +33,7 @@ namespace Barotrauma
if (itemPrefab == null)
{
DebugConsole.ThrowError("Error in salvagequest: couldn't find an item prefab with the name "+itemName);
DebugConsole.ThrowError("Error in SalvageMission: couldn't find an item prefab with the name "+itemName);
}
}
@@ -91,11 +91,7 @@ namespace Barotrauma
public override void End()
{
item.Remove();
if (item.CurrentHull == null)
{
new GUIMessageBox("Quest failed", failureMessage);
return;
}
if (item.CurrentHull == null) return;
GiveReward();

View File

@@ -5,7 +5,7 @@ namespace Barotrauma
{
public class GUIMessageBox : GUIFrame
{
public static Queue<GUIMessageBox> MessageBoxes = new Queue<GUIMessageBox>();
public static Queue<GUIComponent> MessageBoxes = new Queue<GUIComponent>();
const int DefaultWidth=400, DefaultHeight=200;
@@ -15,15 +15,15 @@ namespace Barotrauma
//GUIFrame frame;
public GUIButton[] Buttons;
public static GUIMessageBox VisibleBox
public static GUIComponent VisibleBox
{
get { return MessageBoxes.Count==0 ? null : MessageBoxes.Peek(); }
}
public string Text
{
get { return (children[1] as GUITextBlock).Text; }
set { (children[1] as GUITextBlock).Text = value; }
get { return (children[0].children[1] as GUITextBlock).Text; }
set { (children[0].children[1] as GUITextBlock).Text = value; }
}
public GUIMessageBox(string header, string text)
@@ -39,17 +39,19 @@ namespace Barotrauma
}
public GUIMessageBox(string header, string text, string[] buttons, int width=DefaultWidth, int height=DefaultHeight, Alignment textAlignment = Alignment.TopLeft, GUIComponent parent = null)
: base(new Rectangle(0,0, width, height),
null, Alignment.Center, GUI.Style, parent)
: base(new Rectangle(0,0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
Color.Black*0.5f, Alignment.TopLeft, null, parent)
{
new GUITextBlock(new Rectangle(0, 0, 0, 30), header, Color.Transparent, Color.White, textAlignment, GUI.Style, this, true);
new GUITextBlock(new Rectangle(0, 30, 0, height - 70), text, Color.Transparent, Color.White, textAlignment, GUI.Style, this, true);
var frame = new GUIFrame(new Rectangle(0,0,width,height), null, Alignment.Center, GUI.Style, this);
new GUITextBlock(new Rectangle(0, 0, 0, 30), header, Color.Transparent, Color.White, textAlignment, GUI.Style, frame, true);
new GUITextBlock(new Rectangle(0, 30, 0, height - 70), text, Color.Transparent, Color.White, textAlignment, GUI.Style, frame, true);
int x = 0;
this.Buttons = new GUIButton[buttons.Length];
for (int i = 0; i < buttons.Length; i++)
{
this.Buttons[i] = new GUIButton(new Rectangle(x, 0, 150, 30), buttons[i], Alignment.Left | Alignment.Bottom, GUI.Style, this);
this.Buttons[i] = new GUIButton(new Rectangle(x, 0, 150, 30), buttons[i], Alignment.Left | Alignment.Bottom, GUI.Style, frame);
x += this.Buttons[i].Rect.Width + 20;
}
@@ -57,6 +59,8 @@ namespace Barotrauma
MessageBoxes.Enqueue(this);
}
public bool Close(GUIButton button, object obj)
{
if (parent != null) parent.RemoveChild(this);

View File

@@ -22,7 +22,7 @@ namespace Barotrauma
private string endMessage;
public virtual Quest Quest
public virtual Mission Mission
{
get { return null; }
}

View File

@@ -48,7 +48,7 @@ namespace Barotrauma
+ "The rest of the crew will win if they reach the end of the level or kill the traitor "
+ "before the objective is completed.";
mode = new GameModePreset("Quest", typeof(QuestMode), false);
mode = new GameModePreset("Mission", typeof(MissionMode), false);
mode.Description = "The crew must work together to complete a specific task, such as retrieving "
+ "an alien artifact or killing a creature that's terrorizing nearby outposts. The game ends "
+ "when the task is completed or everyone in the crew has died.";

View File

@@ -6,19 +6,19 @@ using System.Text;
namespace Barotrauma
{
class QuestMode : GameMode
class MissionMode : GameMode
{
Quest quest;
Mission mission;
public override Quest Quest
public override Mission Mission
{
get
{
return quest;
return mission;
}
}
public QuestMode(GameModePreset preset)
public MissionMode(GameModePreset preset)
: base(preset)
{
Location[] locations = new Location[2];
@@ -29,14 +29,14 @@ namespace Barotrauma
{
locations[i] = Location.CreateRandom(new Vector2((float)rand.NextDouble() * 10000.0f, (float)rand.NextDouble() * 10000.0f));
}
quest = Quest.LoadRandom(locations, rand);
mission = Mission.LoadRandom(locations, rand);
}
public override void Start()
{
base.Start();
new GUIMessageBox(quest.Name, quest.Description, 400, 400);
new GUIMessageBox(mission.Name, mission.Description, 400, 400);
//quest.Start(Level.Loaded);
}

View File

@@ -18,6 +18,8 @@ namespace Barotrauma
private GUIButton endShiftButton;
public readonly CargoManager CargoManager;
private ShiftSummary shiftSummary;
public Map Map;
@@ -26,11 +28,11 @@ namespace Barotrauma
private bool savedOnStart;
public override Quest Quest
public override Mission Mission
{
get
{
return Map.SelectedConnection.Quest;
return Map.SelectedConnection.Mission;
}
}
@@ -115,6 +117,8 @@ namespace Barotrauma
endTimer = 5.0f;
CrewManager.StartShift();
shiftSummary = new ShiftSummary(GameMain.GameSession);
}
public bool TryHireCharacter(HireManager hireManager, CharacterInfo characterInfo)
@@ -192,41 +196,31 @@ namespace Barotrauma
//if (endMessage != "" || this.endMessage == null) this.endMessage = endMessage;
GUIFrame summaryFrame = shiftSummary.CreateSummaryFrame();
GUIMessageBox.MessageBoxes.Enqueue(summaryFrame);
var okButton = new GUIButton(new Rectangle(0,0,100,30), "Ok", Alignment.BottomRight, GUI.Style, summaryFrame.children[0]);
okButton.OnClicked = (GUIButton button, object obj) => { GUIMessageBox.MessageBoxes.Dequeue(); return true; };
StringBuilder sb = new StringBuilder();
List<Character> casualties = CrewManager.characters.FindAll(c => c.IsDead);
if (casualties.Count == CrewManager.characters.Count)
bool success = CrewManager.characters.Any(c => !c.IsDead);
if (success)
{
sb.Append("Your entire crew has died!");
var msgBox = new GUIMessageBox("", sb.ToString(), new string[] { "Load game", "Quit" });
msgBox.Buttons[0].OnClicked += GameMain.GameSession.LoadPrevious;
msgBox.Buttons[0].OnClicked += msgBox.Close;
msgBox.Buttons[1].OnClicked = GameMain.LobbyScreen.QuitToMainMenu;
msgBox.Buttons[1].OnClicked += msgBox.Close;
}
else
{
if (casualties.Any())
{
sb.Append("Casualties: \n");
foreach (Character c in casualties)
{
sb.Append(" - " + c.Info.Name + "\n");
}
}
else
{
sb.Append("No casualties!");
}
if (Submarine.Loaded.AtEndPosition)
{
Map.MoveToNextLocation();
}
SaveUtil.SaveGame(GameMain.GameSession.SaveFile);
}
else
{
var msgBox = new GUIMessageBox("Game over", "Your entire crew has died!", new string[] { "Load game", "Quit" });
msgBox.Buttons[0].OnClicked += GameMain.GameSession.LoadPrevious;
msgBox.Buttons[0].OnClicked += msgBox.Close;
msgBox.Buttons[1].OnClicked = GameMain.LobbyScreen.QuitToMainMenu;
msgBox.Buttons[1].OnClicked += msgBox.Close;
}
CrewManager.EndShift();

View File

@@ -1,11 +1,6 @@
using System;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Text;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Barotrauma
@@ -24,11 +19,11 @@ namespace Barotrauma
public CrewManager CrewManager;
public Quest Quest
public Mission Mission
{
get
{
if (gameMode != null) return gameMode.Quest;
if (gameMode != null) return gameMode.Mission;
return null;
}
}
@@ -71,7 +66,7 @@ namespace Barotrauma
guiRoot = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsWidth), Color.Transparent);
if (gameModePreset!=null) this.gameMode = gameModePreset.Instantiate();
if (gameModePreset!=null) gameMode = gameModePreset.Instantiate();
this.submarine = submarine;
}
@@ -122,7 +117,7 @@ namespace Barotrauma
GameMain.GameScreen.BackgroundCreatureManager.SpawnSprites(80);
}
if (Quest!=null) Quest.Start(Level.Loaded);
if (Mission!=null) Mission.Start(Level.Loaded);
if (gameMode!=null) gameMode.Start();
@@ -131,7 +126,7 @@ namespace Barotrauma
public void EndShift(string endMessage)
{
if (Quest != null) Quest.End();
if (Mission != null) Mission.End();
if (GameMain.Server!=null)
{
@@ -172,7 +167,7 @@ namespace Barotrauma
guiRoot.Update(deltaTime);
if (gameMode != null) gameMode.Update(deltaTime);
if (Quest != null) Quest.Update(deltaTime);
if (Mission != null) Mission.Update(deltaTime);
}
public void Draw(SpriteBatch spriteBatch)
@@ -185,7 +180,7 @@ namespace Barotrauma
public void Save(string filePath)
{
XDocument doc = new XDocument(
new XElement((XName)"Gamesession"));
new XElement("Gamesession"));
var now = DateTime.Now;
doc.Root.Add(new XAttribute("savetime", now.Hour + ":" + now.Minute + ", " + now.ToShortDateString()));

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma
{
static class InfoTextManager
{
private static Dictionary<string, List<string>> infoTexts;
static InfoTextManager()
{
LoadInfoTexts(Path.Combine("Content", "InfoTexts.xml"));
}
private static void LoadInfoTexts(string file)
{
infoTexts = new Dictionary<string, List<string>>();
XDocument doc = ToolBox.TryLoadXml(file);
if (doc == null) return;
foreach (XElement subElement in doc.Root.Elements())
{
string infoName = subElement.Name.ToString().ToLower();
List<string> infoList = null;
if (!infoTexts.TryGetValue(infoName, out infoList))
{
infoList = new List<string>();
infoTexts.Add(infoName, infoList);
}
infoList.Add(subElement.ElementInnerText());
}
}
public static string GetInfoText(string infoName)
{
List<string> infoList = null;
if (!infoTexts.TryGetValue(infoName.ToLower(), out infoList) || !infoList.Any())
{
#if DEBUG
return "Info text ''" + infoName + "'' not found";
#else
return "";
#endif
}
string text = infoList[Rand.Int(infoList.Count)];
if (Submarine.Loaded!=null) text = text.Replace("[sub]", Submarine.Loaded.Name);
if (GameMain.GameSession != null && GameMain.GameSession.Map != null)
{
if (GameMain.GameSession.Map.CurrentLocation!=null)
text = text.Replace("[location1]", GameMain.GameSession.Map.CurrentLocation.Name);
if (GameMain.GameSession.Map.SelectedLocation!= null)
text = text.Replace("[location2]", GameMain.GameSession.Map.SelectedLocation.Name);
}
return text;
}
}
}

View File

@@ -0,0 +1,129 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma
{
class ShiftSummary
{
class Casualty
{
public readonly CharacterInfo character;
public readonly CauseOfDeath causeOfDeath;
public readonly string description;
public Casualty(CharacterInfo characterInfo, CauseOfDeath causeOfDeath, string description)
{
this.character = characterInfo;
this.causeOfDeath = causeOfDeath;
this.description = description;
}
}
private Location startLocation, endLocation;
private GameSession gameSession;
private List<Casualty> casualties;
private Mission selectedMission;
public ShiftSummary(GameSession gameSession)
{
this.gameSession = gameSession;
startLocation = gameSession.Map.CurrentLocation;
endLocation = gameSession.Map.SelectedLocation;
casualties = new List<Casualty>();
foreach (Character character in gameSession.CrewManager.characters)
{
character.OnDeath = AddCasualty;
}
selectedMission = gameSession.Mission;
}
public void AddCasualty(Character character, CauseOfDeath causeOfDeath)
{
casualties.Add(new Casualty(character.Info, causeOfDeath, ""));
}
public GUIFrame CreateSummaryFrame()
{
bool gameOver = !gameSession.CrewManager.characters.Any(c => !c.IsDead);
bool progress = Submarine.Loaded.AtEndPosition;
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.8f);
int width = 700, height = 400;
GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,width,height), null, Alignment.Center, GUI.Style, frame);
int y = 0;
string summaryText = InfoTextManager.GetInfoText(gameOver ? "gameover" :
(progress ? "progress" : "return"));
var infoText = new GUITextBlock(new Rectangle(0,y,0,50), summaryText, GUI.Style, innerFrame, true);
y += infoText.Rect.Height;
new GUITextBlock(new Rectangle(0,y,0,20), "Crew status:", GUI.Style, innerFrame, GUI.LargeFont);
y += 30;
int x = 0;
foreach (Character character in gameSession.CrewManager.characters)
{
var characterFrame = new GUIFrame(new Rectangle(x,y,170,70), character.IsDead ? Color.DarkRed*0.7f : Color.Transparent, GUI.Style, innerFrame);
characterFrame.Padding = new Vector4(5.0f,5.0f,5.0f,5.0f);
character.Info.CreateCharacterFrame(characterFrame,
character.Info.Job!=null ? (character.Info.Name + '\n'+"("+character.Info.Job.Name+")") : character.Info.Name, null);
string statusText;
var casualty = casualties.Find(c => c.character == character.Info);
if (casualty != null)
{
statusText = InfoTextManager.GetInfoText("CauseOfDeath." + casualty.causeOfDeath.ToString());
}
else
{
statusText = (character.Health / character.MaxHealth > 0.8f) ? "OK" : "Injured";
}
new GUITextBlock(new Rectangle(0,0,0,20), statusText,
GUI.Style, Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = Color.Black*0.7f;
x += characterFrame.Rect.Width + 10;
}
y += 80;
if (GameMain.GameSession.Mission != null)
{
new GUITextBlock(new Rectangle(0, y, 0, 20), "Mission: "+GameMain.GameSession.Mission.Name, GUI.Style, innerFrame, GUI.LargeFont);
y += 30;
new GUITextBlock(new Rectangle(0,y,0,30),
(GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage,
GUI.Style, innerFrame);
if (GameMain.GameSession.Mission.Completed)
{
new GUITextBlock(new Rectangle(0, y+40, 0, 30), "Reward: "+GameMain.GameSession.Mission.Reward, GUI.Style, innerFrame);
}
}
return frame;
}
}
}

View File

@@ -236,15 +236,15 @@ namespace Barotrauma.Items.Components
(GameMain.GameSession.Map == null) ? "End" : GameMain.GameSession.Map.SelectedLocation.Name,
(Level.Loaded.EndPosition), displayScale, center, (rect.Width * 0.55f));
if (GameMain.GameSession.Quest != null)
if (GameMain.GameSession.Mission != null)
{
var quest = GameMain.GameSession.Quest;
var mission = GameMain.GameSession.Mission;
if (!string.IsNullOrWhiteSpace(quest.RadarLabel))
if (!string.IsNullOrWhiteSpace(mission.RadarLabel))
{
DrawMarker(spriteBatch,
quest.RadarLabel,
quest.RadarPosition, displayScale, center, (rect.Width * 0.55f));
mission.RadarLabel,
mission.RadarPosition, displayScale, center, (rect.Width * 0.55f));
}
}

View File

@@ -402,28 +402,28 @@ namespace Barotrauma
public List<Vector2[]> CrackSegments;
private int questsCompleted;
private int missionsCompleted;
private Quest quest;
public Quest Quest
private Mission mission;
public Mission Mission
{
get
{
if (quest==null || quest.Completed)
if (mission==null || mission.Completed)
{
if (quest !=null && quest.Completed) questsCompleted++;
if (mission !=null && mission.Completed) missionsCompleted++;
int seed = (int)locations[0].MapPosition.X + (int)locations[0].MapPosition.Y * 100;
seed += (int)locations[1].MapPosition.X*10000 + (int)locations[1].MapPosition.Y * 1000000;
Random rand = new Random(seed + questsCompleted);
Random rand = new Random(seed + missionsCompleted);
if (rand.NextDouble() < 0.3f) return null;
quest = Quest.LoadRandom(locations, rand);
mission = Mission.LoadRandom(locations, rand);
}
return quest;
return mission;
}
}
@@ -444,7 +444,7 @@ namespace Barotrauma
{
locations = new Location[] { location1, location2 };
questsCompleted = 0;
missionsCompleted = 0;
}
public Location OtherLocation(Location location)

View File

@@ -618,6 +618,7 @@ namespace Barotrauma
XDocument doc = OpenDoc(filePath);
if (doc == null) return;
name = ToolBox.GetAttributeString(doc.Root, "name", name);
foreach (XElement element in doc.Root.Elements())
{

View File

@@ -230,15 +230,15 @@ namespace Barotrauma
new GUITextBlock(new Rectangle(0, 0, 250, 0), location.Name, GUI.Style, Alignment.TopLeft, Alignment.TopCenter, locationPanel, true, GUI.LargeFont);
if (GameMain.GameSession.Map.SelectedConnection != null && GameMain.GameSession.Map.SelectedConnection.Quest != null)
if (GameMain.GameSession.Map.SelectedConnection != null && GameMain.GameSession.Map.SelectedConnection.Mission != null)
{
var quest = GameMain.GameSession.Map.SelectedConnection.Quest;
var mission = GameMain.GameSession.Map.SelectedConnection.Mission;
new GUITextBlock(new Rectangle(0, 80, 0, 20), "Quest: "+quest.Name, Color.Black*0.8f, Color.White, Alignment.TopLeft, null, locationPanel);
new GUITextBlock(new Rectangle(0, 80, 0, 20), "Mission: "+mission.Name, Color.Black*0.8f, Color.White, Alignment.TopLeft, null, locationPanel);
new GUITextBlock(new Rectangle(0, 100, 0, 20), "Reward: " + quest.Reward+" credits", Color.Black * 0.8f, Color.White, Alignment.TopLeft, null, locationPanel);
new GUITextBlock(new Rectangle(0, 100, 0, 20), "Reward: " + mission.Reward+" credits", Color.Black * 0.8f, Color.White, Alignment.TopLeft, null, locationPanel);
new GUITextBlock(new Rectangle(0, 120, 0, 0), quest.Description, Color.Black * 0.8f, Color.White, Alignment.TopLeft, null, locationPanel, true);
new GUITextBlock(new Rectangle(0, 120, 0, 0), mission.Description, Color.Black * 0.8f, Color.White, Alignment.TopLeft, null, locationPanel, true);
}

View File

@@ -476,10 +476,10 @@ namespace Barotrauma
GameMain.LobbyScreen.Select();
new GUIMessageBox("Welcome to Barotrauma!", "Please note that the single player mode is very unfinished at the moment; "+
"for example, the NPCs don't have an AI yet and there are only a couple of different quests to complete. The multiplayer "+
"mode should be much more enjoyable to play at the moment, so my recommendation is to try out and get a hang of the game mechanics "+
"in the single player mode and then move on to multiplayer. Have fun!\n - Regalis, the main dev of Subsurface", 400, 350);
//new GUIMessageBox("Welcome to Barotrauma!", "Please note that the single player mode is very unfinished at the moment; "+
//"for example, the NPCs don't have an AI yet and there are only a couple of different quests to complete. The multiplayer "+
//"mode should be much more enjoyable to play at the moment, so my recommendation is to try out and get a hang of the game mechanics "+
//"in the single player mode and then move on to multiplayer. Have fun!\n - Regalis, the main dev of Subsurface", 400, 350);
return true;
}

View File

@@ -65,7 +65,7 @@ namespace Barotrauma
if (n > 0) columnX[n] += columnX[n - 1];
}
SpriteFont font = serverList.Rect.Width < 400 ? GUI.SmallFont : GUI.Font;
SpriteFont font = GUI.SmallFont; // serverList.Rect.Width < 400 ? GUI.SmallFont : GUI.Font;
new GUITextBlock(new Rectangle(middleX, 30, 0, 30), "Password", GUI.Style, menu).Font = font;