diff --git a/.vs/Subsurface_Solution/v14/.suo b/.vs/Subsurface_Solution/v14/.suo index 33c17251c..4eb89efd5 100644 Binary files a/.vs/Subsurface_Solution/v14/.suo and b/.vs/Subsurface_Solution/v14/.suo differ diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj index b6028af16..35819c10b 100644 --- a/Subsurface/Barotrauma.csproj +++ b/Subsurface/Barotrauma.csproj @@ -121,8 +121,9 @@ - + + @@ -200,8 +201,8 @@ - - + + @@ -239,7 +240,7 @@ - + diff --git a/Subsurface/Content/Items/Weapons/railgun.xml b/Subsurface/Content/Items/Weapons/railgun.xml index 5a4579d94..449b464bd 100644 --- a/Subsurface/Content/Items/Weapons/railgun.xml +++ b/Subsurface/Content/Items/Weapons/railgun.xml @@ -6,7 +6,7 @@ linkable="true" pickdistance="150"> - + > Coroutines = new List>(); + public static float DeltaTime; + // Starting a coroutine just means adding an enumerator to the list. // You might also want to be able to stop coroutines or delete them, // which might mean putting them into a dictionary @@ -42,6 +44,8 @@ namespace Barotrauma // Updating just means stepping through all the coroutines public static void Update(float deltaTime) { + DeltaTime = deltaTime; + for (int i = Coroutines.Count-1; i>=0; i--) { if (Coroutines[i].Current != null) diff --git a/Subsurface/Source/GUI/GUI.cs b/Subsurface/Source/GUI/GUI.cs index 7fde62533..45bc4b489 100644 --- a/Subsurface/Source/GUI/GUI.cs +++ b/Subsurface/Source/GUI/GUI.cs @@ -20,12 +20,12 @@ namespace Barotrauma { public static GUIStyle Style; - static Texture2D t; + private static Texture2D t; public static SpriteFont Font, SmallFont, LargeFont; private static Sprite cursor; - private static GraphicsDevice graphicsDevice; + private static GraphicsDevice graphicsDevice; private static List messages = new List(); @@ -34,6 +34,8 @@ namespace Barotrauma private static bool pauseMenuOpen; private static GUIFrame pauseMenu; + public static Color ScreenOverlayColor; + public static void Init(ContentManager content) { GUI.Font = ToolBox.TryLoadFont("SpriteFont1", content); @@ -60,8 +62,7 @@ namespace Barotrauma // create 1x1 texture for line drawing t = new Texture2D(graphicsDevice, 1, 1); - t.SetData( - new Color[] { Color.White });// fill the texture with white + t.SetData(new Color[] { Color.White });// fill the texture with white Style = new GUIStyle("Content/UI/style.xml"); } @@ -294,6 +295,14 @@ namespace Barotrauma public static void Draw(float deltaTime, SpriteBatch spriteBatch, Camera cam) { + if (ScreenOverlayColor.A>0.0f) + { + DrawRectangle( + spriteBatch, + new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), + ScreenOverlayColor, true); + } + spriteBatch.DrawString(Font, "FPS: " + (int)GameMain.FrameCounter.AverageFramesPerSecond, new Vector2(10, 10), Color.White); diff --git a/Subsurface/Source/GameSession/GameModes/SinglePlayerMode.cs b/Subsurface/Source/GameSession/GameModes/SinglePlayerMode.cs index 46928b823..77bf3e58d 100644 --- a/Subsurface/Source/GameSession/GameModes/SinglePlayerMode.cs +++ b/Subsurface/Source/GameSession/GameModes/SinglePlayerMode.cs @@ -234,10 +234,25 @@ namespace Barotrauma private bool EndShift(GUIButton button, object obj) { - End(""); + var cinematic = new TransitionCinematic(Submarine.Loaded, GameMain.GameScreen.Cam); + + CoroutineManager.StartCoroutine(EndCinematic(cinematic)); + return true; } + private IEnumerable EndCinematic(TransitionCinematic cinematic) + { + while (cinematic.Running) + { + yield return CoroutineStatus.Running; + } + + End(""); + + yield return CoroutineStatus.Success; + } + public void Save(XElement element) { //element.Add(new XAttribute("day", day)); diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index 632c7257f..f9d3fee8a 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -87,6 +87,12 @@ namespace Barotrauma private set; } + public Body[] ShaftBodies + { + get; + private set; + } + public Level(string seed, float difficulty, int width, int height, int siteInterval) { this.seed = seed; @@ -333,14 +339,14 @@ namespace Barotrauma } + ShaftBodies = new Body[2]; for (int i = 0; i < 2; i++) { - Body shaftBody = BodyFactory.CreateRectangle(GameMain.World, 100.0f, 10.0f, 5.0f); - shaftBody.BodyType = BodyType.Kinematic; - shaftBody.CollisionCategories = Physics.CollisionLevel; - shaftBody.SetTransform(ConvertUnits.ToSimUnits((i == 0) ? startPosition : endPosition), 0.0f); - shaftBody.SleepingAllowed = false; - bodies.Add(shaftBody); + ShaftBodies[i] = BodyFactory.CreateRectangle(GameMain.World, 100.0f, 10.0f, 5.0f); + ShaftBodies[i].BodyType = BodyType.Static; + ShaftBodies[i].CollisionCategories = Physics.CollisionLevel; + ShaftBodies[i].SetTransform(ConvertUnits.ToSimUnits((i == 0) ? startPosition : endPosition), 0.0f); + bodies.Add(ShaftBodies[i]); } foreach (VoronoiCell cell in cells) diff --git a/Subsurface/Source/Map/Levels/LevelRenderer.cs b/Subsurface/Source/Map/Levels/LevelRenderer.cs index d74c6c64f..2b0105859 100644 --- a/Subsurface/Source/Map/Levels/LevelRenderer.cs +++ b/Subsurface/Source/Map/Levels/LevelRenderer.cs @@ -175,13 +175,11 @@ namespace Barotrauma basicEffect.TextureEnabled = false; basicEffect.CurrentTechnique = basicEffect.Techniques["BasicEffect_VertexColor"]; basicEffect.CurrentTechnique.Passes[0].Apply(); - - + graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(bodyVertices.VertexCount / 3.0f)); for (int side = 0; side < 2; side++) { - for (int i = 0; i < 2; i++) { graphicsDevice.SetVertexBuffer(level.WrappingWalls[side, i].BodyVertices); @@ -189,7 +187,6 @@ namespace Barotrauma graphicsDevice.DrawPrimitives( PrimitiveType.TriangleList, 0, (int)Math.Floor(level.WrappingWalls[side, i].BodyVertices.VertexCount / 3.0f)); - } } diff --git a/Subsurface/Source/Map/WaterRenderer.cs b/Subsurface/Source/Map/Levels/WaterRenderer.cs similarity index 100% rename from Subsurface/Source/Map/WaterRenderer.cs rename to Subsurface/Source/Map/Levels/WaterRenderer.cs diff --git a/Subsurface/Source/Map/Location.cs b/Subsurface/Source/Map/Map/Location.cs similarity index 100% rename from Subsurface/Source/Map/Location.cs rename to Subsurface/Source/Map/Map/Location.cs diff --git a/Subsurface/Source/Map/LocationType.cs b/Subsurface/Source/Map/Map/LocationType.cs similarity index 100% rename from Subsurface/Source/Map/LocationType.cs rename to Subsurface/Source/Map/Map/LocationType.cs diff --git a/Subsurface/Source/Map/Map.cs b/Subsurface/Source/Map/Map/Map.cs similarity index 100% rename from Subsurface/Source/Map/Map.cs rename to Subsurface/Source/Map/Map/Map.cs diff --git a/Subsurface/Source/Map/TransitionCinematic.cs b/Subsurface/Source/Map/TransitionCinematic.cs new file mode 100644 index 000000000..acd4cd5b9 --- /dev/null +++ b/Subsurface/Source/Map/TransitionCinematic.cs @@ -0,0 +1,73 @@ +using FarseerPhysics; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; + +namespace Barotrauma +{ + class TransitionCinematic + { + public bool Running + { + get; + private set; + } + + public TransitionCinematic(Submarine submarine, Camera cam) + { + Vector2 targetPos = submarine.Position; + + if (submarine.AtEndPosition) + { + targetPos = Level.Loaded.EndPosition + Vector2.UnitY * 500.0f; + } + else if (submarine.AtStartPosition) + { + targetPos = Level.Loaded.StartPosition + Vector2.UnitY * 500.0f; + } + + Running = true; + CoroutineManager.StartCoroutine(UpdateTransitionCinematic(submarine, cam, targetPos)); + } + + private IEnumerable UpdateTransitionCinematic(Submarine sub, Camera cam, Vector2 targetPos) + { + Character.Controlled = null; + GameMain.LightManager.LosEnabled = false; + + Vector2 diff = targetPos - sub.Position; + float targetSpeed = 10.0f; + + Level.Loaded.ShaftBodies[0].Enabled = false; + Level.Loaded.ShaftBodies[1].Enabled = false; + + cam.TargetPos = Vector2.Zero; + float duration = 5.0f; + float timer = 0.0f; + + while (timer < duration) + { + Vector2 cameraPos = sub.Position; + cameraPos.Y = ConvertUnits.ToDisplayUnits(Level.Loaded.ShaftBodies[0].Position.Y) - cam.WorldView.Height/2.0f; + + GUI.ScreenOverlayColor = Color.Lerp(Color.TransparentBlack, Color.Black, timer/duration); + + cam.Translate((cameraPos - cam.Position) * CoroutineManager.DeltaTime); + + cam.Zoom = Math.Max(0.2f, cam.Zoom - CoroutineManager.DeltaTime * 0.1f); + sub.ApplyForce((Vector2.Normalize(diff) * targetSpeed - sub.Velocity) * 500.0f); + + timer -= CoroutineManager.DeltaTime; + + yield return CoroutineStatus.Running; + } + + Running = false; + + yield return CoroutineStatus.Success; + } + } +} diff --git a/Subsurface/Source/Physics/Physics.cs b/Subsurface/Source/Physics/Physics.cs index 90e44be4e..2196f0d79 100644 --- a/Subsurface/Source/Physics/Physics.cs +++ b/Subsurface/Source/Physics/Physics.cs @@ -19,7 +19,7 @@ namespace Barotrauma public const Category CollisionLevel = Category.Cat7; public static double accumulator; - public static double step = 1.0f/60.0f; + public static double step = 1.0/60.0; public const float DisplayToSimRation = 100.0f; diff --git a/Subsurface/Source/Screens/LobbyScreen.cs b/Subsurface/Source/Screens/LobbyScreen.cs index 30c984d72..1e0d3d971 100644 --- a/Subsurface/Source/Screens/LobbyScreen.cs +++ b/Subsurface/Source/Screens/LobbyScreen.cs @@ -153,6 +153,8 @@ namespace Barotrauma { base.Select(); + GUI.ScreenOverlayColor = Color.Transparent; + gameMode = GameMain.GameSession.gameMode as SinglePlayerMode; foreach (GUIComponent component in topPanel.children) @@ -163,8 +165,6 @@ namespace Barotrauma button.Enabled = GameMain.GameSession.Map.CurrentLocation.Type.HasHireableCharacters; break; } - //hireButton.Enabled = location.Type.HasHireableCharacters; - UpdateCharacterLists(); } @@ -201,11 +201,7 @@ namespace Barotrauma c.Salary.ToString(), null, null, Alignment.TopRight, GUI.Style, frame); - } - } - else - { - //(topPanel.FindChild(PanelTab.CurrentLocation) as GUIButton).Enabled = false; + } } } diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index 0f3b75914..e56595e34 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -282,8 +282,8 @@ namespace Barotrauma public override void Select() { GameMain.LightManager.LosEnabled = false; - - //infoFrame.ClearChildren(); + + GUI.ScreenOverlayColor = Color.Transparent; textBox.Select(); @@ -297,8 +297,7 @@ namespace Barotrauma serverMessage.Enabled = GameMain.Server != null; autoRestartBox.Enabled = GameMain.Server != null; ServerName = (GameMain.Server==null) ? "Server" : GameMain.Server.Name; - - + infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "startButton")); infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "settingsButton")); infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "spectateButton")); diff --git a/Subsurface/Source/Sprite.cs b/Subsurface/Source/Sprite.cs index d36dec81d..1d520df66 100644 --- a/Subsurface/Source/Sprite.cs +++ b/Subsurface/Source/Sprite.cs @@ -197,13 +197,13 @@ namespace Barotrauma public void Draw(SpriteBatch spriteBatch, Vector2 pos, Color color, Vector2 origin, float rotate, Vector2 scale, SpriteEffects spriteEffect = SpriteEffects.None, float? depth = null) { - //for (int x = -1; x < 3; x+=2 ) + //for (int x = -1; x < 3; x += 2) //{ - // for (int y = -1; y < 3; y+=2 ) + // for (int y = -1; y < 3; y += 2) // { - // spriteBatch.Draw(texture, pos + offset + new Vector2(x, y)*1.0f, sourceRect, Color.Black, rotation + rotate, origin, scale, spriteEffect, (depth == null ? this.depth : (float)depth)+0.0001f); - // } + // spriteBatch.Draw(texture, pos + offset + new Vector2(x, y) * 1.0f, sourceRect, Color.Black, rotation + rotate, origin, scale, spriteEffect, (depth == null ? this.depth : (float)depth) + 0.0001f); + // } //} spriteBatch.Draw(texture, pos + offset, sourceRect, color, rotation + rotate, origin, scale, spriteEffect, depth == null ? this.depth : (float)depth);