diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index 415469c..42a3330 100755 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -1,140 +1,152 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Audio; -using Microsoft.Xna.Framework.Content; -using Microsoft.Xna.Framework.GamerServices; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using Microsoft.Xna.Framework.Media; - -namespace DepthsBelow -{ - /// - /// This is the main type for your game - /// - public class Core : Microsoft.Xna.Framework.Game - { - GraphicsDeviceManager graphics; - SpriteBatch spriteBatch; - - public Camera Camera; - - public static MouseInput MouseInput; - public List Squad; - public static Map Map; - - public Core() - { - graphics = new GraphicsDeviceManager(this); - Content.RootDirectory = "Content"; - - graphics.PreferredBackBufferWidth = 1280; - graphics.PreferredBackBufferHeight = 720; - graphics.IsFullScreen = false; - - //graphics.SynchronizeWithVerticalRetrace = false; - this.IsFixedTimeStep = false; - graphics.ApplyChanges(); - - this.IsMouseVisible = true; - } - - /// - /// Allows the game to perform any initialization it needs to before starting to run. - /// This is where it can query for any required services and load any non-graphic - /// related content. Calling base.Initialize will enumerate through any components - /// and initialize them as well. - /// - protected override void Initialize() - { - // TODO: Add your initialization logic here - Camera = new Camera(this); - Squad = new List(); - - base.Initialize(); - } - - /// - /// LoadContent will be called once per game and is the place to load - /// all of your content. - /// - protected override void LoadContent() - { - // Create a new SpriteBatch, which can be used to draw textures. - spriteBatch = new SpriteBatch(GraphicsDevice); - - Map = Content.Load("maps/Cave.Level1"); - // Load map objects - Map.ParseObjects(this); - - // TODO: use this.Content to load your game content here - Soldier.LoadContent(this); - - MouseInput = new MouseInput(this); - MouseInput.LoadContent(); - } - - /// - /// UnloadContent will be called once per game and is the place to unload - /// all content. - /// - protected override void UnloadContent() - { - // TODO: Unload any non ContentManager content here - } - - /// - /// Allows the game to run logic such as updating the world, - /// checking for collisions, gathering input, and playing audio. - /// - /// Provides a snapshot of timing values. - protected override void Update(GameTime gameTime) - { - // Allows the game to exit - if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) - this.Exit(); - - Camera.Update(gameTime); - MouseInput.Update(gameTime); - - // Update soldiers in squad - foreach (var soldier in Squad) - soldier.Update(gameTime); - - base.Update(gameTime); - } - - /// - /// This is called when the game should draw itself. - /// - /// Provides a snapshot of timing values. - protected override void Draw(GameTime gameTime) - { - GraphicsDevice.Clear(Color.Black); - - // Start drawing using the Camera transform - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, - Camera.Transform); - - // Draw the level - Map.Draw(spriteBatch); - - // Draw units - foreach (var soldier in Squad) - { - var sr = soldier.GetComponent(); - if (sr != null) - sr.Draw(spriteBatch); - } - - // Draw mouse input visuals - MouseInput.Draw(spriteBatch); - - spriteBatch.End(); - - base.Draw(gameTime); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Audio; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.GamerServices; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using Microsoft.Xna.Framework.Media; + +namespace DepthsBelow +{ + /// + /// This is the main type for your game + /// + public class Core : Microsoft.Xna.Framework.Game + { + GraphicsDeviceManager graphics; + SpriteBatch spriteBatch; + + public Camera Camera; + + public static MouseInput MouseInput; + public List Squad; + public List Swarm; + public static Map Map; + + public Core() + { + graphics = new GraphicsDeviceManager(this); + Content.RootDirectory = "Content"; + + graphics.PreferredBackBufferWidth = 1280; + graphics.PreferredBackBufferHeight = 720; + graphics.IsFullScreen = false; + + //graphics.SynchronizeWithVerticalRetrace = false; + this.IsFixedTimeStep = false; + graphics.ApplyChanges(); + + this.IsMouseVisible = true; + } + + /// + /// Allows the game to perform any initialization it needs to before starting to run. + /// This is where it can query for any required services and load any non-graphic + /// related content. Calling base.Initialize will enumerate through any components + /// and initialize them as well. + /// + protected override void Initialize() + { + // TODO: Add your initialization logic here + Camera = new Camera(this); + Squad = new List(); + Swarm = new List(); + + base.Initialize(); + } + + /// + /// LoadContent will be called once per game and is the place to load + /// all of your content. + /// + protected override void LoadContent() + { + // Create a new SpriteBatch, which can be used to draw textures. + spriteBatch = new SpriteBatch(GraphicsDevice); + + Map = Content.Load("maps/Cave.Level1"); + // Load map objects + Map.ParseObjects(this); + + // TODO: use this.Content to load your game content here + Soldier.LoadContent(this); + SmallEnemy.LoadContent(this); + + MouseInput = new MouseInput(this); + MouseInput.LoadContent(); + } + + /// + /// UnloadContent will be called once per game and is the place to unload + /// all content. + /// + protected override void UnloadContent() + { + // TODO: Unload any non ContentManager content here + } + + /// + /// Allows the game to run logic such as updating the world, + /// checking for collisions, gathering input, and playing audio. + /// + /// Provides a snapshot of timing values. + protected override void Update(GameTime gameTime) + { + // Allows the game to exit + if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) + this.Exit(); + + Camera.Update(gameTime); + MouseInput.Update(gameTime); + + // Update soldiers in squad + foreach (var soldier in Squad) + soldier.Update(gameTime); + + foreach (var body in Swarm) + body.Update(gameTime); + + base.Update(gameTime); + } + + /// + /// This is called when the game should draw itself. + /// + /// Provides a snapshot of timing values. + protected override void Draw(GameTime gameTime) + { + GraphicsDevice.Clear(Color.Black); + + // Start drawing using the Camera transform + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, + Camera.Transform); + + // Draw the level + Map.Draw(spriteBatch); + + // Draw units + foreach (var soldier in Squad) + { + var sr = soldier.GetComponent(); + if (sr != null) + sr.Draw(spriteBatch); + } + foreach (var body in Swarm) + { + var sr = body.GetComponent(); + if (sr != null) + sr.Draw(spriteBatch); + } + + // Draw mouse input visuals + MouseInput.Draw(spriteBatch); + + spriteBatch.End(); + + base.Draw(gameTime); + } + } +} diff --git a/DepthsBelow/DepthsBelow/DepthsBelow.csproj b/DepthsBelow/DepthsBelow/DepthsBelow.csproj index fe80598..492a487 100644 --- a/DepthsBelow/DepthsBelow/DepthsBelow.csproj +++ b/DepthsBelow/DepthsBelow/DepthsBelow.csproj @@ -1,196 +1,197 @@ - - - - {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 18af796..29fb119 100755 --- a/DepthsBelow/DepthsBelow/MouseInput.cs +++ b/DepthsBelow/DepthsBelow/MouseInput.cs @@ -1,169 +1,190 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Content; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using Microsoft.Xna.Framework.Media; - -namespace DepthsBelow -{ - public class MouseInput - { - Core core; - MouseState lastMouseState; - Rectangle selectionRectangle; - Texture2D selectionTexture; - Rectangle gridRectangle; - Texture2D gridTexture; - - Vector2 directionStart; - Vector2 directionNow; - - bool checkingDirection = false; - - - public MouseInput(Core core) - { - this.core = core; - - selectionRectangle = Rectangle.Empty; - gridRectangle = Rectangle.Empty; - } - - - public void LoadContent() - { - selectionTexture = new Texture2D(core.GraphicsDevice, 1, 1); - selectionTexture.SetData(new Color[] { Color.White }); - - gridTexture = new Texture2D(core.GraphicsDevice, 1, 1); - gridTexture.SetData(new Color[] { Color.White }); - } - - public void Update(GameTime gameTime) - { - MouseState ms = Mouse.GetState(); - Vector2 mouseWorldPos = core.Camera.ScreenToWorld(new Vector2(ms.X, ms.Y)); - KeyboardState ks = Keyboard.GetState(); - - // Selection rectangle - if (ms.LeftButton == ButtonState.Pressed) - { - if (selectionRectangle == Rectangle.Empty) - { - selectionRectangle = new Rectangle((int)mouseWorldPos.X, (int)mouseWorldPos.Y, 0, 0); - } - else - { - selectionRectangle.Width = (int)mouseWorldPos.X - selectionRectangle.X; - selectionRectangle.Height = (int)mouseWorldPos.Y - selectionRectangle.Y; - } - } - // When the mouse is released - if (ms.LeftButton == ButtonState.Released && selectionRectangle != Rectangle.Empty) - { - // Deselect all units - if (!ks.IsKeyDown(Keys.LeftControl)) - { - foreach (var unit in core.Squad) - unit.Selected = false; - } - - // Select all units in the rectangle - foreach (var unit in core.Squad) - { - if (selectionRectangle.Intersects(unit.GetComponent().Rectangle)) - unit.Selected = true; - } - - // Hide the selection rectangle - selectionRectangle = Rectangle.Empty; - } - - // Send orders with right click - if (ms.RightButton == ButtonState.Released && lastMouseState.RightButton == ButtonState.Pressed) - { - foreach (var unit in core.Squad) - if (unit.Selected) - { - unit.GetComponent().Goal = Grid.WorldToGrid(mouseWorldPos); - } - - } - if (ms.RightButton == ButtonState.Pressed) - { - foreach (var unit in core.Squad) - { - if (unit.Selected && gridRectangle.Intersects(unit.GetComponent().Rectangle)) - { - checkingDirection = true; - directionStart = unit.Transform.World + unit.Transform.World.Origin; - } - } - } - if (checkingDirection == true && ms.RightButton == ButtonState.Pressed) - { - foreach (var unit in core.Squad) - if (unit.Selected) - { - directionNow.X = mouseWorldPos.X; - directionNow.Y = mouseWorldPos.Y; - float directionX = mouseWorldPos.X - unit.Transform.World.X; - float directionY = mouseWorldPos.Y - unit.Transform.World.Y; - var mouseDirection = mouseWorldPos; - mouseDirection.Normalize(); - //float angle = (float)Math.Acos(Vector2.Dot(new Vector2(0, 1), mouseDirection)) * MathHelper.TwoPi; - /*if (directionX < 0) - { - directionX *= -1; - unit.GetComponent().World.Rotation = (float)Math.Atan(directionY / directionX); - } - else - { - */unit.GetComponent().World.Rotation = (float)Math.Atan2(mouseWorldPos.Y - unit.Transform.World.Y, mouseWorldPos.X - unit.Transform.World.X);/* - }*/ - //Console.WriteLine(angle); - //unit.GetComponent().World.Rotation = angle; - } - } - else - { - checkingDirection = false; - } - - // Grid highlighting - Point mouseGridPos = Grid.WorldToGrid(mouseWorldPos); - Vector2 rectWorldPos = Grid.GridToWorld(mouseGridPos); - gridRectangle = new Rectangle((int)rectWorldPos.X, (int)rectWorldPos.Y, Grid.TileSize, Grid.TileSize); - - lastMouseState = ms; - } - - public void Draw(SpriteBatch spriteBatch) - { - spriteBatch.Draw(selectionTexture, selectionRectangle, Color.Red * 0.5f); - spriteBatch.Draw(gridTexture, gridRectangle, Color.Yellow * 0.3f); - - 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); - } - - } - - 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); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using Microsoft.Xna.Framework.Media; + +namespace DepthsBelow +{ + public class MouseInput + { + Core core; + MouseState lastMouseState; + Rectangle selectionRectangle; + Texture2D selectionTexture; + Rectangle gridRectangle; + Texture2D gridTexture; + + Vector2 directionStart; + Vector2 directionNow; + + bool checkingDirection = false; + bool readjust = false; + + + public MouseInput(Core core) + { + this.core = core; + + selectionRectangle = Rectangle.Empty; + gridRectangle = Rectangle.Empty; + } + + + public void LoadContent() + { + selectionTexture = new Texture2D(core.GraphicsDevice, 1, 1); + selectionTexture.SetData(new Color[] { Color.White }); + + gridTexture = new Texture2D(core.GraphicsDevice, 1, 1); + gridTexture.SetData(new Color[] { Color.White }); + } + + public void Update(GameTime gameTime) + { + MouseState ms = Mouse.GetState(); + Vector2 mouseWorldPos = core.Camera.ScreenToWorld(new Vector2(ms.X, ms.Y)); + KeyboardState ks = Keyboard.GetState(); + + // Selection rectangle + if (ms.LeftButton == ButtonState.Pressed) + { + + if (selectionRectangle == Rectangle.Empty) + { + directionStart = mouseWorldPos; + selectionRectangle = new Rectangle((int)mouseWorldPos.X, (int)mouseWorldPos.Y, 0, 0); + readjust = false; + } + else + { + if (mouseWorldPos.X > directionStart.X && mouseWorldPos.Y < directionStart.Y || mouseWorldPos.X < directionStart.X && mouseWorldPos.Y > directionStart.Y) + { + int rectangleX = (int)mouseWorldPos.X - ((int)mouseWorldPos.X - (int)directionStart.X); + int rectangleY = (int)mouseWorldPos.Y; + int rectangleWidth = (int)mouseWorldPos.X - (int)directionStart.X; + int rectangleHeight = (int)directionStart.Y - (int)mouseWorldPos.Y; + selectionRectangle = new Rectangle(rectangleX, rectangleY, rectangleWidth, rectangleHeight); + readjust = true; + } + else + { + if (readjust == true) + { + selectionRectangle = new Rectangle((int)directionStart.X, (int)directionStart.Y, 0, 0); + } + selectionRectangle.Width = (int)mouseWorldPos.X - selectionRectangle.X; + selectionRectangle.Height = (int)mouseWorldPos.Y - selectionRectangle.Y; + readjust = false; + } + } + } + // When the mouse is released + if (ms.LeftButton == ButtonState.Released && selectionRectangle != Rectangle.Empty) + { + // Deselect all units + if (!ks.IsKeyDown(Keys.LeftControl)) + { + foreach (var unit in core.Squad) + unit.Selected = false; + } + + // Select all units in the rectangle + foreach (var unit in core.Squad) + { + if (selectionRectangle.Intersects(unit.GetComponent().Rectangle)) + unit.Selected = true; + } + + // Hide the selection rectangle + selectionRectangle = Rectangle.Empty; + } + + // Send orders with right click + if (ms.RightButton == ButtonState.Released && lastMouseState.RightButton == ButtonState.Pressed) + { + foreach (var unit in core.Squad) + if (unit.Selected) + { + unit.GetComponent().Goal = Grid.WorldToGrid(mouseWorldPos); + } + + } + if (ms.RightButton == ButtonState.Pressed) + { + foreach (var unit in core.Squad) + { + if (unit.Selected && gridRectangle.Intersects(unit.GetComponent().Rectangle)) + { + checkingDirection = true; + directionStart = unit.Transform.World + unit.Transform.World.Origin; + } + } + } + if (checkingDirection == true && ms.RightButton == ButtonState.Pressed) + { + foreach (var unit in core.Squad) + if (unit.Selected) + { + directionNow.X = mouseWorldPos.X; + directionNow.Y = mouseWorldPos.Y; + float directionX = mouseWorldPos.X - unit.Transform.World.X; + float directionY = mouseWorldPos.Y - unit.Transform.World.Y; + var mouseDirection = mouseWorldPos; + mouseDirection.Normalize(); + //float angle = (float)Math.Acos(Vector2.Dot(new Vector2(0, 1), mouseDirection)) * MathHelper.TwoPi; + /*if (directionX < 0) + { + directionX *= -1; + unit.GetComponent().World.Rotation = (float)Math.Atan(directionY / directionX); + } + else + { + */unit.GetComponent().World.Rotation = (float)Math.Atan2(mouseWorldPos.Y - unit.Transform.World.Y, mouseWorldPos.X - unit.Transform.World.X);/* + }*/ + //Console.WriteLine(angle); + //unit.GetComponent().World.Rotation = angle; + } + } + else + { + checkingDirection = false; + } + + // Grid highlighting + Point mouseGridPos = Grid.WorldToGrid(mouseWorldPos); + Vector2 rectWorldPos = Grid.GridToWorld(mouseGridPos); + gridRectangle = new Rectangle((int)rectWorldPos.X, (int)rectWorldPos.Y, Grid.TileSize, Grid.TileSize); + + lastMouseState = ms; + } + + public void Draw(SpriteBatch spriteBatch) + { + spriteBatch.Draw(selectionTexture, selectionRectangle, Color.Red * 0.5f); + spriteBatch.Draw(gridTexture, gridRectangle, Color.Yellow * 0.3f); + + 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); + } + + } + + 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/SmallEnemy.cs b/DepthsBelow/DepthsBelow/SmallEnemy.cs new file mode 100644 index 0000000..03b5313 --- /dev/null +++ b/DepthsBelow/DepthsBelow/SmallEnemy.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using DepthsBelow.Component; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; + +namespace DepthsBelow +{ + public class SmallEnemy : Entity + { + public static Texture2D Texture; + public Color Color; + public static Point Origin; + private bool _selected; //I guess as in "currently doing something" + + public List Swarm; + + private PathFinder.Node nextNode; + + public SmallEnemy(Core core, ref List swarm) + : base(core) + { + if (Texture == null) + LoadContent(core); + + this.Swarm = swarm; + + Transform.World.Origin = new Vector2(16, 16); + + this.Color = Color.White; + var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White }; + AddComponent(rc); + + var cc = new Collision(this, 32, 32); + AddComponent(cc); + + var pfc = new PathFinder(this); + AddComponent(pfc); + } + + public bool Selected + { + get { return _selected; } + set + { + _selected = value; + GetComponent().Color = (value) ? Color.Blue : this.Color; + } + } + + public static void LoadContent(Core core) + { + Texture = core.Content.Load("images/Monster"); + } + + public override void Update(GameTime gameTime) + { + base.Update(gameTime); + + float elapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f; + + if (nextNode == null) + nextNode = GetComponent().Next(); + + if (nextNode != null) + { + List soldierCollisions = new List(); + + foreach (var body in Swarm) + { + if (body != this) + { + if (body.Transform.Grid == nextNode.Position) + { + soldierCollisions.Add(body.Transform.Grid); + GetComponent().RecreatePath(soldierCollisions); + nextNode = GetComponent().Next(); + break; + } + } + } + + + + if (nextNode != null) + { + var nodeWorldPos = Grid.GridToWorld(nextNode.Position); + // HACK: Make this work properly with other speeds... + float speed = 4f; + if (Transform.World.X < nodeWorldPos.X) + Transform.World.X += speed; + if (Transform.World.X > nodeWorldPos.X) + Transform.World.X -= speed; + if (Transform.World.Y < nodeWorldPos.Y) + Transform.World.Y += speed; + if (Transform.World.Y > nodeWorldPos.Y) + Transform.World.Y -= speed; + + if (Transform.World == nodeWorldPos) + nextNode = GetComponent().Next(); + } + + } + + /**/ + } + } +} \ No newline at end of file diff --git a/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj b/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj index 3a6f708..a009837 100644 --- a/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj +++ b/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj @@ -1,110 +1,117 @@ - - - - {433A77A2-DE52-4875-A4EF-232CF59C2DD3} - {96E2B04D-8817-42c6-938A-82C39BA4D311};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Debug - x86 - Library - Properties - v4.0 - v4.0 - bin\$(Platform)\$(Configuration) - Content - - - x86 - - - x86 - - - DepthsBelowContent - - - - False - - - False - - - False - - - False - - - False - - - False - - - - - soldier - TextureImporter - TextureProcessor - - - test - TmxImporter - MapProcessor - - - - - {EC3F6988-459C-4783-89E9-F34C0CC731C7} - TiledLib - - - {D054E3A6-7E05-4255-984F-69FE40D9137F} - DepthsBelowContentPipeline - - - - - aztek - TextureImporter - TextureProcessor - - - - - soldier2 - TextureImporter - TextureProcessor - - - - - collision - TextureImporter - TextureProcessor - - - - - Cave.Level1 - MapProcessor - TmxImporter - Designer - - - - - cave - TextureImporter - TextureProcessor - - - - + + + + {433A77A2-DE52-4875-A4EF-232CF59C2DD3} + {96E2B04D-8817-42c6-938A-82C39BA4D311};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + x86 + Library + Properties + v4.0 + v4.0 + bin\$(Platform)\$(Configuration) + Content + + + x86 + + + x86 + + + DepthsBelowContent + + + + False + + + False + + + False + + + False + + + False + + + False + + + + + soldier + TextureImporter + TextureProcessor + + + test + TmxImporter + MapProcessor + + + + + {EC3F6988-459C-4783-89E9-F34C0CC731C7} + TiledLib + + + {D054E3A6-7E05-4255-984F-69FE40D9137F} + DepthsBelowContentPipeline + + + + + aztek + TextureImporter + TextureProcessor + + + + + soldier2 + TextureImporter + TextureProcessor + + + + + collision + TextureImporter + TextureProcessor + + + + + Cave.Level1 + MapProcessor + TmxImporter + Designer + + + + + cave + TextureImporter + TextureProcessor + + + + + Monster + TextureImporter + TextureProcessor + + + + \ No newline at end of file diff --git a/DepthsBelow/DepthsBelowContent/images/Monster.png b/DepthsBelow/DepthsBelowContent/images/Monster.png new file mode 100644 index 0000000..371c75f Binary files /dev/null and b/DepthsBelow/DepthsBelowContent/images/Monster.png differ