Implemented the changes of the new camera.

This commit is contained in:
Harrison Deng 2019-02-06 00:12:08 -06:00
parent e0858ad85d
commit 3c7e6cdefb
5 changed files with 13 additions and 11 deletions

View File

@ -51,6 +51,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Camera\Camera.cs" />
<Compile Include="Camera\Camera2D.cs" /> <Compile Include="Camera\Camera2D.cs" />
<Compile Include="ContentSystem\ContentData.cs" /> <Compile Include="ContentSystem\ContentData.cs" />
<Compile Include="ContentSystem\ContentManagerController.cs" /> <Compile Include="ContentSystem\ContentManagerController.cs" />

View File

@ -34,11 +34,11 @@ namespace RecrownedAthenaeum.Render
{ {
this.graphicsDevice = graphicsDevice ?? (Configuration.GraphicsDeviceManager.GraphicsDevice); this.graphicsDevice = graphicsDevice ?? (Configuration.GraphicsDeviceManager.GraphicsDevice);
camera = camera ?? (Configuration.Camera2D); camera = camera ?? (Configuration.Camera2D);
basicEffect = new BasicEffect(this.graphicsDevice); basicEffect = new BasicEffect(this.graphicsDevice);
basicEffect.VertexColorEnabled = true; basicEffect.VertexColorEnabled = true;
basicEffect.View = camera.Matrix; basicEffect.Projection = camera.projectionMatrix;
basicEffect.View = camera.ViewMatrix;
basicEffect.World = Matrix.Identity;
vertices = new List<VertexPositionColor>(verticesPerBatch); vertices = new List<VertexPositionColor>(verticesPerBatch);
} }
@ -69,9 +69,9 @@ namespace RecrownedAthenaeum.Render
public void End() public void End()
{ {
if (disposed) throw new ObjectDisposedException(this.GetType().Name); if (disposed) throw new ObjectDisposedException(this.GetType().Name);
if (!began) throw new InvalidOperationException("Begin must be called before ending."); if (!began) throw new InvalidOperationException("Begin must be called before ending.");
Flush(); Flush();
began = false;
} }
/// <summary> /// <summary>
@ -95,7 +95,7 @@ namespace RecrownedAthenaeum.Render
} }
} }
vertices.Add(new VertexPositionColor(new Vector3(vertex, 0), color)); vertices.Add(new VertexPositionColor(new Vector3(vertex, 0), color));
bufferPosition = vertices.Count; bufferPosition++;
} }
/// <summary> /// <summary>
@ -108,6 +108,7 @@ namespace RecrownedAthenaeum.Render
if (bufferPosition == 0) return; if (bufferPosition == 0) return;
graphicsDevice.DrawUserPrimitives(primitiveType, vertices.ToArray(), 0, bufferPosition / verticesPerPrimitive); graphicsDevice.DrawUserPrimitives(primitiveType, vertices.ToArray(), 0, bufferPosition / verticesPerPrimitive);
vertices.Clear();
bufferPosition = 0; bufferPosition = 0;
} }

View File

@ -129,13 +129,13 @@ namespace RecrownedAthenaeum.ScreenSystem
{ {
graphics.GraphicsDevice.SetRenderTarget(previousScreenRenderTarget); graphics.GraphicsDevice.SetRenderTarget(previousScreenRenderTarget);
graphics.GraphicsDevice.Clear(previousScreen.BackgroundColor); graphics.GraphicsDevice.Clear(previousScreen.BackgroundColor);
spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.Matrix); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.TransformationMatrix);
previousScreen.Draw(spriteBatch); previousScreen.Draw(spriteBatch);
spriteBatch.End(); spriteBatch.End();
graphics.GraphicsDevice.SetRenderTarget(null); graphics.GraphicsDevice.SetRenderTarget(null);
Screen.UpdatePreviousScreenFrame(previousScreenRenderTarget); Screen.UpdatePreviousScreenFrame(previousScreenRenderTarget);
} }
spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.Matrix); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.TransformationMatrix);
Screen.Draw(spriteBatch); Screen.Draw(spriteBatch);
spriteBatch.End(); spriteBatch.End();
} }

View File

@ -131,8 +131,8 @@ namespace RecrownedAthenaeum.UI.BookSystem
public void GoToPage(Page page) public void GoToPage(Page page)
{ {
Rectangle targetBounds = page.bounds; Rectangle targetBounds = page.bounds;
camera.Position.X = targetBounds.X + (targetBounds.Width * 0.5f); camera.position.X = targetBounds.X + (targetBounds.Width * 0.5f);
camera.Position.Y = targetBounds.Y + (targetBounds.Height * 0.5f); camera.position.Y = targetBounds.Y + (targetBounds.Height * 0.5f);
} }
} }
} }

View File

@ -48,7 +48,7 @@ namespace RecrownedAthenaeum.UI.Modular
if (scissorBounds != null) if (scissorBounds != null)
{ {
batch.End(); batch.End();
batch.Begin(SpriteSortMode.Deferred, null, null, null, scissorRasterizer, null, camera?.Matrix); batch.Begin(SpriteSortMode.Deferred, null, null, null, scissorRasterizer, null, camera?.TransformationMatrix);
scissorBounds.Width = bounds.Width; scissorBounds.Width = bounds.Width;
scissorBounds.Height = bounds.Height; scissorBounds.Height = bounds.Height;
scissorBounds.X = bounds.X; scissorBounds.X = bounds.X;
@ -72,7 +72,7 @@ namespace RecrownedAthenaeum.UI.Modular
{ {
batch.GraphicsDevice.ScissorRectangle = scissorBounds; batch.GraphicsDevice.ScissorRectangle = scissorBounds;
batch.End(); batch.End();
batch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera?.Matrix); batch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera?.TransformationMatrix);
} }
} }