- fixed level generation algorithm placing waypoints at unreachable positions

- changes to drowning/suffocation logic (oxygen-value drops/rises at a fixed rate depending on whether there's enough oxygen available, instead of effects "stacking")
This commit is contained in:
Regalis
2016-03-09 16:57:11 +02:00
parent a1c728d207
commit 6deab579a1
6 changed files with 49 additions and 60 deletions
@@ -41,10 +41,10 @@
<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="Character" ObstructVision="true" setvalue="true" disabledeltatime="true"/> <StatusEffect type="OnWearing" target="Character" ObstructVision="true" setvalue="true" disabledeltatime="true"/>
<StatusEffect type="OnWearing" target="Contained,Character" Oxygen="20.0" Condition="-0.5"> <StatusEffect type="OnWearing" target="Contained,Character" OxygenAvailable="1000.0" Condition="-0.5">
<RequiredItem type="Contained" name="Oxygen Tank"/> <RequiredItem type="Contained" name="Oxygen Tank"/>
</StatusEffect> </StatusEffect>
<StatusEffect type="OnWearing" target="Contained,Character" Oxygen="-30.0" Condition="-0.5"> <StatusEffect type="OnWearing" target="Contained,Character" OxygenAvailable="-100.0" Oxygen="-20.0" Condition="-0.5">
<RequiredItem type="Contained" name="Welding Fuel Tank"/> <RequiredItem type="Contained" name="Welding Fuel Tank"/>
</StatusEffect> </StatusEffect>
</Wearable> </Wearable>
@@ -86,10 +86,13 @@
<sprite texture="DivingSuit.png" limb="LeftLeg" sourcerect="17,47,21,51" origin="0.5,0.55" depth="0.02" hidelimb="true"/> <sprite texture="DivingSuit.png" limb="LeftLeg" sourcerect="17,47,21,51" origin="0.5,0.55" depth="0.02" hidelimb="true"/>
<StatusEffect type="OnWearing" target="Character" ObstructVision="true" PressureProtection="100.0" SpeedMultiplier="0.6" LowPassMultiplier="0.2" setvalue="true" disabledeltatime="true"/> <StatusEffect type="OnWearing" target="Character" ObstructVision="true" PressureProtection="100.0" SpeedMultiplier="0.6" LowPassMultiplier="0.2" setvalue="true" disabledeltatime="true"/>
<StatusEffect type="OnWearing" target="Contained,Character" Oxygen="30.0" Condition="-0.5"> <StatusEffect type="OnWearing" target="Contained,Character" OxygenAvailable="1000.0" Condition="-0.5">
<RequiredItem type="Contained" name="Oxygen Tank"/> <RequiredItem type="Contained" name="Oxygen Tank"/>
</StatusEffect> </StatusEffect>
<StatusEffect type="OnWearing" target="Character" Oxygen="-11.0"/> <StatusEffect type="OnWearing" target="Contained,Character" Oxygen="-20.0" Condition="-0.5">
<RequiredItem type="Contained" name="Welding Fuel Tank"/>
</StatusEffect>
<StatusEffect type="OnWearing" target="Character" OxygenAvailable="-100.0"/>
</Wearable> </Wearable>
<ItemContainer capacity="1" hideitems="true"> <ItemContainer capacity="1" hideitems="true">
+18 -11
View File
@@ -81,7 +81,7 @@ namespace Barotrauma
private Vector2 cursorPosition; private Vector2 cursorPosition;
protected bool needsAir; protected bool needsAir;
protected float oxygen; protected float oxygen, oxygenAvailable;
protected float drowningTime; protected float drowningTime;
protected float health; protected float health;
@@ -251,6 +251,12 @@ namespace Barotrauma
} }
} }
public float OxygenAvailable
{
get { return oxygenAvailable; }
set { oxygenAvailable = MathHelper.Clamp(value, 0.0f, 100.0f); }
}
public float Stun public float Stun
{ {
get { return AnimController.StunTimer; } get { return AnimController.StunTimer; }
@@ -416,6 +422,7 @@ namespace Barotrauma
IsNetworkPlayer = isNetworkPlayer; IsNetworkPlayer = isNetworkPlayer;
oxygen = 100.0f; oxygen = 100.0f;
oxygenAvailable = 100.0f;
aiTarget = new AITarget(this); aiTarget = new AITarget(this);
lowPassMultiplier = 1.0f; lowPassMultiplier = 1.0f;
@@ -1027,20 +1034,20 @@ namespace Barotrauma
if (needsAir) if (needsAir)
{ {
if (AnimController.HeadInWater) Oxygen += deltaTime * (oxygenAvailable < 30.0f ? -5.0f : 10.0f);
{
Oxygen -= deltaTime*100.0f / drowningTime;
}
else if (AnimController.CurrentHull != null)
{
float hullOxygen = AnimController.CurrentHull.OxygenPercentage;
hullOxygen -= 30.0f;
Oxygen += deltaTime * 100.0f * (hullOxygen / 500.0f); PressureProtection -= deltaTime*100.0f;
float hullAvailableOxygen = 0.0f;
if (!AnimController.HeadInWater && AnimController.CurrentHull != null)
{
hullAvailableOxygen = AnimController.CurrentHull.OxygenPercentage;
AnimController.CurrentHull.Oxygen -= Hull.OxygenConsumptionSpeed * deltaTime; AnimController.CurrentHull.Oxygen -= Hull.OxygenConsumptionSpeed * deltaTime;
} }
PressureProtection -= deltaTime*100.0f;
OxygenAvailable += Math.Sign(hullAvailableOxygen - oxygenAvailable) * deltaTime * 50.0f;
} }
Health -= bleeding * deltaTime; Health -= bleeding * deltaTime;
+2 -2
View File
@@ -98,7 +98,7 @@ namespace Barotrauma
if (Screen.Selected == GameMain.EditMapScreen) return; if (Screen.Selected == GameMain.EditMapScreen) return;
if (character.Oxygen < 50.0f && !character.IsDead) if (character.Oxygen < 80.0f && !character.IsDead)
{ {
Vector2 offset = Rand.Vector(noiseOverlay.size.X); Vector2 offset = Rand.Vector(noiseOverlay.size.X);
offset.X = Math.Abs(offset.X); offset.X = Math.Abs(offset.X);
@@ -106,7 +106,7 @@ namespace Barotrauma
noiseOverlay.DrawTiled(spriteBatch, Vector2.Zero - offset, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) + offset, noiseOverlay.DrawTiled(spriteBatch, Vector2.Zero - offset, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) + offset,
Vector2.Zero, Vector2.Zero,
Color.White * ((50.0f - character.Oxygen) / 50.0f)); Color.White * Math.Min((80.0f - character.Oxygen) / 50.0f, 0.8f));
} }
if (damageOverlayTimer>0.0f) if (damageOverlayTimer>0.0f)
+19 -42
View File
@@ -200,22 +200,19 @@ namespace Barotrauma
float tunnelLength = Rand.Range(5000.0f, 10000.0f, false); float tunnelLength = Rand.Range(5000.0f, 10000.0f, false);
var tunnelNodes = MathUtils.GenerateJaggedLine(tunnelStartPos, tunnelStartPos + Rand.Vector(tunnelLength,false) + Vector2.UnitY*5000.0f, 3, 1000.0f); var tunnelNodes = MathUtils.GenerateJaggedLine(
tunnelStartPos,
new Vector2(tunnelStartPos.X, pathBorders.Bottom)+Rand.Vector(tunnelLength,false),
4, 1000.0f);
List<Vector2> tunnel = new List<Vector2>(); List<Vector2> tunnel = new List<Vector2>();
foreach (Vector2[] tunnelNode in tunnelNodes) foreach (Vector2[] tunnelNode in tunnelNodes)
{ {
if (!pathBorders.Contains(tunnelNode[0])) break; if (!pathBorders.Contains(tunnelNode[0])) continue;
tunnel.Add(tunnelNode[0]); tunnel.Add(tunnelNode[0]);
} }
if (tunnel.Any()) if (tunnel.Any()) smallTunnels.Add(tunnel);
{
smallTunnels.Add(tunnel);
positionsOfInterest.Add(new InterestingPosition(tunnel.Last(), false));
if (tunnel.Count() > 4) positionsOfInterest.Add(new InterestingPosition(tunnel[tunnel.Count()/2], false));
}
} }
@@ -229,9 +226,9 @@ namespace Barotrauma
if (smallTunnels.Any(t => t.Any(node => Vector2.Distance(node, site) < siteInterval))) if (smallTunnels.Any(t => t.Any(node => Vector2.Distance(node, site) < siteInterval)))
{ {
if (x < borders.Width - siteInterval) sites.Add(new Vector2(x, y) + Vector2.UnitX * siteInterval * 0.2f); if (x < borders.Width - siteInterval) sites.Add(new Vector2(x, y) + Vector2.UnitX * siteInterval * 0.5f);
if (y < borders.Height - siteInterval) sites.Add(new Vector2(x, y) + Vector2.UnitY * siteInterval * 0.2f); if (y < borders.Height - siteInterval) sites.Add(new Vector2(x, y) + Vector2.UnitY * siteInterval * 0.5f);
if (x < borders.Width - siteInterval && y < borders.Height - siteInterval) sites.Add(new Vector2(x, y) + Vector2.One * siteInterval * 0.2f); if (x < borders.Width - siteInterval && y < borders.Height - siteInterval) sites.Add(new Vector2(x, y) + Vector2.One * siteInterval * 0.5f);
} }
if (mirror) site.X = borders.Width - site.X; if (mirror) site.X = borders.Width - site.X;
@@ -314,42 +311,22 @@ namespace Barotrauma
{ {
if (tunnel.Count<2) continue; if (tunnel.Count<2) continue;
//find the cell which the path starts from
int startCellIndex = FindCellIndex(tunnel[0]);
if (startCellIndex < 0) continue;
//if it wasn't one of the cells in the main path, don't create a tunnel
if (!pathCells.Contains(cells[startCellIndex])) continue;
var newPathCells = GeneratePath(tunnel, cells, pathBorders, 0.0f, 0.0f); var newPathCells = GeneratePath(tunnel, cells, pathBorders, 0.0f, 0.0f);
//for (int n = 0; n < newPathCells.Count; n += 5) positionsOfInterest.Add(new InterestingPosition(tunnel.Last(), false));
//{
// positionsOfInterest.Add(newPathCells[n].Center); if (tunnel.Count() > 4) positionsOfInterest.Add(new InterestingPosition(tunnel[tunnel.Count() / 2], false));
//}
pathCells.AddRange(newPathCells); pathCells.AddRange(newPathCells);
} }
////generate a couple of random paths
//for (int i = 0; i <= Rand.Range(1,4,false); i++)
//{
// //pathBorders = new Rectangle(
// //borders.X + siteInterval * 2, borders.Y - siteInterval * 2,
// //borders.Right - siteInterval * 2, borders.Y + borders.Height - siteInterval * 2);
// Vector2 start = pathCells[Rand.Range(1, pathCells.Count - 2,false)].Center;
// float x = pathBorders.X + Rand.Range(0, pathBorders.Right - pathBorders.X, false);
// float y = pathBorders.Y + Rand.Range(0,pathBorders.Bottom - pathBorders.Y, false);
// if (mirror) x = borders.Width - x;
// Vector2 end = new Vector2(x, y);
// var newPathCells = GeneratePath(new List<Vector2> { start, end }, cells, pathBorders, 0.0f, 0.8f, mirror);
// for (int n = 0; n < newPathCells.Count; n += 5)
// {
// positionsOfInterest.Add(newPathCells[n].Center);
// }
// pathCells.AddRange(newPathCells);
//}
Debug.WriteLine("path: " + sw2.ElapsedMilliseconds + " ms"); Debug.WriteLine("path: " + sw2.ElapsedMilliseconds + " ms");
sw2.Restart(); sw2.Restart();
@@ -152,6 +152,8 @@ namespace Voronoi2
ge.point1 = vertices[i-1]; ge.point1 = vertices[i-1];
ge.point2 = vertices[i]; ge.point2 = vertices[i];
System.Diagnostics.Debug.Assert(ge.point1 != ge.point2);
edges.Add(ge); edges.Add(ge);
} }
+1 -1
View File
@@ -39,7 +39,7 @@ namespace Barotrauma.Lights
{ {
lights = new List<LightSource>(); lights = new List<LightSource>();
AmbientLight = new Color(80, 80, 80, 255); AmbientLight = new Color(60, 60, 60, 255);
visionCircle = Sprite.LoadTexture("Content/Lights/visioncircle.png"); visionCircle = Sprite.LoadTexture("Content/Lights/visioncircle.png");