Progress on multiplayer campaign:

- Moved SaveUtils to the shared project.
- Moved the "new game"/"load game" menu logic to a separate class.
- Somewhat functional campaign UI in the server lobby (only the map view is usable atm though).
This commit is contained in:
Joonas Rikkonen
2017-08-31 18:53:37 +03:00
parent c7ae91da42
commit c1f5e3cbda
18 changed files with 856 additions and 601 deletions
@@ -15,7 +15,7 @@ namespace Barotrauma
{
get
{
SinglePlayerCampaign mode = (GameMode as SinglePlayerCampaign);
CampaignMode mode = (GameMode as CampaignMode);
return (mode == null) ? null : mode.Map;
}
}
@@ -168,32 +168,5 @@ namespace Barotrauma
if (GameMode != null) GameMode.Draw(spriteBatch);
if (infoFrame != null) infoFrame.Draw(spriteBatch);
}
public void Save(string filePath)
{
if (!(GameMode is CampaignMode))
{
throw new NotSupportedException("GameSessions can only be saved when playing in a campaign mode.");
}
XDocument doc = new XDocument(
new XElement("Gamesession"));
var now = DateTime.Now;
doc.Root.Add(new XAttribute("savetime", now.ToShortTimeString() + ", " + now.ToShortDateString()));
doc.Root.Add(new XAttribute("submarine", submarine == null ? "" : submarine.Name));
doc.Root.Add(new XAttribute("mapseed", Map.Seed));
((CampaignMode)GameMode).Save(doc.Root);
try
{
doc.Save(filePath);
}
catch
{
DebugConsole.ThrowError("Saving gamesession to \"" + filePath + "\" failed!");
}
}
}
}