Some visual effects when drowning or being killed by pressure

This commit is contained in:
Regalis
2016-02-19 15:00:45 +02:00
parent b49641ecb8
commit c59a2b5207
9 changed files with 66 additions and 11 deletions

View File

@@ -668,6 +668,9 @@
<Content Include="Content\Particles\flames.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\UI\noise.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\UI\uiButton.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

View File

@@ -809,7 +809,17 @@ namespace Barotrauma
if (moveCam)
{
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, Submarine == null ? 400.0f : 250.0f, 0.05f);
float pressureEffect = 0.0f;
if (pressureProtection < 80.0f && AnimController.CurrentHull != null && AnimController.CurrentHull.LethalPressure > 50.0f)
{
cam.Zoom = MathHelper.Lerp(cam.Zoom,
(AnimController.CurrentHull.LethalPressure / 50.0f) * Rand.Range(1.0f, 1.05f),
(AnimController.CurrentHull.LethalPressure - 50.0f) / 50.0f);
}
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, (Submarine == null ? 400.0f : 250.0f)+pressureEffect, 0.05f);
}
cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
@@ -939,13 +949,14 @@ namespace Barotrauma
}
if (!protectedFromPressure &&
(AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure >= 100.0f))
(AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure >= 80.0f))
{
PressureTimer += ((AnimController.CurrentHull == null) ?
100.0f : AnimController.CurrentHull.LethalPressure) * deltaTime;
if (PressureTimer >= 100.0f)
{
if (controlled == this) cam.Zoom = 5.0f;
Implode();
return;
}
@@ -1178,7 +1189,7 @@ namespace Barotrauma
}
SoundPlayer.PlayDamageSound(DamageSoundType.Implode, 50.0f, AnimController.RefLimb.body);
for (int i = 0; i < 10; i++)
{
Particle p = GameMain.ParticleManager.CreateParticle("waterblood",

View File

@@ -12,6 +12,8 @@ namespace Barotrauma
private static Sprite statusIcons;
private static Sprite noise;
private static GUIProgressBar drowningBar, healthBar;
public static void TakeDamage()
@@ -36,6 +38,11 @@ namespace Barotrauma
statusIcons = new Sprite("Content/UI/statusIcons.png", Vector2.Zero);
}
if (noise==null)
{
noise = new Sprite("Content/UI/noise.png", Vector2.Zero);
}
DrawStatusIcons(spriteBatch, character);
if (character.Inventory != null) character.Inventory.DrawOwn(spriteBatch);
@@ -89,6 +96,29 @@ namespace Barotrauma
textPos.Y += 25;
}
}
//Vector2 offset = Rand.Vector(noise.size.X);
//offset.X = Math.Abs(offset.X);
//offset.Y = Math.Abs(offset.Y);
//noise.DrawTiled(spriteBatch, Vector2.Zero - offset, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) + offset,
// Vector2.Zero,
// Color.White * 0.1f);
if (character.Oxygen < 50.0f)
{
Vector2 offset = Rand.Vector(noise.size.X);
offset.X = Math.Abs(offset.X);
offset.Y = Math.Abs(offset.Y);
noise.DrawTiled(spriteBatch, Vector2.Zero - offset, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) + offset,
Vector2.Zero,
Color.White * ((50.0f - character.Oxygen) / 50.0f));
//spriteBatch.Draw(noise.Texture,
// new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
// new Rectangle(Rand.Int(GameMain.GraphicsWidth), Rand.Int(GameMain.GraphicsHeight), (int)noise.size.X, (int)noise.size.Y),
// Color.White * ((100.0f - character.Oxygen) / 100.0f));
}
}
private static void DrawStatusIcons(SpriteBatch spriteBatch, Character character)

View File

@@ -358,6 +358,7 @@ namespace Barotrauma.Items.Components
if (linkedGap!=null) linkedGap.Remove();
doorSprite.Remove();
weldedSprite.Remove();
if (convexHull!=null) convexHull.Remove();
if (convexHull2 != null) convexHull2.Remove();

View File

@@ -64,10 +64,8 @@ namespace Barotrauma.Items.Components
{
panelTexture = Sprite.LoadTexture("Content/Items/connectionpanel.png");
connector = new Sprite(panelTexture, new Rectangle(448, 80, 64, 64), Vector2.Zero, 0.0f);
connector.Origin = new Vector2(32.0f, 32.0f);
wireCorner = new Sprite(panelTexture, new Rectangle(448, 0, 64, 64), Vector2.Zero, 0.0f);
wireCorner.Origin = new Vector2(32.0f, 32.0f);
connector = new Sprite(panelTexture, new Rectangle(448, 80, 64, 64), new Vector2(-32.0f, -32.0f), 0.0f);
wireCorner = new Sprite(panelTexture, new Rectangle(448, 0, 64, 64), new Vector2(-32.0f, -32.0f), 0.0f);
wireVertical = new Sprite(panelTexture, new Rectangle(480, 64, 16, 16), new Vector2(-8.0f, -8.0f), 0.0f);
wireHorizontal = new Sprite(panelTexture, new Rectangle(496, 64, 16, 16), new Vector2(-8.0f, -8.0f), 0.0f);
}

View File

@@ -270,7 +270,11 @@ namespace Barotrauma
fireSource.Remove();
}
if (soundIndex > -1) Sounds.SoundManager.Stop(soundIndex);
if (soundIndex > -1)
{
Sounds.SoundManager.Stop(soundIndex);
soundIndex = -1;
}
//renderer.Dispose();
@@ -344,7 +348,11 @@ namespace Barotrauma
}
else
{
if (soundIndex > -1) Sounds.SoundManager.Stop(soundIndex);
if (soundIndex > -1)
{
Sounds.SoundManager.Stop(soundIndex);
soundIndex = -1;
}
}
//update client hulls if the amount of water has changed by >10%
@@ -353,7 +361,12 @@ namespace Barotrauma
new Networking.NetworkEvent(ID, false);
lastSentVolume = volume;
}
if (!update) return;
if (!update)
{
lethalPressure = 0.0f;
return;
}
float surfaceY = rect.Y - rect.Height + Volume / rect.Width;
for (int i = 0; i < waveY.Length; i++)

View File

@@ -303,7 +303,6 @@ namespace Barotrauma
public static void PlayDamageSound(DamageSoundType damageType, float damage, PhysicsBody body)
{
Vector2 bodyPosition = body.DrawPosition;
bodyPosition.Y = -bodyPosition.Y;
PlayDamageSound(damageType, damage, bodyPosition);
}

Binary file not shown.