From 324b7f8eddef162a6f306cd093b5e3742f65c84e Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 9 Apr 2018 16:01:38 +0300 Subject: [PATCH] Fixed background fish not being rendered, added scale parameter to bg fish and made them a little smaller and faster. Closes #362 --- .../Map/Levels/BackgroundSprite/BackgroundCreature.cs | 8 ++++++-- .../BackgroundSprite/BackgroundCreaturePrefab.cs | 5 ++++- Barotrauma/BarotraumaClient/Source/Map/Levels/Level.cs | 2 +- .../BackgroundSprites/BackgroundCreaturePrefabs.xml | 10 +++++----- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Map/Levels/BackgroundSprite/BackgroundCreature.cs b/Barotrauma/BarotraumaClient/Source/Map/Levels/BackgroundSprite/BackgroundCreature.cs index b29ffb34b..a55e26770 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Levels/BackgroundSprite/BackgroundCreature.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Levels/BackgroundSprite/BackgroundCreature.cs @@ -177,8 +177,12 @@ namespace Barotrauma drawPosition -= camOffset * (depth / MaxDepth) * 0.05f; } - prefab.Sprite.Draw(spriteBatch, new Vector2(drawPosition.X, -drawPosition.Y), Color.Lerp(Color.White, Color.DarkBlue, (depth/MaxDepth)*0.3f), - rotation, 1.0f - (depth / MaxDepth) * 0.2f, velocity.X > 0.0f ? SpriteEffects.None : SpriteEffects.FlipHorizontally, (depth / MaxDepth)); + prefab.Sprite.Draw(spriteBatch, + new Vector2(drawPosition.X, -drawPosition.Y), + Color.Lerp(Color.White, Color.DarkBlue, (depth/MaxDepth)*0.3f), + rotation, (1.0f - (depth / MaxDepth) * 0.2f) * prefab.Scale, + velocity.X > 0.0f ? SpriteEffects.None : SpriteEffects.FlipHorizontally, + (depth / MaxDepth)); } } diff --git a/Barotrauma/BarotraumaClient/Source/Map/Levels/BackgroundSprite/BackgroundCreaturePrefab.cs b/Barotrauma/BarotraumaClient/Source/Map/Levels/BackgroundSprite/BackgroundCreaturePrefab.cs index 4905591a0..bdb908f32 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Levels/BackgroundSprite/BackgroundCreaturePrefab.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Levels/BackgroundSprite/BackgroundCreaturePrefab.cs @@ -4,7 +4,6 @@ namespace Barotrauma { class BackgroundCreaturePrefab { - public readonly Sprite Sprite; public readonly float Speed; @@ -18,6 +17,8 @@ namespace Barotrauma public readonly float SwarmRadius; public readonly bool DisableRotation; + + public readonly float Scale; public BackgroundCreaturePrefab(XElement element) { @@ -34,6 +35,8 @@ namespace Barotrauma DisableRotation = element.GetAttributeBool("disablerotation", false); + Scale = element.GetAttributeFloat("scale", 1.0f); + foreach (XElement subElement in element.Elements()) { if (subElement.Name.ToString().ToLowerInvariant() != "sprite") continue; diff --git a/Barotrauma/BarotraumaClient/Source/Map/Levels/Level.cs b/Barotrauma/BarotraumaClient/Source/Map/Levels/Level.cs index 541c99ee2..0fcdf9623 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Levels/Level.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Levels/Level.cs @@ -34,7 +34,7 @@ namespace Barotrauma } } - public void DrawBack(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, BackgroundCreatureManager backgroundCreatureManager = null) + public void DrawBack(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam) { float brightness = MathHelper.Clamp(1.1f + (cam.Position.Y - Size.Y) / 100000.0f, 0.1f, 1.0f); GameMain.LightManager.AmbientLight = new Color(backgroundColor * brightness, 1.0f); diff --git a/Barotrauma/BarotraumaShared/Content/BackgroundSprites/BackgroundCreaturePrefabs.xml b/Barotrauma/BarotraumaShared/Content/BackgroundSprites/BackgroundCreaturePrefabs.xml index 94744cc5d..cb6dadb55 100644 --- a/Barotrauma/BarotraumaShared/Content/BackgroundSprites/BackgroundCreaturePrefabs.xml +++ b/Barotrauma/BarotraumaShared/Content/BackgroundSprites/BackgroundCreaturePrefabs.xml @@ -1,22 +1,22 @@  - + - + - + - + - + \ No newline at end of file