Saving (wip), statuseffect refactoring, multiple character faces

This commit is contained in:
Regalis
2015-06-12 16:56:51 +03:00
parent 270efd77e0
commit 566d54197a
35 changed files with 640 additions and 268 deletions
+43 -2
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Xml.Linq;
namespace Subsurface
{
@@ -25,7 +26,7 @@ namespace Subsurface
set { money = (int)Math.Max(value, 0.0f); }
}
public CrewManager(GameSession session)
public CrewManager()
{
characters = new List<Character>();
characterInfos = new List<CharacterInfo>();
@@ -39,6 +40,19 @@ namespace Subsurface
money = 10000;
}
public CrewManager(XElement element)
: this()
{
money = ToolBox.GetAttributeInt(element, "money", 0);
foreach (XElement subElement in element.Elements())
{
if (subElement.Name.ToString().ToLower()!="character") continue;
characterInfos.Add(new CharacterInfo(subElement));
}
}
private string CreateSaveFile(string mapName)
{
string path = "Content/Data/Saves/";
@@ -89,7 +103,7 @@ namespace Subsurface
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(40,0,0,25),
name,
Color.Transparent, Color.Black,
Color.Transparent, Color.White,
Alignment.Left,
Alignment.Left,
frame);
@@ -98,6 +112,11 @@ namespace Subsurface
new GUIImage(new Rectangle(-10,-10,0,0), character.animController.limbs[0].sprite, Alignment.Left, frame);
}
public void Update(float deltaTime)
{
guiFrame.Update(deltaTime);
}
public void KillCharacter(Character killedCharacter)
{
GUIComponent characterBlock = listBox.GetChild(killedCharacter) as GUIComponent;
@@ -138,5 +157,27 @@ namespace Subsurface
{
guiFrame.Draw(spriteBatch);
}
public void Save(string filePath)
{
XDocument doc = new XDocument(
new XElement((XName)"Crew"));
doc.Root.Add(new XAttribute("money", money));
foreach (CharacterInfo ci in characterInfos)
{
ci.Save(doc.Root);
}
try
{
doc.Save(filePath);
}
catch
{
DebugConsole.ThrowError("Saving crewmanager to ''" + filePath + "'' failed!");
}
}
}
}