Functional networkevent validation, functional single player saving, requireditem ui texts, titlescreen & loading
This commit is contained in:
@@ -286,10 +286,10 @@ namespace Subsurface
|
||||
new Rectangle(rect.X, -rect.Y, rect.Width, rect.Height),
|
||||
Color.Red*((100.0f-OxygenPercentage)/400.0f), true);
|
||||
|
||||
spriteBatch.DrawString(GUI.font, "Pressure: " + ((int)pressure - rect.Y).ToString() +
|
||||
spriteBatch.DrawString(GUI.Font, "Pressure: " + ((int)pressure - rect.Y).ToString() +
|
||||
" - Lethality: " + lethalPressure +
|
||||
" - Oxygen: "+((int)OxygenPercentage), new Vector2(rect.X+10, -rect.Y+10), Color.Black);
|
||||
spriteBatch.DrawString(GUI.font, volume +" / "+ FullVolume, new Vector2(rect.X+10, -rect.Y+30), Color.Black);
|
||||
spriteBatch.DrawString(GUI.Font, volume +" / "+ FullVolume, new Vector2(rect.X+10, -rect.Y+30), Color.Black);
|
||||
|
||||
if (isSelected && editing)
|
||||
{
|
||||
|
||||
@@ -82,7 +82,13 @@ namespace Subsurface
|
||||
get { return seed; }
|
||||
}
|
||||
|
||||
public Level(string seed, int width, int height, int siteInterval)
|
||||
public float Difficulty
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Level(string seed, float difficulty, int width, int height, int siteInterval)
|
||||
{
|
||||
if (shaftTexture == null) shaftTexture = Game1.textureLoader.FromFile("Content/Map/shaft.png");
|
||||
|
||||
@@ -90,16 +96,24 @@ namespace Subsurface
|
||||
|
||||
this.siteInterval = siteInterval;
|
||||
|
||||
this.Difficulty = difficulty;
|
||||
|
||||
borders = new Rectangle(0, 0, width, height);
|
||||
}
|
||||
|
||||
public static Level CreateRandom(LocationConnection locationConnection)
|
||||
{
|
||||
int seed = locationConnection.Locations[0].GetHashCode() | locationConnection.Locations[1].GetHashCode();
|
||||
return new Level(seed.ToString(), locationConnection.Difficulty, 100000, 40000, 2000);
|
||||
}
|
||||
|
||||
public static Level CreateRandom(string seed = "")
|
||||
{
|
||||
if (seed == "")
|
||||
{
|
||||
seed = Rand.Range(0, int.MaxValue, false).ToString();
|
||||
}
|
||||
return new Level(seed, 100000, 40000, 2000);
|
||||
return new Level(seed, Rand.Range(30.0f,80.0f,false), 100000, 40000, 2000);
|
||||
}
|
||||
|
||||
public void Generate(float minWidth, bool mirror=false)
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace Subsurface
|
||||
|
||||
LocationType type;
|
||||
|
||||
public List<LocationConnection> connections;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
@@ -30,6 +32,8 @@ namespace Subsurface
|
||||
this.name = RandomName(LocationType.Random());
|
||||
|
||||
this.mapPosition = mapPosition;
|
||||
|
||||
connections = new List<LocationConnection>();
|
||||
}
|
||||
|
||||
public static Location CreateRandom(Vector2 position)
|
||||
|
||||
+93
-14
@@ -10,6 +10,9 @@ namespace Subsurface
|
||||
{
|
||||
class Map
|
||||
{
|
||||
Vector2 difficultyIncrease = new Vector2(5.0f,10.0f);
|
||||
Vector2 difficultyCutoff = new Vector2(80.0f, 100.0f);
|
||||
|
||||
private List<Level> levels;
|
||||
|
||||
private List<Location> locations;
|
||||
@@ -31,11 +34,20 @@ namespace Subsurface
|
||||
get { return currentLocation; }
|
||||
}
|
||||
|
||||
public int CurrentLocationIndex
|
||||
{
|
||||
get { return locations.IndexOf(currentLocation); }
|
||||
}
|
||||
|
||||
public Location SelectedLocation
|
||||
{
|
||||
get { return selectedLocation; }
|
||||
}
|
||||
|
||||
public int Seed
|
||||
{
|
||||
get { return seed; }
|
||||
}
|
||||
|
||||
public Map(int seed, int size)
|
||||
{
|
||||
@@ -53,9 +65,18 @@ namespace Subsurface
|
||||
iceCraters = Game1.textureLoader.FromFile("Content/Map/iceCraters.png");
|
||||
iceCrack = Game1.textureLoader.FromFile("Content/Map/iceCrack.png");
|
||||
|
||||
|
||||
Rand.SetSyncedSeed(this.seed);
|
||||
|
||||
GenerateLocations();
|
||||
|
||||
currentLocation = locations[locations.Count/2];
|
||||
currentLocation = locations[locations.Count / 2];
|
||||
GenerateDifficulties(currentLocation, new List<LocationConnection> (connections), 10.0f);
|
||||
|
||||
foreach (LocationConnection connection in connections)
|
||||
{
|
||||
connection.Level = Level.CreateRandom(connection);
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateLocations()
|
||||
@@ -65,7 +86,7 @@ namespace Subsurface
|
||||
List<Vector2> sites = new List<Vector2>();
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
sites.Add(new Vector2(Rand.Range(0.0f, size), Rand.Range(0.0f, size)));
|
||||
sites.Add(new Vector2(Rand.Range(0.0f, size, false), Rand.Range(0.0f, size, false)));
|
||||
}
|
||||
|
||||
List<GraphEdge> edges = voronoi.MakeVoronoiGraph(sites, size, size);
|
||||
@@ -91,7 +112,7 @@ namespace Subsurface
|
||||
|
||||
Vector2[] points = new Vector2[] { edge.point1, edge.point2 };
|
||||
|
||||
int positionIndex = Rand.Int(1);
|
||||
int positionIndex = Rand.Int(1,false);
|
||||
|
||||
Vector2 position = points[positionIndex];
|
||||
if (newLocations[1 - i] != null && newLocations[1 - i].MapPosition == position) position = points[1 - positionIndex];
|
||||
@@ -100,9 +121,7 @@ namespace Subsurface
|
||||
locations.Add(newLocations[i]);
|
||||
}
|
||||
int seed = (newLocations[0].GetHashCode() | newLocations[1].GetHashCode());
|
||||
connections.Add(new LocationConnection(newLocations[0], newLocations[1], Level.CreateRandom(seed.ToString())));
|
||||
|
||||
|
||||
connections.Add(new LocationConnection(newLocations[0], newLocations[1]));
|
||||
}
|
||||
|
||||
float minDistance = 50.0f;
|
||||
@@ -120,17 +139,22 @@ namespace Subsurface
|
||||
|
||||
foreach (LocationConnection connection2 in connections)
|
||||
{
|
||||
if (connection == connection2) continue;
|
||||
if (connection2.Locations[0] == connection.Locations[0]) connection2.Locations[0] = connection.Locations[1];
|
||||
if (connection2.Locations[1] == connection.Locations[0]) connection2.Locations[1] = connection.Locations[1];
|
||||
}
|
||||
}
|
||||
|
||||
foreach (LocationConnection connection in connections)
|
||||
{
|
||||
connection.Locations[0].connections.Add(connection);
|
||||
connection.Locations[1].connections.Add(connection);
|
||||
}
|
||||
|
||||
for (int i = connections.Count - 1; i >= 0; i--)
|
||||
{
|
||||
LocationConnection connection = connections[i];
|
||||
|
||||
for (int n = i-1; n >= 0; n--)
|
||||
for (int n = i - 1; n >= 0; n--)
|
||||
{
|
||||
if (connection.Locations.Contains(connections[n].Locations[0])
|
||||
&& connection.Locations.Contains(connections[n].Locations[1]))
|
||||
@@ -147,6 +171,31 @@ namespace Subsurface
|
||||
int generations = (int)(Math.Sqrt(Vector2.Distance(start, end) / 10.0f));
|
||||
connection.CrackSegments = GenerateCrack(start, end, generations);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void GenerateDifficulties(Location start, List<LocationConnection> locations, float currDifficulty)
|
||||
{
|
||||
|
||||
if (start.Name.Contains("Sabbati"))
|
||||
{
|
||||
int a = 1;
|
||||
}
|
||||
//start.Difficulty = currDifficulty;
|
||||
currDifficulty += Rand.Range(difficultyIncrease.X, difficultyIncrease.Y, false);
|
||||
if (currDifficulty > Rand.Range(difficultyCutoff.X, difficultyCutoff.Y, false)) currDifficulty = 10.0f;
|
||||
|
||||
foreach (LocationConnection connection in start.connections)
|
||||
{
|
||||
if (!locations.Contains(connection)) continue;
|
||||
|
||||
Location nextLocation = connection.OtherLocation(start);
|
||||
locations.Remove(connection);
|
||||
|
||||
connection.Difficulty = currDifficulty;
|
||||
|
||||
GenerateDifficulties(nextLocation, locations, currDifficulty);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Vector2[]> GenerateCrack(Vector2 start, Vector2 end, int generations)
|
||||
@@ -170,7 +219,7 @@ namespace Subsurface
|
||||
|
||||
Vector2 normal = Vector2.Normalize(endSegment - startSegment);
|
||||
normal = new Vector2(-normal.Y, normal.X);
|
||||
midPoint += normal * Rand.Range(-offsetAmount, offsetAmount);
|
||||
midPoint += normal * Rand.Range(-offsetAmount, offsetAmount, false);
|
||||
|
||||
segments.Insert(i, new Vector2[] { startSegment, midPoint });
|
||||
segments.Insert(i+1, new Vector2[] { midPoint, endSegment });
|
||||
@@ -188,6 +237,16 @@ namespace Subsurface
|
||||
selectedLocation = null;
|
||||
}
|
||||
|
||||
public void SetLocation(int index)
|
||||
{
|
||||
if (index < 0 || index >= locations.Count)
|
||||
{
|
||||
DebugConsole.ThrowError("Location index out of bounds");
|
||||
return;
|
||||
}
|
||||
currentLocation = locations[index];
|
||||
}
|
||||
|
||||
private Location highlightedLocation;
|
||||
public void Draw(SpriteBatch spriteBatch, Rectangle rect)
|
||||
{
|
||||
@@ -217,7 +276,7 @@ namespace Subsurface
|
||||
|
||||
foreach (LocationConnection connection in connections)
|
||||
{
|
||||
Color crackColor = Color.White;
|
||||
Color crackColor = Color.Lerp(Color.LightGreen, Color.DarkRed, connection.Difficulty/100.0f);
|
||||
|
||||
if (highlightedLocation != currentLocation &&
|
||||
connection.Locations.Contains(highlightedLocation) && connection.Locations.Contains(currentLocation))
|
||||
@@ -283,7 +342,7 @@ namespace Subsurface
|
||||
pos.Y = (int)pos.Y;
|
||||
if (highlightedLocation==location)
|
||||
{
|
||||
spriteBatch.DrawString(GUI.font, location.Name, pos + new Vector2(-50, -20), Color.DarkRed);
|
||||
spriteBatch.DrawString(GUI.Font, location.Name, pos + new Vector2(-50, -20), Color.DarkRed);
|
||||
}
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X - 4, (int)pos.Y - 4, 5 + 8, 5 + 8), Color.DarkRed, false);
|
||||
}
|
||||
@@ -296,6 +355,8 @@ namespace Subsurface
|
||||
{
|
||||
private Location[] locations;
|
||||
private Level level;
|
||||
|
||||
public float Difficulty;
|
||||
|
||||
public List<Vector2[]> CrackSegments;
|
||||
|
||||
@@ -307,12 +368,30 @@ namespace Subsurface
|
||||
public Level Level
|
||||
{
|
||||
get { return level; }
|
||||
set { level = value; }
|
||||
}
|
||||
|
||||
public LocationConnection(Location location1, Location location2, Level level)
|
||||
|
||||
public LocationConnection(Location location1, Location location2)
|
||||
{
|
||||
locations = new Location[] { location1, location2 };
|
||||
this.level = level;
|
||||
//location1.connections.Add(this);
|
||||
//location2.connections.Add(this);
|
||||
}
|
||||
|
||||
public Location OtherLocation(Location location)
|
||||
{
|
||||
if (locations[0] == location)
|
||||
{
|
||||
return locations[1];
|
||||
}
|
||||
else if (locations[1] == location)
|
||||
{
|
||||
return locations[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Subsurface
|
||||
|
||||
public void DrawListLine(SpriteBatch spriteBatch, Vector2 pos, Color color)
|
||||
{
|
||||
spriteBatch.DrawString(GUI.font, name, pos, color);
|
||||
spriteBatch.DrawString(GUI.Font, name, pos, color);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -316,6 +316,8 @@ namespace Subsurface
|
||||
|
||||
public static Body PickBody(Vector2 rayStart, Vector2 rayEnd, List<Body> ignoredBodies = null)
|
||||
{
|
||||
|
||||
|
||||
float closestFraction = 1.0f;
|
||||
Body closestBody = null;
|
||||
Game1.World.RayCast((fixture, point, normal, fraction) =>
|
||||
@@ -414,7 +416,7 @@ namespace Subsurface
|
||||
Vector2 translateAmount = speed * deltaTime;
|
||||
translateAmount += ConvertUnits.ToDisplayUnits(hullBody.Position) * collisionRigidness;
|
||||
|
||||
if (targetPosition != Vector2.Zero && Vector2.Distance(targetPosition, Position) > 5.0f)
|
||||
if (targetPosition != Vector2.Zero && Vector2.Distance(targetPosition, Position) > 50.0f)
|
||||
{
|
||||
translateAmount += (targetPosition - Position) * 0.01f;
|
||||
}
|
||||
@@ -582,7 +584,7 @@ namespace Subsurface
|
||||
return;
|
||||
}
|
||||
|
||||
newTargetPosition = newTargetPosition + newSpeed * (float)(NetTime.Now - sendingTime);
|
||||
//newTargetPosition = newTargetPosition + newSpeed * (float)(NetTime.Now - sendingTime);
|
||||
|
||||
targetPosition = newTargetPosition;
|
||||
speed = newSpeed;
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Subsurface
|
||||
|
||||
Effect effect;
|
||||
|
||||
Vector2 wavePos;
|
||||
public Vector2 wavePos;
|
||||
|
||||
public WaterVertex[] vertices = new WaterVertex[DefaultBufferSize];
|
||||
|
||||
@@ -96,6 +96,11 @@ namespace Subsurface
|
||||
|
||||
vertexBuffer.SetData(verts);
|
||||
|
||||
wavePos.X += 0.0001f;
|
||||
wavePos.Y += 0.0001f;
|
||||
|
||||
effect.Parameters["xWavePos"].SetValue(wavePos);
|
||||
|
||||
effect.CurrentTechnique = effect.Techniques["WaterShader"];
|
||||
effect.Parameters["xTexture"].SetValue(texture);
|
||||
effect.Parameters["xView"].SetValue(Matrix.Identity);
|
||||
@@ -115,11 +120,7 @@ namespace Subsurface
|
||||
|
||||
vertexBuffer.SetData(vertices);
|
||||
|
||||
wavePos.X += 0.0001f;
|
||||
wavePos.Y += 0.0001f;
|
||||
|
||||
effect.Parameters["xBumpPos"].SetValue(cam.Position/Game1.GraphicsWidth/cam.Zoom);
|
||||
effect.Parameters["xWavePos"].SetValue(wavePos);
|
||||
effect.Parameters["xBumpPos"].SetValue(cam.Position / Game1.GraphicsWidth / cam.Zoom);
|
||||
|
||||
effect.CurrentTechnique = effect.Techniques["EmptyShader"];
|
||||
effect.Parameters["xTexture"].SetValue(texture);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Subsurface
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
{
|
||||
//if (!editing) return;
|
||||
if (!editing && !Game1.DebugDraw) return;
|
||||
|
||||
Point pos = new Point((int)Position.X, (int)Position.Y);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user