Round end cinematic, CoroutineManager deltatime
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
73
Subsurface/Source/Map/TransitionCinematic.cs
Normal file
73
Subsurface/Source/Map/TransitionCinematic.cs
Normal file
@@ -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<object> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user