Functional networkevent validation, functional single player saving, requireditem ui texts, titlescreen & loading
This commit is contained in:
@@ -20,6 +20,7 @@ namespace Subsurface
|
||||
private GUIFrame guiFrame;
|
||||
private GUIListBox listBox;
|
||||
|
||||
|
||||
public int Money
|
||||
{
|
||||
get { return money; }
|
||||
@@ -143,7 +144,11 @@ namespace Subsurface
|
||||
{
|
||||
foreach (Character c in characters)
|
||||
{
|
||||
if (!c.IsDead) continue;
|
||||
if (!c.IsDead)
|
||||
{
|
||||
c.Info.UpdateCharacterItems();
|
||||
continue;
|
||||
}
|
||||
|
||||
CharacterInfo deadInfo = characterInfos.Find(x => c.Info == x);
|
||||
if (deadInfo != null) characterInfos.Remove(deadInfo);
|
||||
@@ -165,7 +170,7 @@ namespace Subsurface
|
||||
element.Add(new XAttribute("money", money));
|
||||
|
||||
foreach (CharacterInfo ci in characterInfos)
|
||||
{
|
||||
{
|
||||
ci.Save(element);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,18 +31,31 @@ namespace Subsurface
|
||||
|
||||
private Level level;
|
||||
|
||||
public Map map;
|
||||
|
||||
public Level Level
|
||||
{
|
||||
get { return level; }
|
||||
}
|
||||
|
||||
public Map Map
|
||||
{
|
||||
get
|
||||
{
|
||||
SinglePlayerMode mode = (gameMode as SinglePlayerMode);
|
||||
return (mode == null) ? null : mode.map;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Submarine Submarine
|
||||
{
|
||||
get { return submarine; }
|
||||
}
|
||||
|
||||
public string SavePath
|
||||
{
|
||||
get { return savePath; }
|
||||
}
|
||||
|
||||
public GameSession(Submarine submarine, GameModePreset gameModePreset)
|
||||
:this(submarine, gameModePreset.Instantiate())
|
||||
{
|
||||
@@ -57,8 +70,6 @@ namespace Subsurface
|
||||
|
||||
guiRoot = new GUIFrame(new Rectangle(0,0,Game1.GraphicsWidth,Game1.GraphicsWidth), Color.Transparent);
|
||||
|
||||
map = new Map(Rand.Int(), 500);
|
||||
|
||||
//int width = 350, height = 100;
|
||||
//if (Game1.NetworkMember!=null)
|
||||
//{
|
||||
@@ -118,13 +129,13 @@ namespace Subsurface
|
||||
StartShift(duration, level);
|
||||
}
|
||||
|
||||
public void StartShift(TimeSpan duration, Level level)
|
||||
public void StartShift(TimeSpan duration, Level level, bool reloadSub = true)
|
||||
{
|
||||
Lights.LightManager.FowEnabled = (Game1.Server==null);
|
||||
|
||||
this.level = level;
|
||||
|
||||
if (Submarine.Loaded != submarine) submarine.Load();
|
||||
if (reloadSub || Submarine.Loaded != submarine) submarine.Load();
|
||||
|
||||
if (gameMode!=null) gameMode.Start(duration);
|
||||
|
||||
@@ -147,8 +158,6 @@ namespace Subsurface
|
||||
else if (Game1.Client==null)
|
||||
{
|
||||
Game1.LobbyScreen.Select();
|
||||
|
||||
SaveUtil.SaveGame(savePath);
|
||||
}
|
||||
|
||||
taskManager.EndShift();
|
||||
|
||||
@@ -22,9 +22,13 @@ namespace Subsurface
|
||||
// get { return day; }
|
||||
//}
|
||||
|
||||
public Map map;
|
||||
|
||||
bool crewDead;
|
||||
private float endTimer;
|
||||
|
||||
private bool savedOnStart;
|
||||
|
||||
public SinglePlayerMode(GameModePreset preset)
|
||||
: base(preset)
|
||||
{
|
||||
@@ -36,6 +40,7 @@ namespace Subsurface
|
||||
|
||||
hireManager.GenerateCharacters("Content/Characters/Human/human.xml", 10);
|
||||
|
||||
|
||||
//day = 1;
|
||||
}
|
||||
|
||||
@@ -44,6 +49,12 @@ namespace Subsurface
|
||||
{
|
||||
//day = ToolBox.GetAttributeInt(element,"day",1);
|
||||
|
||||
string mapSeed = ToolBox.GetAttributeString(element, "mapseed", "a");
|
||||
|
||||
GenerateMap(mapSeed);
|
||||
|
||||
map.SetLocation(ToolBox.GetAttributeInt(element, "currentlocation", 0));
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().ToLower() != "crew") continue;
|
||||
@@ -52,8 +63,23 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateMap(string seed)
|
||||
{
|
||||
map = new Map(seed.GetHashCode(), 500);
|
||||
}
|
||||
|
||||
public override void Start(TimeSpan duration)
|
||||
{
|
||||
if (!savedOnStart)
|
||||
{
|
||||
SaveUtil.SaveGame(Game1.GameSession.SavePath);
|
||||
savedOnStart = true;
|
||||
|
||||
|
||||
//Game1.GameSession.submarine.Load();
|
||||
}
|
||||
|
||||
|
||||
endTimer = 5.0f;
|
||||
|
||||
crewManager.StartShift();
|
||||
@@ -85,12 +111,12 @@ namespace Subsurface
|
||||
|
||||
if (Level.Loaded.AtEndPosition)
|
||||
{
|
||||
endShiftButton.Text = "Enter " + Game1.GameSession.map.SelectedLocation.Name;
|
||||
endShiftButton.Text = "Enter " + map.SelectedLocation.Name;
|
||||
endShiftButton.Draw(spriteBatch);
|
||||
}
|
||||
else if (Level.Loaded.AtStartPosition)
|
||||
{
|
||||
endShiftButton.Text = "Enter " + Game1.GameSession.map.CurrentLocation.Name;
|
||||
endShiftButton.Text = "Enter " + map.CurrentLocation.Name;
|
||||
endShiftButton.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
@@ -125,8 +151,10 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
private bool EndShift(GUIButton button, object obj)
|
||||
public override void End(string endMessage = "")
|
||||
{
|
||||
base.End(endMessage);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
List<Character> casualties = crewManager.characters.FindAll(c => c.IsDead);
|
||||
|
||||
@@ -157,9 +185,10 @@ namespace Subsurface
|
||||
|
||||
if (Level.Loaded.AtEndPosition)
|
||||
{
|
||||
Game1.GameSession.map.MoveToNextLocation();
|
||||
map.MoveToNextLocation();
|
||||
}
|
||||
|
||||
SaveUtil.SaveGame(Game1.GameSession.SavePath);
|
||||
}
|
||||
|
||||
crewManager.EndShift();
|
||||
@@ -168,16 +197,30 @@ namespace Subsurface
|
||||
Character.CharacterList[i].Remove();
|
||||
}
|
||||
|
||||
|
||||
//SaveUtil.SaveGame(Game1.GameSession.SavePath);
|
||||
|
||||
Game1.GameSession.EndShift("");
|
||||
|
||||
}
|
||||
|
||||
private bool EndShift(GUIButton button, object obj)
|
||||
{
|
||||
End("");
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Save(XElement element)
|
||||
{
|
||||
//element.Add(new XAttribute("day", day));
|
||||
XElement modeElement = new XElement("gamemode");
|
||||
|
||||
crewManager.Save(element);
|
||||
modeElement.Add(new XAttribute("currentlocation", map.CurrentLocationIndex));
|
||||
modeElement.Add(new XAttribute("mapseed", map.Seed));
|
||||
|
||||
crewManager.Save(modeElement);
|
||||
|
||||
element.Add(modeElement);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user