Saving (wip), statuseffect refactoring, multiple character faces
@@ -14,7 +14,7 @@ using Subsurface.Particles;
|
|||||||
|
|
||||||
namespace Subsurface
|
namespace Subsurface
|
||||||
{
|
{
|
||||||
class Character : Entity, IDamageable
|
class Character : Entity, IDamageable, IPropertyObject
|
||||||
{
|
{
|
||||||
public static List<Character> characterList = new List<Character>();
|
public static List<Character> characterList = new List<Character>();
|
||||||
|
|
||||||
@@ -40,12 +40,14 @@ namespace Subsurface
|
|||||||
public byte largeUpdateTimer;
|
public byte largeUpdateTimer;
|
||||||
|
|
||||||
public readonly Dictionary<string, ObjectProperty> properties;
|
public readonly Dictionary<string, ObjectProperty> properties;
|
||||||
|
public Dictionary<string, ObjectProperty> ObjectProperties
|
||||||
|
{
|
||||||
|
get { return properties; }
|
||||||
|
}
|
||||||
|
|
||||||
protected Key selectKeyHit;
|
protected Key selectKeyHit;
|
||||||
protected Key actionKeyHit;
|
protected Key actionKeyHit, actionKeyDown;
|
||||||
protected Key actionKeyDown;
|
protected Key secondaryKeyHit, secondaryKeyDown;
|
||||||
protected Key secondaryKeyHit;
|
|
||||||
protected Key secondaryKeyDown;
|
|
||||||
|
|
||||||
private Item selectedConstruction;
|
private Item selectedConstruction;
|
||||||
private Item[] selectedItems;
|
private Item[] selectedItems;
|
||||||
@@ -83,6 +85,14 @@ namespace Subsurface
|
|||||||
//which AIstate each sound is for
|
//which AIstate each sound is for
|
||||||
private AIController.AiState[] soundStates;
|
private AIController.AiState[] soundStates;
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return speciesName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Inventory Inventory
|
public Inventory Inventory
|
||||||
{
|
{
|
||||||
get { return inventory; }
|
get { return inventory; }
|
||||||
@@ -344,10 +354,10 @@ namespace Subsurface
|
|||||||
|
|
||||||
animController.FindHull();
|
animController.FindHull();
|
||||||
|
|
||||||
if (info.ID >= 0)
|
//if (info.ID >= 0)
|
||||||
{
|
//{
|
||||||
ID = info.ID;
|
// ID = info.ID;
|
||||||
}
|
//}
|
||||||
|
|
||||||
characterList.Add(this);
|
characterList.Add(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Xml.Linq;
|
using Microsoft.Xna.Framework;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Subsurface
|
namespace Subsurface
|
||||||
{
|
{
|
||||||
@@ -6,27 +7,28 @@ namespace Subsurface
|
|||||||
|
|
||||||
class CharacterInfo
|
class CharacterInfo
|
||||||
{
|
{
|
||||||
//the name of the character (e.q. Urist McEngineer)
|
|
||||||
public string name;
|
public string name;
|
||||||
|
|
||||||
public readonly string file;
|
public readonly string file;
|
||||||
|
|
||||||
public int ID;
|
public readonly int headSpriteId;
|
||||||
|
|
||||||
|
//public int ID;
|
||||||
|
|
||||||
public Gender gender;
|
public Gender gender;
|
||||||
|
|
||||||
public int salary;
|
public int salary;
|
||||||
|
|
||||||
public string GenderString()
|
//public string GenderString()
|
||||||
{
|
//{
|
||||||
return gender.ToString();
|
// return gender.ToString();
|
||||||
}
|
//}
|
||||||
|
|
||||||
public CharacterInfo(string file, string name = "", Gender gender = Gender.None)
|
public CharacterInfo(string file, string name = "", Gender gender = Gender.None)
|
||||||
{
|
{
|
||||||
this.file = file;
|
this.file = file;
|
||||||
|
|
||||||
ID = -1;
|
//ID = -1;
|
||||||
|
|
||||||
XDocument doc = ToolBox.TryLoadXml(file);
|
XDocument doc = ToolBox.TryLoadXml(file);
|
||||||
if (doc == null) return;
|
if (doc == null) return;
|
||||||
@@ -35,7 +37,7 @@ namespace Subsurface
|
|||||||
|
|
||||||
if (ToolBox.GetAttributeBool(doc.Root, "genders", false))
|
if (ToolBox.GetAttributeBool(doc.Root, "genders", false))
|
||||||
{
|
{
|
||||||
if (gender==Gender.None)
|
if (gender == Gender.None)
|
||||||
{
|
{
|
||||||
float femaleRatio = ToolBox.GetAttributeFloat(doc.Root, "femaleratio", 0.5f);
|
float femaleRatio = ToolBox.GetAttributeFloat(doc.Root, "femaleratio", 0.5f);
|
||||||
this.gender = (Game1.random.NextDouble() < femaleRatio) ? Gender.Female : Gender.Male;
|
this.gender = (Game1.random.NextDouble() < femaleRatio) ? Gender.Female : Gender.Male;
|
||||||
@@ -46,6 +48,20 @@ namespace Subsurface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 headSpriteRange = ToolBox.GetAttributeVector2(doc.Root, "headid", Vector2.Zero);
|
||||||
|
if (headSpriteRange == Vector2.Zero)
|
||||||
|
{
|
||||||
|
headSpriteRange = ToolBox.GetAttributeVector2(
|
||||||
|
doc.Root,
|
||||||
|
this.gender == Gender.Female ? "femaleheadid" : "maleheadid",
|
||||||
|
Vector2.Zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (headSpriteRange != Vector2.Zero)
|
||||||
|
{
|
||||||
|
headSpriteId = Game1.localRandom.Next((int)headSpriteRange.X, (int)headSpriteRange.Y + 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(name))
|
if (!string.IsNullOrEmpty(name))
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -69,8 +85,30 @@ namespace Subsurface
|
|||||||
this.name += ToolBox.GetRandomLine(lastNamePath);
|
this.name += ToolBox.GetRandomLine(lastNamePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharacterInfo(XElement element)
|
||||||
|
{
|
||||||
|
name = element.Name.ToString();
|
||||||
|
|
||||||
|
string genderStr = ToolBox.GetAttributeString(element, "gender", "male").ToLower();
|
||||||
|
gender = (genderStr == "male") ? Gender.Male : Gender.Female;
|
||||||
|
|
||||||
|
salary = ToolBox.GetAttributeInt(element, "salary", 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual XElement Save(XElement parentElement)
|
||||||
|
{
|
||||||
|
XElement componentElement = new XElement("character");
|
||||||
|
|
||||||
|
componentElement.Add(
|
||||||
|
new XAttribute("name", name),
|
||||||
|
new XAttribute("gender", gender == Gender.Male ? "male" : "female"),
|
||||||
|
new XAttribute("salary", salary),
|
||||||
|
new XAttribute("headspriteid", headSpriteId));
|
||||||
|
|
||||||
|
parentElement.Add(componentElement);
|
||||||
|
return componentElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using Microsoft.Xna.Framework;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Subsurface
|
namespace Subsurface
|
||||||
@@ -11,9 +12,9 @@ namespace Subsurface
|
|||||||
|
|
||||||
float timer;
|
float timer;
|
||||||
|
|
||||||
private Item item;
|
Vector2 position;
|
||||||
|
|
||||||
private Character character;
|
List<IPropertyObject> targets;
|
||||||
|
|
||||||
public float Timer
|
public float Timer
|
||||||
{
|
{
|
||||||
@@ -26,14 +27,14 @@ namespace Subsurface
|
|||||||
delay = ToolBox.GetAttributeFloat(element, "delay", 1.0f);
|
delay = ToolBox.GetAttributeFloat(element, "delay", 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(ActionType type, float deltaTime, Item item, Character character = null)
|
public override void Apply(ActionType type, float deltaTime, Vector2 position, List<IPropertyObject> targets)
|
||||||
{
|
{
|
||||||
if (this.type != type) return;
|
if (this.type != type) return;
|
||||||
|
|
||||||
this.item = item;
|
|
||||||
this.character = character;
|
|
||||||
|
|
||||||
timer = delay;
|
timer = delay;
|
||||||
|
this.position = position;
|
||||||
|
|
||||||
|
this.targets = targets;
|
||||||
|
|
||||||
list.Add(this);
|
list.Add(this);
|
||||||
}
|
}
|
||||||
@@ -44,7 +45,7 @@ namespace Subsurface
|
|||||||
|
|
||||||
if (timer > 0.0f) return;
|
if (timer > 0.0f) return;
|
||||||
|
|
||||||
base.Apply(1.0f, character, item);
|
base.Apply(1.0f, position, targets);
|
||||||
list.Remove(this);
|
list.Remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,11 @@ namespace Subsurface
|
|||||||
string spritePath = subElement.Attribute("texture").Value;
|
string spritePath = subElement.Attribute("texture").Value;
|
||||||
|
|
||||||
if (character.info!=null)
|
if (character.info!=null)
|
||||||
|
{
|
||||||
spritePath = spritePath.Replace("[GENDER]", (character.info.gender == Gender.Female) ? "f" : "");
|
spritePath = spritePath.Replace("[GENDER]", (character.info.gender == Gender.Female) ? "f" : "");
|
||||||
|
spritePath = spritePath.Replace("[HEADID]", character.info.headSpriteId.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sprite = new Sprite(subElement, "", spritePath);
|
sprite = new Sprite(subElement, "", spritePath);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ namespace Subsurface
|
|||||||
class StatusEffect
|
class StatusEffect
|
||||||
{
|
{
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum Target
|
public enum TargetType
|
||||||
{
|
{
|
||||||
This = 1, Parent = 2, Character = 4, Contained = 8, Nearby = 16, UseTarget=32
|
This = 1, Parent = 2, Character = 4, Contained = 8, Nearby = 16, UseTarget=32
|
||||||
}
|
}
|
||||||
|
|
||||||
private Target targets;
|
private TargetType targetTypes;
|
||||||
private string[] targetNames;
|
private string[] targetNames;
|
||||||
|
|
||||||
public string[] propertyNames;
|
public string[] propertyNames;
|
||||||
@@ -30,9 +30,9 @@ namespace Subsurface
|
|||||||
|
|
||||||
private Sound sound;
|
private Sound sound;
|
||||||
|
|
||||||
public Target Targets
|
public TargetType Targets
|
||||||
{
|
{
|
||||||
get { return targets; }
|
get { return targetTypes; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] TargetNames
|
public string[] TargetNames
|
||||||
@@ -92,7 +92,7 @@ namespace Subsurface
|
|||||||
string[] Flags = attribute.Value.Split(',');
|
string[] Flags = attribute.Value.Split(',');
|
||||||
foreach (string s in Flags)
|
foreach (string s in Flags)
|
||||||
{
|
{
|
||||||
targets |= (Target)Enum.Parse(typeof(Target), s, true);
|
targetTypes |= (TargetType)Enum.Parse(typeof(TargetType), s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -143,18 +143,27 @@ namespace Subsurface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public virtual void Apply(ActionType type, float deltaTime, Item item, Character character = null)
|
//public virtual void Apply(ActionType type, float deltaTime, Item item, Character character = null)
|
||||||
{
|
//{
|
||||||
if (this.type == type) Apply(deltaTime, character, item);
|
// if (this.type == type) Apply(deltaTime, character, item);
|
||||||
}
|
//}
|
||||||
|
|
||||||
public virtual void Apply(ActionType type, float deltaTime, Vector2 position, IPropertyObject target)
|
public virtual void Apply(ActionType type, float deltaTime, Vector2 position, IPropertyObject target)
|
||||||
{
|
{
|
||||||
if (!targetNames.Contains(target.Name)) return;
|
if (!targetNames.Contains(target.Name)) return;
|
||||||
if (this.type == type) Apply(deltaTime, position, target);
|
|
||||||
|
List<IPropertyObject> targets = new List<IPropertyObject>();
|
||||||
|
targets.Add(target);
|
||||||
|
|
||||||
|
if (this.type == type) Apply(deltaTime, position, targets);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Apply(float deltaTime, Vector2 position, IPropertyObject target)
|
public virtual void Apply(ActionType type, float deltaTime, Vector2 position, List<IPropertyObject> targets)
|
||||||
|
{
|
||||||
|
if (this.type == type) Apply(deltaTime, position, targets);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Apply(float deltaTime, Vector2 position, List<IPropertyObject> targets)
|
||||||
{
|
{
|
||||||
if (explosion != null) explosion.Explode(position);
|
if (explosion != null) explosion.Explode(position);
|
||||||
|
|
||||||
@@ -163,42 +172,45 @@ namespace Subsurface
|
|||||||
for (int i = 0; i < propertyNames.Count(); i++)
|
for (int i = 0; i < propertyNames.Count(); i++)
|
||||||
{
|
{
|
||||||
ObjectProperty property;
|
ObjectProperty property;
|
||||||
if (target.ObjectProperties.TryGetValue(propertyNames[i], out property))
|
foreach (IPropertyObject target in targets)
|
||||||
{
|
{
|
||||||
|
if (targetNames!=null && !targetNames.Contains(target.Name)) continue;
|
||||||
|
if (!target.ObjectProperties.TryGetValue(propertyNames[i], out property)) continue;
|
||||||
|
|
||||||
ApplyToProperty(property, propertyEffects[i], deltaTime);
|
ApplyToProperty(property, propertyEffects[i], deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Apply(float deltaTime, Character character, Item item)
|
//protected virtual void Apply(float deltaTime, Character character, Item item)
|
||||||
{
|
//{
|
||||||
if (explosion != null) explosion.Explode(item.SimPosition);
|
// if (explosion != null) explosion.Explode(item.SimPosition);
|
||||||
|
|
||||||
if (sound != null) sound.Play(1.0f, 1000.0f, item.body.FarseerBody);
|
// if (sound != null) sound.Play(1.0f, 1000.0f, item.body.FarseerBody);
|
||||||
|
|
||||||
for (int i = 0; i < propertyNames.Count(); i++)
|
// for (int i = 0; i < propertyNames.Count(); i++)
|
||||||
{
|
// {
|
||||||
ObjectProperty property;
|
// ObjectProperty property;
|
||||||
|
|
||||||
if (character!=null && character.properties.TryGetValue(propertyNames[i], out property))
|
// if (character!=null && character.properties.TryGetValue(propertyNames[i], out property))
|
||||||
{
|
// {
|
||||||
ApplyToProperty(property, propertyEffects[i], deltaTime);
|
// ApplyToProperty(property, propertyEffects[i], deltaTime);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (item == null) continue;
|
// if (item == null) continue;
|
||||||
|
|
||||||
if (item.properties.TryGetValue(propertyNames[i], out property))
|
// if (item.properties.TryGetValue(propertyNames[i], out property))
|
||||||
{
|
// {
|
||||||
ApplyToProperty(property, propertyEffects[i], deltaTime);
|
// ApplyToProperty(property, propertyEffects[i], deltaTime);
|
||||||
}
|
// }
|
||||||
|
|
||||||
foreach (ItemComponent ic in item.components)
|
// foreach (ItemComponent ic in item.components)
|
||||||
{
|
// {
|
||||||
if (!ic.properties.TryGetValue(propertyNames[i], out property)) continue;
|
// if (!ic.properties.TryGetValue(propertyNames[i], out property)) continue;
|
||||||
ApplyToProperty(property, propertyEffects[i], deltaTime);
|
// ApplyToProperty(property, propertyEffects[i], deltaTime);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
protected void ApplyToProperty(ObjectProperty property, object value, float deltaTime)
|
protected void ApplyToProperty(ObjectProperty property, object value, float deltaTime)
|
||||||
{
|
{
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<character name ="human" humanoid="true" needsair="true" genders="true" drowningtime="30">
|
<character name ="human" humanoid="true" needsair="true" genders="true" maleheadid="1,4" femaleheadid="1,2" drowningtime="30">
|
||||||
|
|
||||||
<name firstname="Content/Characters/Human/[GENDER]firstnames.txt" lastname="Content/Characters/Human/lastnames.txt" />
|
<name firstname="Content/Characters/Human/[GENDER]firstnames.txt" lastname="Content/Characters/Human/lastnames.txt" />
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<!-- head -->
|
<!-- head -->
|
||||||
<limb id = "0" radius="13" mass = "6" type="Head" attackpriority="2" impacttolerance="3.0">
|
<limb id = "0" radius="13" mass = "6" type="Head" attackpriority="2" impacttolerance="3.0">
|
||||||
<sprite texture="Content/Characters/Human/[GENDER]head.png" sourcerect="1,1,37,38" depth="0.12" origin="0.5,0.5"/>
|
<sprite texture="Content/Characters/Human/[GENDER]head[HEADID].png" sourcerect="1,1,37,38" depth="0.12" origin="0.5,0.5"/>
|
||||||
</limb>
|
</limb>
|
||||||
<!-- body -->
|
<!-- body -->
|
||||||
<limb id = "1" width="26" height="30" mass = "20" type="Torso" attackpriority="3" impacttolerance="5.0">
|
<limb id = "1" width="26" height="30" mass = "20" type="Torso" attackpriority="3" impacttolerance="5.0">
|
||||||
|
|||||||
|
After Width: | Height: | Size: 324 B |
@@ -0,0 +1,16 @@
|
|||||||
|
<Items>
|
||||||
|
<Item
|
||||||
|
name="Captain's Cap"
|
||||||
|
pickdistance="150">
|
||||||
|
|
||||||
|
<Sprite texture ="captainhat.png" depth="0.4"/>
|
||||||
|
|
||||||
|
<Body radius="8" density="5"/>
|
||||||
|
|
||||||
|
<Wearable limbtype="Head" slots="Any,Head">
|
||||||
|
<sprite texture="captainhat.png" limb="Head" origin="0.4,0.94"/>
|
||||||
|
</Wearable>
|
||||||
|
</Item>
|
||||||
|
|
||||||
|
</Items>
|
||||||
|
|
||||||
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
<Wearable limbtype="Head" slots="Any,Head">
|
<Wearable limbtype="Head" slots="Any,Head">
|
||||||
<sprite texture="DivingMask.png" limb="Head" sourcerect="1,1,37,38"/>
|
<sprite texture="DivingMask.png" limb="Head" sourcerect="1,1,37,38"/>
|
||||||
<StatusEffect type="OnWearing" target="Contained,Character" targetnames="Oxygen Tank" Condition="-0.7" Oxygen="20.0"/>
|
<StatusEffect type="OnWearing" target="Contained,Character" targetnames="Oxygen Tank,human" Condition="-0.7" Oxygen="20.0"/>
|
||||||
<StatusEffect type="OnWearing" target="Contained,Character" targetnames="Welding Fuel Tank" Condition="-0.7" Oxygen="-20.0"/>
|
<StatusEffect type="OnWearing" target="Contained,Character" targetnames="Welding Fuel Tank,human" Condition="-0.7" Oxygen="-20.0"/>
|
||||||
</Wearable>
|
</Wearable>
|
||||||
|
|
||||||
<ItemContainer capacity="1" hideitems="true">
|
<ItemContainer capacity="1" hideitems="true">
|
||||||
|
|||||||
@@ -209,12 +209,20 @@ namespace Subsurface
|
|||||||
Game1.LobbyScreen.Select();
|
Game1.LobbyScreen.Select();
|
||||||
break;
|
break;
|
||||||
case "savemap":
|
case "savemap":
|
||||||
|
if (commands.Length < 2) break;
|
||||||
Map.Loaded.SaveAs("Content/SavedMaps/" + commands[1]);
|
Map.Loaded.SaveAs("Content/SavedMaps/" + commands[1]);
|
||||||
NewMessage("map saved", Color.Green);
|
NewMessage("map saved", Color.Green);
|
||||||
break;
|
break;
|
||||||
case "loadmap":
|
case "loadmap":
|
||||||
|
if (commands.Length < 2) break;
|
||||||
Map.Load("Content/SavedMaps/" + commands[1]);
|
Map.Load("Content/SavedMaps/" + commands[1]);
|
||||||
break;
|
break;
|
||||||
|
case "savegame":
|
||||||
|
SaveUtil.SaveGame("Content/Data/test.save");
|
||||||
|
break;
|
||||||
|
case "loadgame":
|
||||||
|
SaveUtil.LoadGame("Content/Data/test.save");
|
||||||
|
break;
|
||||||
case "messagebox":
|
case "messagebox":
|
||||||
if (commands.Length < 3) break;
|
if (commands.Length < 3) break;
|
||||||
new GUIMessageBox(commands[1], commands[2]);
|
new GUIMessageBox(commands[1], commands[2]);
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ namespace Subsurface
|
|||||||
// new Vector2(10, 30), Color.White);
|
// new Vector2(10, 30), Color.White);
|
||||||
|
|
||||||
|
|
||||||
if (Character.Controlled != null) Character.Controlled.DrawHud(spriteBatch, cam);
|
if (Character.Controlled != null && cam!=null) Character.Controlled.DrawHud(spriteBatch, cam);
|
||||||
|
|
||||||
DrawMessages(spriteBatch, (float)deltaTime);
|
DrawMessages(spriteBatch, (float)deltaTime);
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ namespace Subsurface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
{
|
{
|
||||||
// TODO: Add your initialization logic here
|
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
particleManager = new ParticleManager("Content/Particles/prefabs.xml", Cam);
|
particleManager = new ParticleManager("Content/Particles/prefabs.xml", Cam);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Subsurface
|
namespace Subsurface
|
||||||
{
|
{
|
||||||
@@ -25,7 +26,7 @@ namespace Subsurface
|
|||||||
set { money = (int)Math.Max(value, 0.0f); }
|
set { money = (int)Math.Max(value, 0.0f); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public CrewManager(GameSession session)
|
public CrewManager()
|
||||||
{
|
{
|
||||||
characters = new List<Character>();
|
characters = new List<Character>();
|
||||||
characterInfos = new List<CharacterInfo>();
|
characterInfos = new List<CharacterInfo>();
|
||||||
@@ -39,6 +40,19 @@ namespace Subsurface
|
|||||||
money = 10000;
|
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)
|
private string CreateSaveFile(string mapName)
|
||||||
{
|
{
|
||||||
string path = "Content/Data/Saves/";
|
string path = "Content/Data/Saves/";
|
||||||
@@ -89,7 +103,7 @@ namespace Subsurface
|
|||||||
GUITextBlock textBlock = new GUITextBlock(
|
GUITextBlock textBlock = new GUITextBlock(
|
||||||
new Rectangle(40,0,0,25),
|
new Rectangle(40,0,0,25),
|
||||||
name,
|
name,
|
||||||
Color.Transparent, Color.Black,
|
Color.Transparent, Color.White,
|
||||||
Alignment.Left,
|
Alignment.Left,
|
||||||
Alignment.Left,
|
Alignment.Left,
|
||||||
frame);
|
frame);
|
||||||
@@ -98,6 +112,11 @@ namespace Subsurface
|
|||||||
new GUIImage(new Rectangle(-10,-10,0,0), character.animController.limbs[0].sprite, Alignment.Left, frame);
|
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)
|
public void KillCharacter(Character killedCharacter)
|
||||||
{
|
{
|
||||||
GUIComponent characterBlock = listBox.GetChild(killedCharacter) as GUIComponent;
|
GUIComponent characterBlock = listBox.GetChild(killedCharacter) as GUIComponent;
|
||||||
@@ -138,5 +157,27 @@ namespace Subsurface
|
|||||||
{
|
{
|
||||||
guiFrame.Draw(spriteBatch);
|
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!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Microsoft.Xna.Framework.Graphics;
|
|||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Subsurface
|
namespace Subsurface
|
||||||
{
|
{
|
||||||
@@ -20,6 +21,8 @@ namespace Subsurface
|
|||||||
|
|
||||||
public readonly GameMode gameMode;
|
public readonly GameMode gameMode;
|
||||||
|
|
||||||
|
private GUIFrame guiRoot;
|
||||||
|
|
||||||
private GUIListBox chatBox;
|
private GUIListBox chatBox;
|
||||||
private GUITextBox textBox;
|
private GUITextBox textBox;
|
||||||
|
|
||||||
@@ -27,44 +30,53 @@ namespace Subsurface
|
|||||||
|
|
||||||
private GUIButton endShiftButton;
|
private GUIButton endShiftButton;
|
||||||
|
|
||||||
string saveFile;
|
Map selectedMap;
|
||||||
|
|
||||||
private int day;
|
private int day;
|
||||||
|
|
||||||
public string SaveFile
|
//public string SaveFile
|
||||||
{
|
//{
|
||||||
get { return saveFile; }
|
// get { return saveFile; }
|
||||||
}
|
//}
|
||||||
|
|
||||||
public int Day
|
public int Day
|
||||||
{
|
{
|
||||||
get { return day; }
|
get { return day; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameSession(string selectedMapFile, bool save, TimeSpan gameDuration, GameMode gameMode = null)
|
public GameSession(Map selectedMap, TimeSpan gameDuration, GameMode gameMode = null)
|
||||||
{
|
{
|
||||||
taskManager = new TaskManager(this);
|
taskManager = new TaskManager(this);
|
||||||
crewManager = new CrewManager(this);
|
crewManager = new CrewManager();
|
||||||
hireManager = new HireManager();
|
hireManager = new HireManager();
|
||||||
|
|
||||||
hireManager.GenerateCharacters("Content/Characters/Human/human.xml", 10);
|
hireManager.GenerateCharacters("Content/Characters/Human/human.xml", 10);
|
||||||
|
|
||||||
|
guiRoot = new GUIFrame(new Rectangle(0,0,Game1.GraphicsWidth,Game1.GraphicsWidth), Color.Transparent);
|
||||||
|
|
||||||
int width = 350, height = 100;
|
int width = 350, height = 100;
|
||||||
chatBox = new GUIListBox(new Rectangle(
|
if (Game1.Client!=null || Game1.Server!=null)
|
||||||
Game1.GraphicsWidth - (int)GUI.style.smallPadding.X - width,
|
{
|
||||||
Game1.GraphicsHeight - (int)GUI.style.smallPadding.W*2 - 25 - height,
|
chatBox = new GUIListBox(new Rectangle(
|
||||||
width, height),
|
Game1.GraphicsWidth - (int)GUI.style.smallPadding.X - width,
|
||||||
Color.White * 0.5f);
|
Game1.GraphicsHeight - (int)GUI.style.smallPadding.W*2 - 25 - height,
|
||||||
|
width, height),
|
||||||
|
Color.White * 0.5f, guiRoot);
|
||||||
|
|
||||||
endShiftButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 240, 20, 100, 25), "End shift", Color.White, Alignment.CenterX, null);
|
textBox = new GUITextBox(
|
||||||
endShiftButton.OnClicked = EndShift;
|
new Rectangle(chatBox.Rect.X, chatBox.Rect.Y + chatBox.Rect.Height + (int)GUI.style.smallPadding.W, chatBox.Rect.Width, 25),
|
||||||
|
Color.White * 0.5f, Color.Black, Alignment.Bottom, Alignment.Left, guiRoot);
|
||||||
|
textBox.OnEnter = EnterChatMessage;
|
||||||
|
}
|
||||||
|
|
||||||
timerBar = new GUIProgressBar(new Rectangle(Game1.GraphicsWidth - 120, 20, 100, 25), Color.Gold, 0.0f, null);
|
if (Game1.Client==null)
|
||||||
|
{
|
||||||
|
endShiftButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 240, 20, 100, 25), "End shift", Color.White, Alignment.Left | Alignment.Top, guiRoot);
|
||||||
|
endShiftButton.OnClicked = EndShift;
|
||||||
|
}
|
||||||
|
|
||||||
|
timerBar = new GUIProgressBar(new Rectangle(Game1.GraphicsWidth - 120, 20, 100, 25), Color.Gold, 0.0f, guiRoot);
|
||||||
|
|
||||||
textBox = new GUITextBox(
|
|
||||||
new Rectangle(chatBox.Rect.X, chatBox.Rect.Y + chatBox.Rect.Height + (int)GUI.style.smallPadding.W, chatBox.Rect.Width, 25),
|
|
||||||
Color.White * 0.5f, Color.Black, Alignment.Bottom, Alignment.Left);
|
|
||||||
textBox.OnEnter = EnterChatMessage;
|
|
||||||
|
|
||||||
this.gameMode = gameMode;
|
this.gameMode = gameMode;
|
||||||
if (this.gameMode != null) this.gameMode.Start(Game1.NetLobbyScreen.GameDuration);
|
if (this.gameMode != null) this.gameMode.Start(Game1.NetLobbyScreen.GameDuration);
|
||||||
@@ -72,12 +84,22 @@ namespace Subsurface
|
|||||||
startTime = DateTime.Now;
|
startTime = DateTime.Now;
|
||||||
endTime = startTime + gameDuration;
|
endTime = startTime + gameDuration;
|
||||||
|
|
||||||
if (!save) return;
|
this.selectedMap = selectedMap;
|
||||||
|
|
||||||
CreateSaveFile(selectedMapFile);
|
//if (!save) return;
|
||||||
|
|
||||||
|
//CreateSaveFile(selectedMapFile);
|
||||||
|
|
||||||
day = 1;
|
day = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameSession(string filePath)
|
||||||
|
: this(null, new TimeSpan(0,0,0,0))
|
||||||
|
{
|
||||||
|
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||||
|
if (doc == null) return;
|
||||||
|
|
||||||
|
day = ToolBox.GetAttributeInt(doc.Root,"day",1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryHireCharacter(CharacterInfo characterInfo)
|
public bool TryHireCharacter(CharacterInfo characterInfo)
|
||||||
@@ -101,6 +123,8 @@ namespace Subsurface
|
|||||||
{
|
{
|
||||||
if (crewManager.characterInfos.Count == 0) return;
|
if (crewManager.characterInfos.Count == 0) return;
|
||||||
|
|
||||||
|
if (Map.Loaded!=selectedMap) selectedMap.Load();
|
||||||
|
|
||||||
crewManager.StartShift();
|
crewManager.StartShift();
|
||||||
taskManager.StartShift(scriptedEventCount);
|
taskManager.StartShift(scriptedEventCount);
|
||||||
}
|
}
|
||||||
@@ -135,9 +159,9 @@ namespace Subsurface
|
|||||||
new GUIMessageBox("Day #" + day + " is over!\n", sb.ToString());
|
new GUIMessageBox("Day #" + day + " is over!\n", sb.ToString());
|
||||||
|
|
||||||
|
|
||||||
if (saveFile == null) return false;
|
//if (saveFile == null) return false;
|
||||||
|
|
||||||
Map.Loaded.SaveAs(saveFile);
|
//Map.Loaded.SaveAs(saveFile);
|
||||||
|
|
||||||
crewManager.EndShift();
|
crewManager.EndShift();
|
||||||
|
|
||||||
@@ -146,6 +170,11 @@ namespace Subsurface
|
|||||||
day++;
|
day++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = Character.characterList.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
Character.characterList.RemoveAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
taskManager.EndShift();
|
taskManager.EndShift();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -153,33 +182,33 @@ namespace Subsurface
|
|||||||
|
|
||||||
private void CreateSaveFile(string mapName)
|
private void CreateSaveFile(string mapName)
|
||||||
{
|
{
|
||||||
string path = "Content/Data/Saves/";
|
//string path = "Content/Data/Saves/";
|
||||||
|
|
||||||
if (!Directory.Exists(path))
|
//if (!Directory.Exists(path))
|
||||||
{
|
//{
|
||||||
Directory.CreateDirectory(path);
|
// Directory.CreateDirectory(path);
|
||||||
}
|
//}
|
||||||
|
|
||||||
string name = Path.GetFileNameWithoutExtension(mapName);
|
//string name = Path.GetFileNameWithoutExtension(mapName);
|
||||||
string extension = Path.GetExtension(mapName);
|
//string extension = Path.GetExtension(mapName);
|
||||||
|
|
||||||
int i = 0;
|
//int i = 0;
|
||||||
while (File.Exists(path + name + i + extension))
|
//while (File.Exists(path + name + i + extension))
|
||||||
{
|
//{
|
||||||
i++;
|
// i++;
|
||||||
}
|
//}
|
||||||
|
|
||||||
saveFile = path + name + i+extension;
|
//saveFile = path + name + i+extension;
|
||||||
|
|
||||||
|
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
File.Copy(mapName, saveFile);
|
// File.Copy(mapName, saveFile);
|
||||||
}
|
//}
|
||||||
catch (Exception e)
|
//catch (Exception e)
|
||||||
{
|
//{
|
||||||
DebugConsole.ThrowError("Copying map file ''" + mapName + "'' to ''" + saveFile + "'' failed", e);
|
// DebugConsole.ThrowError("Copying map file ''" + mapName + "'' to ''" + saveFile + "'' failed", e);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool EnterChatMessage(GUITextBox textBox, string message)
|
public bool EnterChatMessage(GUITextBox textBox, string message)
|
||||||
@@ -218,11 +247,14 @@ namespace Subsurface
|
|||||||
public void Update(float deltaTime)
|
public void Update(float deltaTime)
|
||||||
{
|
{
|
||||||
taskManager.Update(deltaTime);
|
taskManager.Update(deltaTime);
|
||||||
endShiftButton.Enabled = !taskManager.CriticalTasks;
|
if (endShiftButton!=null) endShiftButton.Enabled = !taskManager.CriticalTasks;
|
||||||
|
|
||||||
endShiftButton.Update(deltaTime);
|
|
||||||
|
|
||||||
textBox.Update(deltaTime);
|
guiRoot.Update(deltaTime);
|
||||||
|
crewManager.Update(deltaTime);
|
||||||
|
//endShiftButton.Update(deltaTime);
|
||||||
|
|
||||||
|
//textBox.Update(deltaTime);
|
||||||
|
|
||||||
if (gameMode != null) gameMode.Update();
|
if (gameMode != null) gameMode.Update();
|
||||||
|
|
||||||
@@ -246,15 +278,33 @@ namespace Subsurface
|
|||||||
|
|
||||||
public void Draw(SpriteBatch spriteBatch)
|
public void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
|
guiRoot.Draw(spriteBatch);
|
||||||
crewManager.Draw(spriteBatch);
|
crewManager.Draw(spriteBatch);
|
||||||
taskManager.Draw(spriteBatch);
|
taskManager.Draw(spriteBatch);
|
||||||
|
|
||||||
chatBox.Draw(spriteBatch);
|
//chatBox.Draw(spriteBatch);
|
||||||
textBox.Draw(spriteBatch);
|
//textBox.Draw(spriteBatch);
|
||||||
|
|
||||||
timerBar.Draw(spriteBatch);
|
//timerBar.Draw(spriteBatch);
|
||||||
|
|
||||||
if (Game1.Client == null) endShiftButton.Draw(spriteBatch);
|
//if (Game1.Client == null) endShiftButton.Draw(spriteBatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Save(string filePath)
|
||||||
|
{
|
||||||
|
XDocument doc = new XDocument(
|
||||||
|
new XElement((XName)"Gamesession"));
|
||||||
|
|
||||||
|
doc.Root.Add(new XAttribute("day", day));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
doc.Save(filePath);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Saving gamesession to ''" + filePath + "'' failed!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,47 +115,13 @@ namespace Subsurface.Items.Components
|
|||||||
|
|
||||||
foreach (StatusEffect effect in ri.statusEffects)
|
foreach (StatusEffect effect in ri.statusEffects)
|
||||||
{
|
{
|
||||||
if (effect.Targets.HasFlag(StatusEffect.Target.This)) effect.Apply(ActionType.OnContaining, deltaTime, item);
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.This)) effect.Apply(ActionType.OnContaining, deltaTime, item.SimPosition, item.AllPropertyObjects);
|
||||||
if (effect.Targets.HasFlag(StatusEffect.Target.Contained)) effect.Apply(ActionType.OnContaining, deltaTime, contained);
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.Contained)) effect.Apply(ActionType.OnContaining, deltaTime, item.SimPosition, contained.AllPropertyObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
contained.ApplyStatusEffects(ActionType.OnContained, deltaTime);
|
contained.ApplyStatusEffects(ActionType.OnContained, deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (hideItems) return;
|
|
||||||
|
|
||||||
//Vector2 transformedItemPos;
|
|
||||||
//Vector2 transformedItemInterval = itemInterval;
|
|
||||||
////float transformedItemRotation = itemRotation;
|
|
||||||
//if (item.body==null)
|
|
||||||
//{
|
|
||||||
// transformedItemPos = new Vector2(item.Rect.X, item.Rect.Y);
|
|
||||||
// transformedItemPos = ConvertUnits.ToSimUnits(transformedItemPos) + itemPos;
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// Matrix transform = Matrix.CreateRotationZ(item.body.Rotation);
|
|
||||||
|
|
||||||
// transformedItemPos = item.body.Position + Vector2.Transform(itemPos, transform);
|
|
||||||
// transformedItemInterval = Vector2.Transform(transformedItemInterval, transform);
|
|
||||||
// //transformedItemRotation += item.body.Rotation;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//foreach (Item containedItem in inventory.items)
|
|
||||||
//{
|
|
||||||
// if (containedItem == null) continue;
|
|
||||||
|
|
||||||
// Vector2 itemDist = (transformedItemPos - containedItem.body.Position);
|
|
||||||
// Vector2 force = (itemDist - containedItem.body.LinearVelocity * 0.1f) * containedItem.body.Mass * 60.0f;
|
|
||||||
|
|
||||||
// containedItem.body.ApplyForce(force);
|
|
||||||
|
|
||||||
// containedItem.body.SmoothRotate(itemRotation);
|
|
||||||
|
|
||||||
// transformedItemPos += transformedItemInterval;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(SpriteBatch spriteBatch)
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
|
|||||||
@@ -233,9 +233,12 @@ namespace Subsurface.Items.Components
|
|||||||
|
|
||||||
public override void Update(float deltaTime, Camera cam)
|
public override void Update(float deltaTime, Camera cam)
|
||||||
{
|
{
|
||||||
OpenState += deltaTime * ((isOpen) ? 3.0f : -3.0f);
|
if (!isStuck)
|
||||||
|
{
|
||||||
|
OpenState += deltaTime * ((isOpen) ? 3.0f : -3.0f);
|
||||||
|
LinkedGap.Open = openState;
|
||||||
|
}
|
||||||
|
|
||||||
LinkedGap.Open = openState;
|
|
||||||
|
|
||||||
item.SendSignal((isOpen) ? "1" : "0", "state_out");
|
item.SendSignal((isOpen) ? "1" : "0", "state_out");
|
||||||
}
|
}
|
||||||
@@ -309,8 +312,6 @@ namespace Subsurface.Items.Components
|
|||||||
|
|
||||||
public override void ReceiveSignal(string signal, Connection connection, Item sender)
|
public override void ReceiveSignal(string signal, Connection connection, Item sender)
|
||||||
{
|
{
|
||||||
if (isStuck) return;
|
|
||||||
|
|
||||||
if (connection.name=="toggle")
|
if (connection.name=="toggle")
|
||||||
{
|
{
|
||||||
isOpen = !isOpen;
|
isOpen = !isOpen;
|
||||||
|
|||||||
@@ -291,7 +291,13 @@ namespace Subsurface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Remove() { }
|
public virtual void Remove()
|
||||||
|
{
|
||||||
|
if (loopingSound!=null)
|
||||||
|
{
|
||||||
|
Sounds.SoundManager.Stop(loopingSoundIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool HasRequiredContainedItems(bool addMessage)
|
public bool HasRequiredContainedItems(bool addMessage)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -147,8 +147,8 @@ namespace Subsurface.Items.Components
|
|||||||
|
|
||||||
foreach (StatusEffect effect in statusEffects)
|
foreach (StatusEffect effect in statusEffects)
|
||||||
{
|
{
|
||||||
if (Array.IndexOf(effect.TargetNames, targetItem.Name) == -1) continue;
|
//if (Array.IndexOf(effect.TargetNames, targetItem.Name) == -1) continue;
|
||||||
effect.Apply(ActionType.OnUse, deltaTime, targetItem);
|
effect.Apply(ActionType.OnUse, deltaTime, item.SimPosition, targetItem.AllPropertyObjects);
|
||||||
//targetItem.ApplyStatusEffect(effect, ActionType.OnUse, deltaTime);
|
//targetItem.ApplyStatusEffect(effect, ActionType.OnUse, deltaTime);
|
||||||
}
|
}
|
||||||
//ApplyStatusEffects(ActionType.OnUse, 1.0f, null, targ);
|
//ApplyStatusEffects(ActionType.OnUse, 1.0f, null, targ);
|
||||||
|
|||||||
@@ -115,22 +115,14 @@ namespace Subsurface.Items.Components
|
|||||||
|
|
||||||
Item[] containedItems = item.ContainedItems;
|
Item[] containedItems = item.ContainedItems;
|
||||||
|
|
||||||
|
ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
|
||||||
|
|
||||||
for (int i = 0; i < limb.Length; i++)
|
if (containedItems == null) return;
|
||||||
|
for (int j = 0; j<containedItems.Length; j++)
|
||||||
{
|
{
|
||||||
if (limb[i] == null) continue;
|
if (containedItems[j] == null) continue;
|
||||||
ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
|
containedItems[j].ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
|
||||||
|
|
||||||
if (containedItems == null) continue;
|
|
||||||
for (int j = 0; j<containedItems.Length; j++)
|
|
||||||
{
|
|
||||||
if (containedItems[j] == null) continue;
|
|
||||||
containedItems[j].ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,6 +144,20 @@ namespace Subsurface
|
|||||||
get { return prefab.IsLinkable; }
|
get { return prefab.IsLinkable; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<IPropertyObject> AllPropertyObjects
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<IPropertyObject> pobjects = new List<IPropertyObject>();
|
||||||
|
pobjects.Add(this);
|
||||||
|
foreach (ItemComponent ic in components)
|
||||||
|
{
|
||||||
|
pobjects.Add(ic);
|
||||||
|
}
|
||||||
|
return pobjects;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<string> highlightText;
|
List<string> highlightText;
|
||||||
|
|
||||||
public List<string> HighlightText
|
public List<string> HighlightText
|
||||||
@@ -334,9 +348,11 @@ namespace Subsurface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<IPropertyObject> targets = new List<IPropertyObject>();
|
||||||
|
|
||||||
if (containedItems!=null)
|
if (containedItems!=null)
|
||||||
{
|
{
|
||||||
if (effect.Targets.HasFlag(StatusEffect.Target.Contained))
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.Contained))
|
||||||
{
|
{
|
||||||
foreach (Item containedItem in containedItems)
|
foreach (Item containedItem in containedItems)
|
||||||
{
|
{
|
||||||
@@ -344,7 +360,8 @@ namespace Subsurface
|
|||||||
if (effect.TargetNames != null && !effect.TargetNames.Contains(containedItem.Name)) continue;
|
if (effect.TargetNames != null && !effect.TargetNames.Contains(containedItem.Name)) continue;
|
||||||
|
|
||||||
hasTargets = true;
|
hasTargets = true;
|
||||||
effect.Apply(type, deltaTime, containedItem);
|
targets.Add(containedItem);
|
||||||
|
//effect.Apply(type, deltaTime, containedItem);
|
||||||
//containedItem.ApplyStatusEffect(effect, type, deltaTime, containedItem);
|
//containedItem.ApplyStatusEffect(effect, type, deltaTime, containedItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,19 +370,27 @@ namespace Subsurface
|
|||||||
|
|
||||||
if (hasTargets)
|
if (hasTargets)
|
||||||
{
|
{
|
||||||
if (effect.Targets.HasFlag(StatusEffect.Target.This))
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.This))
|
||||||
effect.Apply(type, deltaTime, this);
|
{
|
||||||
|
foreach (var pobject in AllPropertyObjects)
|
||||||
|
{
|
||||||
|
targets.Add(pobject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//effect.Apply(type, deltaTime, this);
|
||||||
//ApplyStatusEffect(effect, type, deltaTime, this);
|
//ApplyStatusEffect(effect, type, deltaTime, this);
|
||||||
|
|
||||||
if (effect.Targets.HasFlag(StatusEffect.Target.Character))
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.Character)) targets.Add(character);
|
||||||
effect.Apply(type, deltaTime, null, character);
|
//effect.Apply(type, deltaTime, null, character);
|
||||||
//ApplyStatusEffect(effect, type, deltaTime, null, character, limb);
|
//ApplyStatusEffect(effect, type, deltaTime, null, character, limb);
|
||||||
|
|
||||||
if (container != null && effect.Targets.HasFlag(StatusEffect.Target.Parent))
|
if (container != null && effect.Targets.HasFlag(StatusEffect.TargetType.Parent)) targets.Add(container);
|
||||||
{
|
//{
|
||||||
effect.Apply(type, deltaTime, container);
|
// effect.Apply(type, deltaTime, container);
|
||||||
//container.ApplyStatusEffect(effect, type, deltaTime, container);
|
// //container.ApplyStatusEffect(effect, type, deltaTime, container);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
effect.Apply(type, deltaTime, SimPosition, targets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ namespace Subsurface
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (mapHash != null) return mapHash;
|
||||||
|
|
||||||
XDocument doc = OpenDoc(filePath);
|
XDocument doc = OpenDoc(filePath);
|
||||||
mapHash = new MapHash(doc);
|
mapHash = new MapHash(doc);
|
||||||
|
|
||||||
@@ -286,8 +288,7 @@ namespace Subsurface
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//string docString = doc.ToString();
|
SaveUtil.CompressStringToFile(filePath, doc.ToString());
|
||||||
ToolBox.CompressStringToFile(filePath, doc.ToString());
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -388,7 +389,7 @@ namespace Subsurface
|
|||||||
|
|
||||||
if (extension == ".gz")
|
if (extension == ".gz")
|
||||||
{
|
{
|
||||||
Stream stream = ToolBox.DecompressFiletoStream(file);
|
Stream stream = SaveUtil.DecompressFiletoStream(file);
|
||||||
if (stream == null)
|
if (stream == null)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Loading map ''" + file + "'' failed!");
|
DebugConsole.ThrowError("Loading map ''" + file + "'' failed!");
|
||||||
@@ -504,7 +505,7 @@ namespace Subsurface
|
|||||||
|
|
||||||
public static void Unload()
|
public static void Unload()
|
||||||
{
|
{
|
||||||
if (loaded==null)return;
|
if (loaded == null) return;
|
||||||
loaded.Clear();
|
loaded.Clear();
|
||||||
loaded = null;
|
loaded = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ namespace Subsurface.Networking
|
|||||||
TimeSpan duration = new TimeSpan(0,(int)durationMinutes,0);
|
TimeSpan duration = new TimeSpan(0,(int)durationMinutes,0);
|
||||||
|
|
||||||
//int gameModeIndex = inc.ReadInt32();
|
//int gameModeIndex = inc.ReadInt32();
|
||||||
Game1.GameSession = new GameSession("", false, duration);
|
Game1.GameSession = new GameSession(Map.Loaded, duration);
|
||||||
Game1.GameSession.StartShift(1);
|
Game1.GameSession.StartShift(1);
|
||||||
|
|
||||||
myCharacter = ReadCharacterData(inc);
|
myCharacter = ReadCharacterData(inc);
|
||||||
|
|||||||
@@ -273,9 +273,9 @@ namespace Subsurface.Networking
|
|||||||
|
|
||||||
Map selectedMap = Game1.NetLobbyScreen.SelectedMap as Map;
|
Map selectedMap = Game1.NetLobbyScreen.SelectedMap as Map;
|
||||||
|
|
||||||
selectedMap.Load();
|
//selectedMap.Load();
|
||||||
|
|
||||||
Game1.GameSession = new GameSession("", false, Game1.NetLobbyScreen.GameDuration, Game1.NetLobbyScreen.SelectedMode);
|
Game1.GameSession = new GameSession(selectedMap, Game1.NetLobbyScreen.GameDuration, Game1.NetLobbyScreen.SelectedMode);
|
||||||
Game1.GameSession.StartShift(1);
|
Game1.GameSession.StartShift(1);
|
||||||
//EventManager.SelectEvent(Game1.netLobbyScreen.SelectedEvent);
|
//EventManager.SelectEvent(Game1.netLobbyScreen.SelectedEvent);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,181 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Subsurface
|
||||||
|
{
|
||||||
|
class SaveUtil
|
||||||
|
{
|
||||||
|
public delegate void ProgressDelegate(string sMessage);
|
||||||
|
|
||||||
|
public static void SaveGame(string directory)
|
||||||
|
{
|
||||||
|
if (Directory.Exists(directory))
|
||||||
|
{
|
||||||
|
Directory.Delete(directory, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Directory.CreateDirectory(directory);
|
||||||
|
|
||||||
|
Map.Loaded.SaveAs(directory+"\\map.gz");
|
||||||
|
|
||||||
|
Game1.GameSession.crewManager.Save(directory+"\\crew.xml");
|
||||||
|
|
||||||
|
CompressDirectory(directory, directory+".save", null);
|
||||||
|
|
||||||
|
Directory.Delete(directory, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LoadGame(string filePath)
|
||||||
|
{
|
||||||
|
DecompressToDirectory(filePath+".save", Path.GetDirectoryName(filePath)+"\\temp", null);
|
||||||
|
|
||||||
|
Map.Load(Path.GetDirectoryName(filePath) + "\\temp\\map.gz");
|
||||||
|
Game1.GameSession = new GameSession(Path.GetDirectoryName(filePath) + "\\temp\\map.gz");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string CreateSavePath(string saveFolder, string fileName="save")
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(saveFolder))
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Save folder ''"+saveFolder+"'' not found. Created new folder");
|
||||||
|
Directory.CreateDirectory(saveFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
string extension = ".save";
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while (File.Exists(saveFolder + fileName + i + extension))
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return saveFolder + fileName + i + extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CompressStringToFile(string fileName, string value)
|
||||||
|
{
|
||||||
|
// A.
|
||||||
|
// Write string to temporary file.
|
||||||
|
string temp = Path.GetTempFileName();
|
||||||
|
File.WriteAllText(temp, value);
|
||||||
|
|
||||||
|
// B.
|
||||||
|
// Read file into byte array buffer.
|
||||||
|
byte[] b;
|
||||||
|
using (FileStream f = new FileStream(temp, FileMode.Open))
|
||||||
|
{
|
||||||
|
b = new byte[f.Length];
|
||||||
|
f.Read(b, 0, (int)f.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// C.
|
||||||
|
// Use GZipStream to write compressed bytes to target file.
|
||||||
|
using (FileStream f2 = new FileStream(fileName, FileMode.Create))
|
||||||
|
using (GZipStream gz = new GZipStream(f2, CompressionMode.Compress, false))
|
||||||
|
{
|
||||||
|
gz.Write(b, 0, b.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Stream DecompressFiletoStream(string fileName)
|
||||||
|
{
|
||||||
|
if (!File.Exists(fileName))
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("File ''"+fileName+" doesn't exist!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (FileStream originalFileStream = new FileStream(fileName, FileMode.Open))
|
||||||
|
{
|
||||||
|
MemoryStream decompressedFileStream = new MemoryStream();
|
||||||
|
|
||||||
|
using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress))
|
||||||
|
{
|
||||||
|
decompressionStream.CopyTo(decompressedFileStream);
|
||||||
|
return decompressedFileStream;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CompressFile(string sDir, string sRelativePath, GZipStream zipStream)
|
||||||
|
{
|
||||||
|
//Compress file name
|
||||||
|
char[] chars = sRelativePath.ToCharArray();
|
||||||
|
zipStream.Write(BitConverter.GetBytes(chars.Length), 0, sizeof(int));
|
||||||
|
foreach (char c in chars)
|
||||||
|
zipStream.Write(BitConverter.GetBytes(c), 0, sizeof(char));
|
||||||
|
|
||||||
|
//Compress file content
|
||||||
|
byte[] bytes = File.ReadAllBytes(Path.Combine(sDir, sRelativePath));
|
||||||
|
zipStream.Write(BitConverter.GetBytes(bytes.Length), 0, sizeof(int));
|
||||||
|
zipStream.Write(bytes, 0, bytes.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool DecompressFile(string sDir, GZipStream zipStream, ProgressDelegate progress)
|
||||||
|
{
|
||||||
|
//Decompress file name
|
||||||
|
byte[] bytes = new byte[sizeof(int)];
|
||||||
|
int Readed = zipStream.Read(bytes, 0, sizeof(int));
|
||||||
|
if (Readed < sizeof(int))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int iNameLen = BitConverter.ToInt32(bytes, 0);
|
||||||
|
bytes = new byte[sizeof(char)];
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < iNameLen; i++)
|
||||||
|
{
|
||||||
|
zipStream.Read(bytes, 0, sizeof(char));
|
||||||
|
char c = BitConverter.ToChar(bytes, 0);
|
||||||
|
sb.Append(c);
|
||||||
|
}
|
||||||
|
string sFileName = sb.ToString();
|
||||||
|
if (progress != null)
|
||||||
|
progress(sFileName);
|
||||||
|
|
||||||
|
//Decompress file content
|
||||||
|
bytes = new byte[sizeof(int)];
|
||||||
|
zipStream.Read(bytes, 0, sizeof(int));
|
||||||
|
int iFileLen = BitConverter.ToInt32(bytes, 0);
|
||||||
|
|
||||||
|
bytes = new byte[iFileLen];
|
||||||
|
zipStream.Read(bytes, 0, bytes.Length);
|
||||||
|
|
||||||
|
string sFilePath = Path.Combine(sDir, sFileName);
|
||||||
|
string sFinalDir = Path.GetDirectoryName(sFilePath);
|
||||||
|
if (!Directory.Exists(sFinalDir))
|
||||||
|
Directory.CreateDirectory(sFinalDir);
|
||||||
|
|
||||||
|
using (FileStream outFile = new FileStream(sFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||||
|
outFile.Write(bytes, 0, iFileLen);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CompressDirectory(string sInDir, string sOutFile, ProgressDelegate progress)
|
||||||
|
{
|
||||||
|
string[] sFiles = Directory.GetFiles(sInDir, "*.*", SearchOption.AllDirectories);
|
||||||
|
int iDirLen = sInDir[sInDir.Length - 1] == Path.DirectorySeparatorChar ? sInDir.Length : sInDir.Length + 1;
|
||||||
|
|
||||||
|
using (FileStream outFile = new FileStream(sOutFile, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||||
|
using (GZipStream str = new GZipStream(outFile, CompressionMode.Compress))
|
||||||
|
foreach (string sFilePath in sFiles)
|
||||||
|
{
|
||||||
|
string sRelativePath = sFilePath.Substring(iDirLen);
|
||||||
|
if (progress != null)
|
||||||
|
progress(sRelativePath);
|
||||||
|
CompressFile(sInDir, sRelativePath, str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DecompressToDirectory(string sCompressedFile, string sDir, ProgressDelegate progress)
|
||||||
|
{
|
||||||
|
using (FileStream inFile = new FileStream(sCompressedFile, FileMode.Open, FileAccess.Read, FileShare.None))
|
||||||
|
using (GZipStream zipStream = new GZipStream(inFile, CompressionMode.Decompress, true))
|
||||||
|
while (DecompressFile(sDir, zipStream, progress)) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -96,7 +96,7 @@ namespace Subsurface
|
|||||||
{
|
{
|
||||||
base.Select();
|
base.Select();
|
||||||
|
|
||||||
Map.Unload();
|
//Map.Unload();
|
||||||
|
|
||||||
UpdateCharacterLists();
|
UpdateCharacterLists();
|
||||||
|
|
||||||
@@ -222,7 +222,8 @@ namespace Subsurface
|
|||||||
|
|
||||||
private bool StartShift(GUIButton button, object selection)
|
private bool StartShift(GUIButton button, object selection)
|
||||||
{
|
{
|
||||||
Map.Load(Game1.GameSession.SaveFile);
|
|
||||||
|
//Map.Load(Game1.GameSession.SaveFile);
|
||||||
|
|
||||||
Game1.GameSession.StartShift();
|
Game1.GameSession.StartShift();
|
||||||
|
|
||||||
|
|||||||
@@ -55,23 +55,20 @@ namespace Subsurface
|
|||||||
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected map:", Color.Transparent, Color.Black, Alignment.Left, menuTabs[(int)Tabs.NewGame]);
|
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected map:", Color.Transparent, Color.Black, Alignment.Left, menuTabs[(int)Tabs.NewGame]);
|
||||||
mapList = new GUIListBox(new Rectangle(0, 60, 200, 400), Color.White, menuTabs[1]);
|
mapList = new GUIListBox(new Rectangle(0, 60, 200, 400), Color.White, menuTabs[1]);
|
||||||
|
|
||||||
//string[] mapFilePaths = Map.GetMapFilePaths();
|
foreach (Map map in Map.SavedMaps)
|
||||||
//if (mapFilePaths!=null)
|
{
|
||||||
//{
|
GUITextBlock textBlock = new GUITextBlock(
|
||||||
foreach (Map map in Map.SavedMaps)
|
new Rectangle(0, 0, 0, 25),
|
||||||
{
|
map.Name,
|
||||||
GUITextBlock textBlock = new GUITextBlock(
|
GUI.style,
|
||||||
new Rectangle(0, 0, 0, 25),
|
Alignment.Left,
|
||||||
map.Name,
|
Alignment.Left,
|
||||||
GUI.style,
|
mapList);
|
||||||
Alignment.Left,
|
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
|
||||||
Alignment.Left,
|
textBlock.UserData = map;
|
||||||
mapList);
|
}
|
||||||
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
|
if (Map.SavedMaps.Count > 0) mapList.Select(Map.SavedMaps[0]);
|
||||||
textBlock.UserData = map;
|
|
||||||
}
|
|
||||||
if (Map.SavedMaps.Count > 0) mapList.Select(Map.SavedMaps[0]);
|
|
||||||
//}
|
|
||||||
|
|
||||||
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", GUI.style, Alignment.Right | Alignment.Bottom, menuTabs[(int)Tabs.NewGame]);
|
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", GUI.style, Alignment.Right | Alignment.Bottom, menuTabs[(int)Tabs.NewGame]);
|
||||||
button.OnClicked = StartGame;
|
button.OnClicked = StartGame;
|
||||||
@@ -150,7 +147,7 @@ namespace Subsurface
|
|||||||
if (selectedMap == null) return false;
|
if (selectedMap == null) return false;
|
||||||
|
|
||||||
|
|
||||||
Game1.GameSession = new GameSession(selectedMap.FilePath, true, TimeSpan.Zero);
|
Game1.GameSession = new GameSession(selectedMap, TimeSpan.Zero);
|
||||||
|
|
||||||
Game1.LobbyScreen.Select();
|
Game1.LobbyScreen.Select();
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Subsurface.Networking;
|
|||||||
using FarseerPhysics;
|
using FarseerPhysics;
|
||||||
using FarseerPhysics.Factories;
|
using FarseerPhysics.Factories;
|
||||||
using FarseerPhysics.Dynamics;
|
using FarseerPhysics.Dynamics;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Subsurface
|
namespace Subsurface
|
||||||
{
|
{
|
||||||
@@ -472,7 +473,7 @@ namespace Subsurface
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg.Write(selectedMap.Name);
|
msg.Write(Path.GetFileName(selectedMap.FilePath));
|
||||||
msg.Write(selectedMap.MapHash.MD5Hash);
|
msg.Write(selectedMap.MapHash.MD5Hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,7 +503,7 @@ namespace Subsurface
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mapList.Select(map);
|
mapList.Select(map);
|
||||||
map.Load();
|
//map.Load();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,7 @@
|
|||||||
<Compile Include="Particles\ParticlePrefab.cs" />
|
<Compile Include="Particles\ParticlePrefab.cs" />
|
||||||
<Compile Include="Physics\Physics.cs" />
|
<Compile Include="Physics\Physics.cs" />
|
||||||
<Compile Include="Properties.cs" />
|
<Compile Include="Properties.cs" />
|
||||||
|
<Compile Include="SaveUtil.cs" />
|
||||||
<Compile Include="Screens\EditCharacterScreen.cs" />
|
<Compile Include="Screens\EditCharacterScreen.cs" />
|
||||||
<Compile Include="EventInput\EventInput.cs" />
|
<Compile Include="EventInput\EventInput.cs" />
|
||||||
<Compile Include="EventInput\KeyboardDispatcher.cs" />
|
<Compile Include="EventInput\KeyboardDispatcher.cs" />
|
||||||
@@ -187,6 +188,9 @@
|
|||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>.\FarseerPhysics MonoGame.dll</HintPath>
|
<HintPath>.\FarseerPhysics MonoGame.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="ICSharpCode.SharpZipLib">
|
||||||
|
<HintPath>C:\Users\Joonas\Desktop\SharpZipLib_0860_Bin\net-20\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Lidgren.Network, Version=3.3.0.2069, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Lidgren.Network, Version=3.3.0.2069, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>.\Lidgren.Network.dll</HintPath>
|
<HintPath>.\Lidgren.Network.dll</HintPath>
|
||||||
@@ -218,16 +222,28 @@
|
|||||||
<Content Include="Content\Characters\Human\ffirstnames.txt">
|
<Content Include="Content\Characters\Human\ffirstnames.txt">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Content\Characters\Human\fhead.png">
|
<Content Include="Content\Characters\Human\fhead1.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Content\Characters\Human\fhead2.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Content\Characters\Human\firstnames.txt">
|
<Content Include="Content\Characters\Human\firstnames.txt">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Content\Characters\Human\head.png">
|
<Content Include="Content\Characters\Human\flegs.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Content\Characters\Human\flegs.png">
|
<Content Include="Content\Characters\Human\head1.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Content\Characters\Human\head2.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Content\Characters\Human\head3.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Content\Characters\Human\head4.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Content\Characters\Human\lastnames.txt">
|
<Content Include="Content\Characters\Human\lastnames.txt">
|
||||||
@@ -271,6 +287,12 @@
|
|||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Content\Items\Clothes\captainhat.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Content\Items\Clothes\clothes.xml">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Content\Items\connector.png">
|
<Content Include="Content\Items\connector.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
@@ -128,50 +128,50 @@ namespace Subsurface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void CompressStringToFile(string fileName, string value)
|
//public static void CompressStringToFile(string fileName, string value)
|
||||||
{
|
//{
|
||||||
// A.
|
// // A.
|
||||||
// Write string to temporary file.
|
// // Write string to temporary file.
|
||||||
string temp = Path.GetTempFileName();
|
// string temp = Path.GetTempFileName();
|
||||||
File.WriteAllText(temp, value);
|
// File.WriteAllText(temp, value);
|
||||||
|
|
||||||
// B.
|
// // B.
|
||||||
// Read file into byte array buffer.
|
// // Read file into byte array buffer.
|
||||||
byte[] b;
|
// byte[] b;
|
||||||
using (FileStream f = new FileStream(temp, FileMode.Open))
|
// using (FileStream f = new FileStream(temp, FileMode.Open))
|
||||||
{
|
// {
|
||||||
b = new byte[f.Length];
|
// b = new byte[f.Length];
|
||||||
f.Read(b, 0, (int)f.Length);
|
// f.Read(b, 0, (int)f.Length);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// C.
|
// // C.
|
||||||
// Use GZipStream to write compressed bytes to target file.
|
// // Use GZipStream to write compressed bytes to target file.
|
||||||
using (FileStream f2 = new FileStream(fileName, FileMode.Create))
|
// using (FileStream f2 = new FileStream(fileName, FileMode.Create))
|
||||||
using (GZipStream gz = new GZipStream(f2, CompressionMode.Compress, false))
|
// using (GZipStream gz = new GZipStream(f2, CompressionMode.Compress, false))
|
||||||
{
|
// {
|
||||||
gz.Write(b, 0, b.Length);
|
// gz.Write(b, 0, b.Length);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
public static Stream DecompressFiletoStream(string fileName)
|
//public static Stream DecompressFiletoStream(string fileName)
|
||||||
{
|
//{
|
||||||
if (!File.Exists(fileName))
|
// if (!File.Exists(fileName))
|
||||||
{
|
// {
|
||||||
DebugConsole.ThrowError("File ''"+fileName+" doesn't exist!");
|
// DebugConsole.ThrowError("File ''"+fileName+" doesn't exist!");
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
using (FileStream originalFileStream = new FileStream(fileName, FileMode.Open))
|
// using (FileStream originalFileStream = new FileStream(fileName, FileMode.Open))
|
||||||
{
|
// {
|
||||||
MemoryStream decompressedFileStream = new MemoryStream();
|
// MemoryStream decompressedFileStream = new MemoryStream();
|
||||||
|
|
||||||
using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress))
|
// using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress))
|
||||||
{
|
// {
|
||||||
decompressionStream.CopyTo(decompressedFileStream);
|
// decompressionStream.CopyTo(decompressedFileStream);
|
||||||
return decompressedFileStream;
|
// return decompressedFileStream;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
public static XDocument TryLoadXml(string filePath)
|
public static XDocument TryLoadXml(string filePath)
|
||||||
{
|
{
|
||||||
|
|||||||