diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index 42a3330..539ed61 100755 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -16,7 +16,7 @@ namespace DepthsBelow /// public class Core : Microsoft.Xna.Framework.Game { - GraphicsDeviceManager graphics; + public static GraphicsDeviceManager GraphicsDeviceManager; SpriteBatch spriteBatch; public Camera Camera; @@ -24,20 +24,22 @@ namespace DepthsBelow public static MouseInput MouseInput; public List Squad; public List Swarm; - public static Map Map; + public static Map Map; + + public SmallEnemy TestMonster; public Core() { - graphics = new GraphicsDeviceManager(this); + GraphicsDeviceManager = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; - graphics.PreferredBackBufferWidth = 1280; - graphics.PreferredBackBufferHeight = 720; - graphics.IsFullScreen = false; + GraphicsDeviceManager.PreferredBackBufferWidth = 1280; + GraphicsDeviceManager.PreferredBackBufferHeight = 720; + GraphicsDeviceManager.IsFullScreen = false; //graphics.SynchronizeWithVerticalRetrace = false; this.IsFixedTimeStep = false; - graphics.ApplyChanges(); + GraphicsDeviceManager.ApplyChanges(); this.IsMouseVisible = true; } @@ -53,7 +55,9 @@ namespace DepthsBelow // TODO: Add your initialization logic here Camera = new Camera(this); Squad = new List(); - Swarm = new List(); + Swarm = new List(); + + TestMonster = new SmallEnemy(this, ref Swarm); base.Initialize(); } @@ -142,7 +146,9 @@ namespace DepthsBelow } // Draw mouse input visuals - MouseInput.Draw(spriteBatch); + MouseInput.Draw(spriteBatch); + + TestMonster.GetComponent().Draw(spriteBatch); spriteBatch.End(); diff --git a/DepthsBelow/DepthsBelow/DepthsBelow.csproj b/DepthsBelow/DepthsBelow/DepthsBelow.csproj index 492a487..68cfd78 100644 --- a/DepthsBelow/DepthsBelow/DepthsBelow.csproj +++ b/DepthsBelow/DepthsBelow/DepthsBelow.csproj @@ -1,191 +1,192 @@ - - - - {94683C5B-052D-4143-96D8-35C67E831000} - {6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Debug - x86 - WinExe - Properties - DepthsBelow - DepthsBelow - v4.0 - Client - v4.0 - Windows - HiDef - faa0577e-a03e-43cf-89c7-0a03f4c22717 - Game - Game.ico - GameThumbnail.png - false - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 1 - 1.0.0.%2a - false - true - true - - - true - full - false - bin\x86\Debug - DEBUG;TRACE;WINDOWS - prompt - 4 - true - false - x86 - false - - - pdbonly - true - bin\x86\Release - TRACE;WINDOWS - prompt - 4 - true - false - x86 - true - - - ECE66DEF071576E8D2F7D57232C0569623E3E2DF - - - DepthsBelow_TemporaryKey.pfx - - - true - - - true - - - - False - - - False - - - False - - - False - - - False - - - False - - - False - - - False - - - False - - - False - - - False - - - - False - - - False - - - False - - - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - {CD3F949D-54AA-4D38-99DB-92905A375D84} - AStar - - - DepthsBelowContent %28Content%29 - Content - {433A77A2-DE52-4875-A4EF-232CF59C2DD3} - - - - - False - Microsoft .NET Framework 4 Client Profile %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - False - Windows Installer 3.1 - true - - - False - Microsoft XNA Framework Redistributable 4.0 - true - - - - - - - + + + + {94683C5B-052D-4143-96D8-35C67E831000} + {6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + x86 + WinExe + Properties + DepthsBelow + DepthsBelow + v4.0 + Client + v4.0 + Windows + HiDef + faa0577e-a03e-43cf-89c7-0a03f4c22717 + Game + Game.ico + GameThumbnail.png + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 1 + 1.0.0.%2a + false + true + true + + + true + full + false + bin\x86\Debug + DEBUG;TRACE;WINDOWS + prompt + 4 + true + false + x86 + false + + + pdbonly + true + bin\x86\Release + TRACE;WINDOWS + prompt + 4 + true + false + x86 + true + + + ECE66DEF071576E8D2F7D57232C0569623E3E2DF + + + DepthsBelow_TemporaryKey.pfx + + + true + + + true + + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + + False + + + False + + + False + + + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {CD3F949D-54AA-4D38-99DB-92905A375D84} + AStar + + + DepthsBelowContent %28Content%29 + Content + {433A77A2-DE52-4875-A4EF-232CF59C2DD3} + + + + + False + Microsoft .NET Framework 4 Client Profile %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 3.1 + true + + + False + Microsoft XNA Framework Redistributable 4.0 + true + + + + + + + + --> \ No newline at end of file diff --git a/DepthsBelow/DepthsBelow/MouseInput.cs b/DepthsBelow/DepthsBelow/MouseInput.cs index 29fb119..691a918 100755 --- a/DepthsBelow/DepthsBelow/MouseInput.cs +++ b/DepthsBelow/DepthsBelow/MouseInput.cs @@ -144,7 +144,7 @@ namespace DepthsBelow } else { - */unit.GetComponent().World.Rotation = (float)Math.Atan2(mouseWorldPos.Y - unit.Transform.World.Y, mouseWorldPos.X - unit.Transform.World.X);/* + */unit.GetComponent().World.Rotation = (float)Math.Atan2(mouseWorldPos.Y - unit.Transform.World.Y - unit.Transform.World.Origin.Y, mouseWorldPos.X - unit.Transform.World.X - unit.Transform.World.Origin.X);/* }*/ //Console.WriteLine(angle); //unit.GetComponent().World.Rotation = angle; @@ -170,21 +170,10 @@ namespace DepthsBelow if (checkingDirection == true) { - Texture2D blank = new Texture2D(core.GraphicsDevice, 1, 1, false, SurfaceFormat.Color); - blank.SetData(new[] { Color.White }); - DrawLine(spriteBatch, blank, 2, Color.White, directionStart, directionNow); + RenderHelpers.DrawLine(spriteBatch, Color.White, 2, directionStart, directionNow); } } - void DrawLine(SpriteBatch batch, Texture2D blank, float width, Color color, Vector2 point1, Vector2 point2) - { - float angle = (float)Math.Atan2(point2.Y - point1.Y, point2.X - point1.X); - float length = Vector2.Distance(point1, point2); - - batch.Draw(blank, point1, null, color, - angle, Vector2.Zero, new Vector2(length, width), - SpriteEffects.None, 0); - } } } diff --git a/DepthsBelow/DepthsBelow/RenderHelpers.cs b/DepthsBelow/DepthsBelow/RenderHelpers.cs new file mode 100755 index 0000000..ee8b95a --- /dev/null +++ b/DepthsBelow/DepthsBelow/RenderHelpers.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace DepthsBelow +{ + static class RenderHelpers + { + static Texture2D blank; + + public static void DrawLine(SpriteBatch batch, Color color, float width, Vector2 start, Vector2 end) + { + if (blank == null) + { + blank = new Texture2D(Core.GraphicsDeviceManager.GraphicsDevice, 1, 1, false, SurfaceFormat.Color); + blank.SetData(new[] { color }); + } + + float angle = (float)Math.Atan2(end.Y - start.Y, end.X - start.X); + float length = Vector2.Distance(start, end); + + batch.Draw(blank, start, null, color, + angle, Vector2.Zero, new Vector2(length, width), + SpriteEffects.None, 0); + } + } +}