Merge branch 'master' of https://bitbucket.org/Regalis11/repo
Conflicts: Subsurface_Solution.v12.suo
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Subsurface
|
|||||||
|
|
||||||
public int HeadSpriteId;
|
public int HeadSpriteId;
|
||||||
|
|
||||||
//public int ID;
|
public Job Job;
|
||||||
|
|
||||||
public Gender Gender;
|
public Gender Gender;
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ namespace Subsurface
|
|||||||
// 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, Job job = null)
|
||||||
{
|
{
|
||||||
this.File = file;
|
this.File = file;
|
||||||
|
|
||||||
@@ -62,6 +62,8 @@ namespace Subsurface
|
|||||||
HeadSpriteId = Rand.Range((int)headSpriteRange.X, (int)headSpriteRange.Y + 1);
|
HeadSpriteId = Rand.Range((int)headSpriteRange.X, (int)headSpriteRange.Y + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.Job = (job == null) ? Job.Random() : job;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(name))
|
if (!string.IsNullOrEmpty(name))
|
||||||
{
|
{
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
|
|||||||
@@ -114,6 +114,8 @@ namespace Subsurface
|
|||||||
|
|
||||||
float angle = MathUtils.GetShortestAngle(tail.body.Rotation, movementAngle + waveRotation);
|
float angle = MathUtils.GetShortestAngle(tail.body.Rotation, movementAngle + waveRotation);
|
||||||
|
|
||||||
|
tail.body.ApplyTorque(angle * tail.Mass);
|
||||||
|
|
||||||
//limbs[tailIndex].body.ApplyTorque((Math.Sign(angle) + Math.Max(Math.Min(angle * 10.0f, 10.0f), -10.0f)) * limbs[tailIndex].body.Mass);
|
//limbs[tailIndex].body.ApplyTorque((Math.Sign(angle) + Math.Max(Math.Min(angle * 10.0f, 10.0f), -10.0f)) * limbs[tailIndex].body.Mass);
|
||||||
//limbs[tailIndex].body.ApplyTorque(-limbs[tailIndex].body.AngularVelocity * 0.5f * limbs[tailIndex].body.Mass);
|
//limbs[tailIndex].body.ApplyTorque(-limbs[tailIndex].body.AngularVelocity * 0.5f * limbs[tailIndex].body.Mass);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +1,52 @@
|
|||||||
using System.Collections.Generic;
|
using Microsoft.Xna.Framework;
|
||||||
using System.Xml.Linq;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Subsurface
|
namespace Subsurface
|
||||||
{
|
{
|
||||||
class Job
|
class Job
|
||||||
{
|
{
|
||||||
public static List<Job> jobList;
|
|
||||||
|
|
||||||
string name;
|
private JobPrefab prefab;
|
||||||
string description;
|
|
||||||
|
|
||||||
//names of the items the character spawns with
|
private Dictionary<string, float> skills;
|
||||||
public List<string> itemNames;
|
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return name; }
|
get { return prefab.Name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Job(XElement element)
|
public string Description
|
||||||
{
|
{
|
||||||
name = element.Name.ToString();
|
get { return prefab.Description; }
|
||||||
|
}
|
||||||
|
|
||||||
description = ToolBox.GetAttributeString(element, "description", "");
|
public Job(JobPrefab jobPrefab)
|
||||||
|
|
||||||
itemNames = new List<string>();
|
|
||||||
|
|
||||||
foreach (XElement subElement in element.Elements())
|
|
||||||
{
|
{
|
||||||
switch (subElement.Name.ToString())
|
prefab = jobPrefab;
|
||||||
|
|
||||||
|
skills = new Dictionary<string, float>();
|
||||||
|
foreach (KeyValuePair<string, Vector2> skill in prefab.skills)
|
||||||
{
|
{
|
||||||
case "item":
|
skills.Add(skill.Key, Rand.Range(skill.Value.X, skill.Value.Y, false));
|
||||||
string itemName = ToolBox.GetAttributeString(subElement, "name", "");
|
|
||||||
if (!string.IsNullOrEmpty(itemName)) itemNames.Add(itemName);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Job Random()
|
||||||
public static void LoadAll(string filePath)
|
|
||||||
{
|
{
|
||||||
jobList = new List<Job>();
|
JobPrefab prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count-1, false)];
|
||||||
|
|
||||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
return new Job(prefab);
|
||||||
if (doc == null) return;
|
}
|
||||||
|
|
||||||
foreach (XElement element in doc.Root.Elements())
|
public float GetSkill(string skillName)
|
||||||
{
|
{
|
||||||
Job job = new Job(element);
|
float skillLevel = 0.0f;
|
||||||
jobList.Add(job);
|
skills.TryGetValue(skillName.ToLower(), out skillLevel);
|
||||||
}
|
|
||||||
|
return skillLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace Subsurface
|
||||||
|
{
|
||||||
|
class JobPrefab
|
||||||
|
{
|
||||||
|
public static List<JobPrefab> List;
|
||||||
|
|
||||||
|
string name;
|
||||||
|
string description;
|
||||||
|
|
||||||
|
//names of the items the character spawns with
|
||||||
|
public List<string> itemNames;
|
||||||
|
|
||||||
|
public Dictionary<string, Vector2> skills;
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return name; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get { return description; }
|
||||||
|
}
|
||||||
|
|
||||||
|
//public float GetSkill(string skillName)
|
||||||
|
//{
|
||||||
|
// float skillLevel = 0.0f;
|
||||||
|
// if (skills.TryGetValue(skillName.ToLower(), out skillLevel))
|
||||||
|
// {
|
||||||
|
// return skillLevel;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// DebugConsole.ThrowError("Skill ''"+skillName+" not found!");
|
||||||
|
// return skillLevel;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
public JobPrefab(XElement element)
|
||||||
|
{
|
||||||
|
name = element.Name.ToString();
|
||||||
|
|
||||||
|
description = ToolBox.GetAttributeString(element, "description", "");
|
||||||
|
|
||||||
|
itemNames = new List<string>();
|
||||||
|
|
||||||
|
skills = new Dictionary<string, Vector2>();
|
||||||
|
|
||||||
|
foreach (XElement subElement in element.Elements())
|
||||||
|
{
|
||||||
|
switch (subElement.Name.ToString())
|
||||||
|
{
|
||||||
|
case "item":
|
||||||
|
string itemName = ToolBox.GetAttributeString(subElement, "name", "");
|
||||||
|
if (!string.IsNullOrEmpty(itemName)) itemNames.Add(itemName);
|
||||||
|
break;
|
||||||
|
case "skills":
|
||||||
|
LoadSkills(subElement);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadSkills(XElement element)
|
||||||
|
{
|
||||||
|
foreach (XElement subElement in element.Elements())
|
||||||
|
{
|
||||||
|
string skillName = subElement.Name.ToString().ToLower();
|
||||||
|
if (skills.ContainsKey(skillName)) continue;
|
||||||
|
|
||||||
|
var levelAttribute = subElement.Attribute("level").ToString();
|
||||||
|
if (levelAttribute.Contains("'"))
|
||||||
|
{
|
||||||
|
skills.Add(skillName, ToolBox.ParseToVector2(levelAttribute, false));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float skillLevel = float.Parse(levelAttribute, CultureInfo.InvariantCulture);
|
||||||
|
skills.Add(skillName, new Vector2(skillLevel, skillLevel));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void LoadAll(string filePath)
|
||||||
|
{
|
||||||
|
List = new List<JobPrefab>();
|
||||||
|
|
||||||
|
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||||
|
if (doc == null) return;
|
||||||
|
|
||||||
|
foreach (XElement element in doc.Root.Elements())
|
||||||
|
{
|
||||||
|
JobPrefab job = new JobPrefab(element);
|
||||||
|
List.Add(job);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -145,7 +145,7 @@ namespace Subsurface
|
|||||||
|
|
||||||
MapEntityPrefab.Init();
|
MapEntityPrefab.Init();
|
||||||
|
|
||||||
Job.LoadAll("Content/Characters/Jobs.xml");
|
JobPrefab.LoadAll("Content/Characters/Jobs.xml");
|
||||||
|
|
||||||
StructurePrefab.LoadAll("Content/Map/StructurePrefabs.xml");
|
StructurePrefab.LoadAll("Content/Map/StructurePrefabs.xml");
|
||||||
ItemPrefab.LoadAll();
|
ItemPrefab.LoadAll();
|
||||||
|
|||||||
+23
-22
@@ -2,6 +2,7 @@
|
|||||||
using FarseerPhysics.Common;
|
using FarseerPhysics.Common;
|
||||||
using FarseerPhysics.Dynamics;
|
using FarseerPhysics.Dynamics;
|
||||||
using FarseerPhysics.Factories;
|
using FarseerPhysics.Factories;
|
||||||
|
using Lidgren.Network;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
@@ -24,13 +25,13 @@ namespace Subsurface
|
|||||||
|
|
||||||
private int siteInterval;
|
private int siteInterval;
|
||||||
|
|
||||||
const int gridCellWidth = 2000;
|
const int GridCellWidth = 2000;
|
||||||
List<VoronoiCell>[,] cellGrid;
|
private List<VoronoiCell>[,] cellGrid;
|
||||||
|
|
||||||
//List<Body> bodies;
|
//List<Body> bodies;
|
||||||
List<VoronoiCell> cells;
|
private List<VoronoiCell> cells;
|
||||||
|
|
||||||
BasicEffect basicEffect;
|
private BasicEffect basicEffect;
|
||||||
|
|
||||||
private VertexPositionColor[] vertices;
|
private VertexPositionColor[] vertices;
|
||||||
private VertexBuffer vertexBuffer;
|
private VertexBuffer vertexBuffer;
|
||||||
@@ -38,7 +39,7 @@ namespace Subsurface
|
|||||||
private Vector2 startPosition;
|
private Vector2 startPosition;
|
||||||
private Vector2 endPosition;
|
private Vector2 endPosition;
|
||||||
|
|
||||||
Rectangle borders;
|
private Rectangle borders;
|
||||||
|
|
||||||
public Vector2 StartPosition
|
public Vector2 StartPosition
|
||||||
{
|
{
|
||||||
@@ -107,10 +108,10 @@ namespace Subsurface
|
|||||||
Debug.WriteLine("MakeVoronoiGraph: " + sw2.ElapsedMilliseconds + " ms");
|
Debug.WriteLine("MakeVoronoiGraph: " + sw2.ElapsedMilliseconds + " ms");
|
||||||
sw2.Restart();
|
sw2.Restart();
|
||||||
|
|
||||||
cellGrid = new List<VoronoiCell>[borders.Width / gridCellWidth, borders.Height / gridCellWidth];
|
cellGrid = new List<VoronoiCell>[borders.Width / GridCellWidth, borders.Height / GridCellWidth];
|
||||||
for (int x = 0; x < borders.Width / gridCellWidth; x++)
|
for (int x = 0; x < borders.Width / GridCellWidth; x++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < borders.Height / gridCellWidth; y++)
|
for (int y = 0; y < borders.Height / GridCellWidth; y++)
|
||||||
{
|
{
|
||||||
cellGrid[x, y] = new List<VoronoiCell>();
|
cellGrid[x, y] = new List<VoronoiCell>();
|
||||||
}
|
}
|
||||||
@@ -125,13 +126,13 @@ namespace Subsurface
|
|||||||
Site site = (i == 0) ? ge.site1 : ge.site2;
|
Site site = (i == 0) ? ge.site1 : ge.site2;
|
||||||
|
|
||||||
VoronoiCell cell = cellGrid[
|
VoronoiCell cell = cellGrid[
|
||||||
(int)Math.Floor(site.coord.x / gridCellWidth),
|
(int)Math.Floor(site.coord.x / GridCellWidth),
|
||||||
(int)Math.Floor(site.coord.y / gridCellWidth)].Find(c => c.site == site);
|
(int)Math.Floor(site.coord.y / GridCellWidth)].Find(c => c.site == site);
|
||||||
|
|
||||||
if (cell == null)
|
if (cell == null)
|
||||||
{
|
{
|
||||||
cell = new VoronoiCell(site);
|
cell = new VoronoiCell(site);
|
||||||
cellGrid[(int)Math.Floor(cell.Center.X / gridCellWidth), (int)Math.Floor(cell.Center.Y / gridCellWidth)].Add(cell);
|
cellGrid[(int)Math.Floor(cell.Center.X / GridCellWidth), (int)Math.Floor(cell.Center.Y / GridCellWidth)].Add(cell);
|
||||||
cells.Add(cell);
|
cells.Add(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +204,7 @@ namespace Subsurface
|
|||||||
|
|
||||||
foreach (VoronoiCell cell in cells)
|
foreach (VoronoiCell cell in cells)
|
||||||
{
|
{
|
||||||
cellGrid[(int)Math.Floor(cell.Center.X / gridCellWidth), (int)Math.Floor(cell.Center.Y / gridCellWidth)].Add(cell);
|
cellGrid[(int)Math.Floor(cell.Center.X / GridCellWidth), (int)Math.Floor(cell.Center.Y / GridCellWidth)].Add(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneratePolygons(cells, pathCells);
|
GeneratePolygons(cells, pathCells);
|
||||||
@@ -399,8 +400,8 @@ namespace Subsurface
|
|||||||
float closestDist = 0.0f;
|
float closestDist = 0.0f;
|
||||||
VoronoiCell closestCell = null;
|
VoronoiCell closestCell = null;
|
||||||
|
|
||||||
int gridPosX = (int)Math.Floor(position.X / gridCellWidth);
|
int gridPosX = (int)Math.Floor(position.X / GridCellWidth);
|
||||||
int gridPosY = (int)Math.Floor(position.Y / gridCellWidth);
|
int gridPosY = (int)Math.Floor(position.Y / GridCellWidth);
|
||||||
|
|
||||||
int searchOffset = 1;
|
int searchOffset = 1;
|
||||||
|
|
||||||
@@ -492,10 +493,9 @@ namespace Subsurface
|
|||||||
//todo: make sure the first point is the one where the edge should start from
|
//todo: make sure the first point is the one where the edge should start from
|
||||||
bodyPoints.Sort(new CompareCCW(cell.Center));
|
bodyPoints.Sort(new CompareCCW(cell.Center));
|
||||||
|
|
||||||
if (bodyPoints.Count == tempVertices.Count)
|
//if (bodyPoints.Count == tempVertices.Count)
|
||||||
{
|
//{
|
||||||
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < bodyPoints.Count; i++)
|
for (int i = 0; i < bodyPoints.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -636,8 +636,8 @@ namespace Subsurface
|
|||||||
public void SetObserverPosition(Vector2 position)
|
public void SetObserverPosition(Vector2 position)
|
||||||
{
|
{
|
||||||
observerPosition = position - this.Position;
|
observerPosition = position - this.Position;
|
||||||
int gridPosX = (int)Math.Floor(observerPosition.X / gridCellWidth);
|
int gridPosX = (int)Math.Floor(observerPosition.X / GridCellWidth);
|
||||||
int gridPosY = (int)Math.Floor(observerPosition.Y / gridCellWidth);
|
int gridPosY = (int)Math.Floor(observerPosition.Y / GridCellWidth);
|
||||||
int searchOffset = 2;
|
int searchOffset = 2;
|
||||||
|
|
||||||
int startX = Math.Max(gridPosX - searchOffset, 0);
|
int startX = Math.Max(gridPosX - searchOffset, 0);
|
||||||
@@ -726,8 +726,8 @@ namespace Subsurface
|
|||||||
public List<Vector2[]> GetCellEdges(Vector2 refPos, int searchDepth = 2, bool onlySolid = true)
|
public List<Vector2[]> GetCellEdges(Vector2 refPos, int searchDepth = 2, bool onlySolid = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
int gridPosX = (int)Math.Floor(refPos.X / gridCellWidth);
|
int gridPosX = (int)Math.Floor(refPos.X / GridCellWidth);
|
||||||
int gridPosY = (int)Math.Floor(refPos.Y / gridCellWidth);
|
int gridPosY = (int)Math.Floor(refPos.Y / GridCellWidth);
|
||||||
|
|
||||||
int startX = Math.Max(gridPosX - searchDepth, 0);
|
int startX = Math.Max(gridPosX - searchDepth, 0);
|
||||||
int endX = Math.Min(gridPosX + searchDepth, cellGrid.GetLength(0) - 1);
|
int endX = Math.Min(gridPosX + searchDepth, cellGrid.GetLength(0) - 1);
|
||||||
@@ -800,6 +800,7 @@ namespace Subsurface
|
|||||||
vertexBuffer.Dispose();
|
vertexBuffer.Dispose();
|
||||||
vertexBuffer = null;
|
vertexBuffer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+61
-15
@@ -5,6 +5,7 @@ using FarseerPhysics.Common.Decomposition;
|
|||||||
using FarseerPhysics.Dynamics;
|
using FarseerPhysics.Dynamics;
|
||||||
using FarseerPhysics.Dynamics.Contacts;
|
using FarseerPhysics.Dynamics.Contacts;
|
||||||
using FarseerPhysics.Factories;
|
using FarseerPhysics.Factories;
|
||||||
|
using Lidgren.Network;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
@@ -22,14 +23,14 @@ namespace Subsurface
|
|||||||
None = 0, Left = 1, Right = 2
|
None = 0, Left = 1, Right = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
class Submarine
|
class Submarine : Entity
|
||||||
{
|
{
|
||||||
public static List<Submarine> SavedSubmarines = new List<Submarine>();
|
public static List<Submarine> SavedSubmarines = new List<Submarine>();
|
||||||
|
|
||||||
private static Submarine loaded;
|
|
||||||
|
|
||||||
public static readonly Vector2 GridSize = new Vector2(16.0f, 16.0f);
|
public static readonly Vector2 GridSize = new Vector2(16.0f, 16.0f);
|
||||||
|
|
||||||
|
private static Submarine loaded;
|
||||||
|
|
||||||
private static Vector2 lastPickedPosition;
|
private static Vector2 lastPickedPosition;
|
||||||
private static float lastPickedFraction;
|
private static float lastPickedFraction;
|
||||||
|
|
||||||
@@ -38,6 +39,9 @@ namespace Subsurface
|
|||||||
|
|
||||||
Vector2 speed;
|
Vector2 speed;
|
||||||
|
|
||||||
|
Vector2 targetPosition;
|
||||||
|
Vector2 targetSpeed;
|
||||||
|
|
||||||
private Rectangle borders;
|
private Rectangle borders;
|
||||||
|
|
||||||
private Body hullBody;
|
private Body hullBody;
|
||||||
@@ -45,6 +49,10 @@ namespace Subsurface
|
|||||||
private string filePath;
|
private string filePath;
|
||||||
private string name;
|
private string name;
|
||||||
|
|
||||||
|
|
||||||
|
private double lastNetworkUpdate;
|
||||||
|
|
||||||
|
|
||||||
//properties ----------------------------------------------------
|
//properties ----------------------------------------------------
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
@@ -99,6 +107,11 @@ namespace Subsurface
|
|||||||
get { return new Vector2(borders.X+borders.Width/2, borders.Y - borders.Height/2); }
|
get { return new Vector2(borders.X+borders.Width/2, borders.Y - borders.Height/2); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector2 Position
|
||||||
|
{
|
||||||
|
get { return (Level.Loaded==null) ? Vector2.Zero : -Level.Loaded.Position; }
|
||||||
|
}
|
||||||
|
|
||||||
public string FilePath
|
public string FilePath
|
||||||
{
|
{
|
||||||
get { return filePath; }
|
get { return filePath; }
|
||||||
@@ -392,16 +405,27 @@ namespace Subsurface
|
|||||||
|
|
||||||
public void Update(float deltaTime)
|
public void Update(float deltaTime)
|
||||||
{
|
{
|
||||||
Translate(ConvertUnits.ToDisplayUnits(hullBody.Position) * collisionRigidness + speed * deltaTime);
|
Vector2 translateAmount = speed * deltaTime;
|
||||||
|
translateAmount += ConvertUnits.ToDisplayUnits(hullBody.Position) * collisionRigidness;
|
||||||
|
|
||||||
|
if (targetPosition != Vector2.Zero && Vector2.Distance(targetPosition, Position) > 5.0f)
|
||||||
|
{
|
||||||
|
translateAmount += (targetPosition - Position)*0.1f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
targetPosition = Vector2.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
CalculateBuoyancy();
|
Translate(translateAmount);
|
||||||
|
|
||||||
|
ApplyForce(CalculateBuoyancy());
|
||||||
|
|
||||||
float dragCoefficient = 0.00001f;
|
float dragCoefficient = 0.00001f;
|
||||||
|
|
||||||
float speedLength = speed.Length();
|
float speedLength = speed.Length();
|
||||||
float drag = speedLength * speedLength * dragCoefficient * mass;
|
float drag = speedLength * speedLength * dragCoefficient * mass;
|
||||||
System.Diagnostics.Debug.WriteLine("speed: "+speed);
|
|
||||||
if (speed != Vector2.Zero)
|
if (speed != Vector2.Zero)
|
||||||
{
|
{
|
||||||
ApplyForce(-Vector2.Normalize(speed) * drag);
|
ApplyForce(-Vector2.Normalize(speed) * drag);
|
||||||
@@ -439,7 +463,7 @@ namespace Subsurface
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CalculateBuoyancy()
|
private Vector2 CalculateBuoyancy()
|
||||||
{
|
{
|
||||||
float waterVolume = 0.0f;
|
float waterVolume = 0.0f;
|
||||||
float volume = 0.0f;
|
float volume = 0.0f;
|
||||||
@@ -456,7 +480,7 @@ namespace Subsurface
|
|||||||
float buoyancy = neutralPercentage-waterPercentage;
|
float buoyancy = neutralPercentage-waterPercentage;
|
||||||
buoyancy *= mass * 10.0f;
|
buoyancy *= mass * 10.0f;
|
||||||
|
|
||||||
ApplyForce(new Vector2(0.0f, buoyancy));
|
return new Vector2(0.0f, buoyancy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPosition(Vector2 position)
|
public void SetPosition(Vector2 position)
|
||||||
@@ -510,6 +534,34 @@ namespace Subsurface
|
|||||||
collidingCell = null;
|
collidingCell = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void FillNetworkData(Networking.NetworkEventType type, NetOutgoingMessage message, object data)
|
||||||
|
{
|
||||||
|
message.Write(NetTime.Now);
|
||||||
|
message.Write(Position.X);
|
||||||
|
message.Write(Position.Y);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ReadNetworkData(Networking.NetworkEventType type, NetIncomingMessage message)
|
||||||
|
{
|
||||||
|
double sendingTime = message.ReadDouble();
|
||||||
|
|
||||||
|
if (sendingTime <= lastNetworkUpdate) return;
|
||||||
|
|
||||||
|
Vector2 newPosition = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||||
|
if (newPosition == Position) return;
|
||||||
|
if ((newPosition - Position).Length() > 500.0f)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine("Submarine has moved over 500 pixels since last update");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
targetPosition = Position;
|
||||||
|
|
||||||
|
lastNetworkUpdate = sendingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//saving/loading ----------------------------------------------------
|
//saving/loading ----------------------------------------------------
|
||||||
|
|
||||||
@@ -553,7 +605,7 @@ namespace Subsurface
|
|||||||
if (loaded==null)
|
if (loaded==null)
|
||||||
{
|
{
|
||||||
loaded = new Submarine(savePath);
|
loaded = new Submarine(savePath);
|
||||||
return;
|
// return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loaded.SaveAs(savePath);
|
loaded.SaveAs(savePath);
|
||||||
@@ -768,7 +820,6 @@ namespace Subsurface
|
|||||||
sub.Load();
|
sub.Load();
|
||||||
|
|
||||||
return sub;
|
return sub;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Unload()
|
public static void Unload()
|
||||||
@@ -793,9 +844,4 @@ namespace Subsurface
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//class HullBody
|
|
||||||
//{
|
|
||||||
// public Body body;
|
|
||||||
// //public Texture2D shapeTexture;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ namespace Subsurface
|
|||||||
{
|
{
|
||||||
GUITextBlock textBlock = new GUITextBlock(
|
GUITextBlock textBlock = new GUITextBlock(
|
||||||
new Rectangle(0, 0, 0, 25),
|
new Rectangle(0, 0, 0, 25),
|
||||||
c.Name, GUI.style,
|
c.Name + " ("+c.Job.Name+")", GUI.style,
|
||||||
Alignment.Left,
|
Alignment.Left,
|
||||||
Alignment.Left,
|
Alignment.Left,
|
||||||
characterList);
|
characterList);
|
||||||
@@ -205,7 +205,7 @@ namespace Subsurface
|
|||||||
|
|
||||||
GUITextBlock textBlock = new GUITextBlock(
|
GUITextBlock textBlock = new GUITextBlock(
|
||||||
new Rectangle(0, 0, 0, 25),
|
new Rectangle(0, 0, 0, 25),
|
||||||
c.Name,
|
c.Name + " (" + c.Job.Name + ")",
|
||||||
Color.Transparent, Color.Black,
|
Color.Transparent, Color.Black,
|
||||||
Alignment.Left, null, frame);
|
Alignment.Left, null, frame);
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,15 @@ namespace Subsurface
|
|||||||
{
|
{
|
||||||
enum Tabs { Main = 0, NewGame = 1, LoadGame = 2, JoinServer = 3 }
|
enum Tabs { Main = 0, NewGame = 1, LoadGame = 2, JoinServer = 3 }
|
||||||
|
|
||||||
GUIFrame[] menuTabs;
|
private GUIFrame[] menuTabs;
|
||||||
GUIListBox mapList;
|
private GUIListBox mapList;
|
||||||
|
|
||||||
GUIListBox saveList;
|
private GUIListBox saveList;
|
||||||
|
|
||||||
GUITextBox nameBox;
|
private GUITextBox nameBox;
|
||||||
GUITextBox ipBox;
|
private GUITextBox ipBox;
|
||||||
|
|
||||||
Game1 game;
|
private Game1 game;
|
||||||
|
|
||||||
int selectedTab;
|
int selectedTab;
|
||||||
|
|
||||||
@@ -87,6 +87,18 @@ namespace Subsurface
|
|||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Load Game", Color.Transparent, Color.Black, Alignment.CenterX, null, menuTabs[(int)Tabs.LoadGame]);
|
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Load Game", Color.Transparent, Color.Black, Alignment.CenterX, null, menuTabs[(int)Tabs.LoadGame]);
|
||||||
|
|
||||||
|
if (!Directory.Exists(SaveUtil.SaveFolder))
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Save folder ''"+SaveUtil.SaveFolder+" not found! Attempting to create a new folder");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(SaveUtil.SaveFolder);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Failed to create the folder ''"+SaveUtil.SaveFolder+"''!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string[] saveFiles = Directory.GetFiles(SaveUtil.SaveFolder, "*.save");
|
string[] saveFiles = Directory.GetFiles(SaveUtil.SaveFolder, "*.save");
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ namespace Subsurface
|
|||||||
|
|
||||||
GUIListBox jobList = new GUIListBox(new Rectangle(0,180,200,0), GUI.style, playerFrame);
|
GUIListBox jobList = new GUIListBox(new Rectangle(0,180,200,0), GUI.style, playerFrame);
|
||||||
|
|
||||||
foreach (Job job in Job.jobList)
|
foreach (JobPrefab job in JobPrefab.List)
|
||||||
{
|
{
|
||||||
GUITextBlock jobText = new GUITextBlock(new Rectangle(0,0,0,20), job.Name, GUI.style, jobList);
|
GUITextBlock jobText = new GUITextBlock(new Rectangle(0,0,0,20), job.Name, GUI.style, jobList);
|
||||||
GUIButton upButton = new GUIButton(new Rectangle(jobText.Rect.Width - 40, 0, 20, 20), "u", GUI.style, jobText);
|
GUIButton upButton = new GUIButton(new Rectangle(jobText.Rect.Width - 40, 0, 20, 20), "u", GUI.style, jobText);
|
||||||
|
|||||||
@@ -61,6 +61,7 @@
|
|||||||
<Compile Include="Characters\DelayedEffect.cs" />
|
<Compile Include="Characters\DelayedEffect.cs" />
|
||||||
<Compile Include="Characters\Job.cs" />
|
<Compile Include="Characters\Job.cs" />
|
||||||
<Compile Include="Characters\Jobs\Job.cs" />
|
<Compile Include="Characters\Jobs\Job.cs" />
|
||||||
|
<Compile Include="Characters\Jobs\JobPrefab.cs" />
|
||||||
<Compile Include="Characters\AI\SteeringManager.cs" />
|
<Compile Include="Characters\AI\SteeringManager.cs" />
|
||||||
<Compile Include="Characters\AI\SteeringPath.cs" />
|
<Compile Include="Characters\AI\SteeringPath.cs" />
|
||||||
<Compile Include="Rand.cs" />
|
<Compile Include="Rand.cs" />
|
||||||
@@ -197,6 +198,10 @@
|
|||||||
<Compile Include="Map\Hull.cs" />
|
<Compile Include="Map\Hull.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="FarseerPhysics MonoGame, Version=3.5.0.30657, Culture=neutral, processorArchitecture=x86">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>bin\Windows\Debug\FarseerPhysics MonoGame.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>
|
||||||
@@ -715,10 +720,6 @@
|
|||||||
<Folder Include="Data\Saves\" />
|
<Folder Include="Data\Saves\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Lataukset\Selain-lataukset\Farseer Physics Engine 3.5\Farseer Physics Engine 3.5\Farseer Physics MonoGame.csproj">
|
|
||||||
<Project>{0aad36e3-51a5-4a07-ab60-5c8a66bd38b7}</Project>
|
|
||||||
<Name>Farseer Physics MonoGame</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
<ProjectReference Include="..\Subsurface_content\Subsurface_content\Subsurface_content.csproj">
|
<ProjectReference Include="..\Subsurface_content\Subsurface_content\Subsurface_content.csproj">
|
||||||
<Project>{1e6bf44d-6e31-40cc-8321-3d5958c983e7}</Project>
|
<Project>{1e6bf44d-6e31-40cc-8321-3d5958c983e7}</Project>
|
||||||
<Name>Subsurface_content</Name>
|
<Name>Subsurface_content</Name>
|
||||||
|
|||||||
@@ -9,6 +9,6 @@
|
|||||||
<ErrorReportUrlHistory />
|
<ErrorReportUrlHistory />
|
||||||
<FallbackCulture>en-US</FallbackCulture>
|
<FallbackCulture>en-US</FallbackCulture>
|
||||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||||
<ProjectView>ProjectFiles</ProjectView>
|
<ProjectView>ShowAllFiles</ProjectView>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Binary file not shown.
Reference in New Issue
Block a user