Navigation requires power, locationtypes and missions included in content packages

This commit is contained in:
Regalis
2016-02-18 22:04:47 +02:00
parent cd4e3a3d2a
commit 9e11134bd3
10 changed files with 50 additions and 29 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ namespace Barotrauma
{
public enum ContentType
{
None, Jobs, Item, Character, Structure, Executable, RandomEvents
None, Jobs, Item, Character, Structure, Executable, LocationTypes, RandomEvents, Missions
}
public class ContentPackage
+4 -3
View File
@@ -10,9 +10,7 @@ namespace Barotrauma
class Mission
{
private static List<Mission> list = new List<Mission>();
private static string configFile = "Content/Missions.xml";
private string name;
private string description;
@@ -96,6 +94,9 @@ namespace Barotrauma
public static Mission LoadRandom(Location[] locations, Random rand)
{
var files = GameMain.SelectedPackage.GetFilesOfType(ContentType.Missions);
string configFile = files[rand.Next(files.Count)];
XDocument doc = ToolBox.TryLoadXml(configFile);
if (doc == null) return null;
+1 -1
View File
@@ -253,7 +253,7 @@ namespace Barotrauma
ParticleManager = new ParticleManager("Content/Particles/ParticlePrefabs.xml", Cam);
yield return CoroutineStatus.Running;
LocationType.Init("Content/Map/locationTypes.xml");
LocationType.Init();
MainMenuScreen.Select();
TitleScreen.LoadState = 100.0f;
@@ -117,18 +117,10 @@ namespace Barotrauma.Items.Components
{
//base.Update(deltaTime, cam);
//if (voltage < minVoltage) return;
if (voltage < minVoltage) return;
if (autoPilot)
{
//if (steeringPath==null)
//{
// PathFinder pathFinder = new PathFinder(WayPoint.WayPointList, false);
// steeringPath = pathFinder.FindPath(
// ConvertUnits.ToSimUnits(Level.Loaded.StartPosition),
// ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
//}
UpdateAutoPilot(deltaTime);
}
else if (valueChanged)
@@ -149,6 +141,9 @@ namespace Barotrauma.Items.Components
targetLevel += (neutralBallastLevel - 0.5f) * 100.0f;
item.SendSignal(targetLevel.ToString(CultureInfo.InvariantCulture), "velocity_y_out");
voltage -= deltaTime;
}
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
@@ -162,13 +157,15 @@ namespace Barotrauma.Items.Components
GuiFrame.Update(1.0f / 60.0f);
GuiFrame.Draw(spriteBatch);
if (voltage < minVoltage) return;
Rectangle velRect = new Rectangle(x + 20, y + 20, width - 40, height - 40);
//GUI.DrawRectangle(spriteBatch, velRect, Color.White, false);
if (Submarine.Loaded != null && Level.Loaded != null)
{
Vector2 realWorldVelocity = ConvertUnits.ToDisplayUnits(Submarine.Loaded.Velocity * Physics.DisplayToRealWorldRatio) * 3.6f;
float realWorldDepth = (Submarine.Loaded.Position.Y - Level.Loaded.Size.Y) *Physics.DisplayToRealWorldRatio;
float realWorldDepth = Math.Abs(Submarine.Loaded.Position.Y - Level.Loaded.Size.Y) * Physics.DisplayToRealWorldRatio;
GUI.DrawString(spriteBatch, new Vector2(x + 20, y + height - 65),
"Velocity: " + (int)realWorldVelocity.X + " km/h", Color.LightGreen, null, 0, GUI.SmallFont);
GUI.DrawString(spriteBatch, new Vector2(x + 20, y + height - 50),
@@ -306,7 +303,11 @@ namespace Barotrauma.Items.Components
if (connection.Name == "velocity_in")
{
currVelocity = ToolBox.ParseToVector2(signal, false);
}
}
else
{
base.ReceiveSignal(signal, connection, sender, power);
}
}
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
+16 -10
View File
@@ -127,20 +127,26 @@ namespace Barotrauma
return null;
}
public static void Init(string file)
public static void Init()
{
XDocument doc = ToolBox.TryLoadXml(file);
if (doc==null)
var locationTypeFiles = GameMain.SelectedPackage.GetFilesOfType(ContentType.LocationTypes);
foreach (string file in locationTypeFiles)
{
return;
XDocument doc = ToolBox.TryLoadXml(file);
if (doc==null)
{
return;
}
foreach (XElement element in doc.Root.Elements())
{
LocationType locationType = new LocationType(element);
list.Add(locationType);
}
}
foreach (XElement element in doc.Root.Elements())
{
LocationType locationType = new LocationType(element);
list.Add(locationType);
}
}
}
}