diff --git a/DepthsBelow/DepthsBelow/Component/PathFinder.cs b/DepthsBelow/DepthsBelow/Component/PathFinder.cs index 83e7f22..1e92f77 100755 --- a/DepthsBelow/DepthsBelow/Component/PathFinder.cs +++ b/DepthsBelow/DepthsBelow/Component/PathFinder.cs @@ -157,12 +157,19 @@ namespace DepthsBelow.Component { if (collision.Solid && collision.Parent != this.Parent) { - try - { - var pos = collision.Parent.Position; - mapCollisionMap[pos.X, pos.Y] = 0; - } - catch { } + var pos = Grid.WorldToGrid(new Vector2(collision.Rectangle.X, collision.Rectangle.Y)); + + for (int x = 0; x < Math.Ceiling(collision.Rectangle.Width / (double)Grid.TileSize); x++) + for (int y = 0; y < Math.Ceiling(collision.Rectangle.Height / (double)Grid.TileSize); y++) + { + try + { + mapCollisionMap[pos.X + x, pos.Y + y] = 0; + } + catch + { + } + } } } diff --git a/DepthsBelow/DepthsBelow/Component/SpriteRenderer.cs b/DepthsBelow/DepthsBelow/Component/SpriteRenderer.cs index e612aa8..2609172 100755 --- a/DepthsBelow/DepthsBelow/Component/SpriteRenderer.cs +++ b/DepthsBelow/DepthsBelow/Component/SpriteRenderer.cs @@ -38,7 +38,7 @@ namespace DepthsBelow.Component public void Draw(SpriteBatch spriteBatch) { var transform = this.Parent.GetComponent(); - spriteBatch.Draw(Texture, transform.World.Position + new Vector2(Grid.TileSize / 2, Grid.TileSize / 2), null, Color, transform.World.Rotation, transform.World.Origin, Scale, SpriteEffects, 0); + spriteBatch.Draw(Texture, transform.World.Position + transform.World.Origin, null, Color, transform.World.Rotation, transform.World.Origin, Scale, SpriteEffects, 0); } } } diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index 4f3e788..204c4fd 100755 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -101,16 +101,24 @@ namespace DepthsBelow lightRenderTarget = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents); sceneRenderTarget = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height); - Map = Content.Load("maps/Aztek.Test"); + Map = Content.Load("maps/prototyp"); + //Map = Content.Load("maps/Aztek.Test"); //Map = Content.Load("maps/Cave.Level1"); + // Load map objects Map.ParseObjects(this); + + Squad[0].Name = "Dean H. Jones"; + Squad[1].Name = "Walter L. Verville"; + Squad[2].Name = "Patrick Y. Southerland"; + Squad[3].Name = "Andrew C. Friend"; + Squad[4].Name = "Gary B. Whitley"; + + // Center the camera on a unit + Camera.Position = Squad[0].Transform.World.Position * -1 + new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2); + GroupManager = new DynamicGroupManager(Squad.Cast().ToList(), (float)Grid.TileSize * 1.5f); - Squad[0].Name = "Dean H. Jones"; - Squad[1].Name = "Walter L. Verville"; - Squad[2].Name = "Patrick Y. Southerland"; - Squad[3].Name = "Andrew C. Friend"; - Squad[4].Name = "Gary B. Whitley"; + Interface.CreateUnitFrames(Squad); // TODO: use this.Content to load your game content here diff --git a/DepthsBelow/DepthsBelow/DepthsBelow.csproj b/DepthsBelow/DepthsBelow/DepthsBelow.csproj index ac52dfa..f9a9068 100755 --- a/DepthsBelow/DepthsBelow/DepthsBelow.csproj +++ b/DepthsBelow/DepthsBelow/DepthsBelow.csproj @@ -122,6 +122,7 @@ + diff --git a/DepthsBelow/DepthsBelow/Door.cs b/DepthsBelow/DepthsBelow/Door.cs new file mode 100755 index 0000000..24112ff --- /dev/null +++ b/DepthsBelow/DepthsBelow/Door.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using DepthsBelow.Component; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; + +namespace DepthsBelow +{ + public class Door : Entity + { + public Texture2D Texture; + + public static Texture2D TextureOpen; + public static Texture2D TextureClosed; + public static Texture2D TextureDestroyed; + + public bool Alive = true; + public bool IsOpen; + + public Door() + : base() + { + LoadContent(); + + IsOpen = false; + + var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White }; + AddComponent(rc); + + var cc = new Collision(this, Texture.Width, Texture.Height); + cc.Solid = true; + AddComponent(cc); + } + + public void LoadContent() + { + TextureOpen = GameServices.GetService().Load("images/door_open"); + TextureClosed = GameServices.GetService().Load("images/door_closed"); + TextureDestroyed = GameServices.GetService().Load("images/door_destroyed"); + + Texture = TextureClosed; + } + + public void Open() + { + if (Alive && !IsOpen) + { + IsOpen = true; + this.GetComponent().Texture = TextureOpen; + this.GetComponent().Solid = false; + } + } + + public void Close() + { + if (Alive && IsOpen) + { + IsOpen = false; + this.GetComponent().Texture = TextureClosed; + this.GetComponent().Solid = true; + } + } + + public void Toggle() + { + if (IsOpen) + Close(); + else + Open(); + } + + public void Kill() + { + Alive = false; + this.GetComponent().Texture = TextureDestroyed; + this.GetComponent().Solid = false; + } + } +} diff --git a/DepthsBelow/DepthsBelow/EntityManager.cs b/DepthsBelow/DepthsBelow/EntityManager.cs index 41cce90..ddc4b6d 100755 --- a/DepthsBelow/DepthsBelow/EntityManager.cs +++ b/DepthsBelow/DepthsBelow/EntityManager.cs @@ -74,6 +74,11 @@ namespace DepthsBelow return components; } + public static List GetEntities() where T : Entity + { + return Entities.OfType().ToList(); + } + /// /// Update all entities handled by the entity manager. /// diff --git a/DepthsBelow/DepthsBelow/KeyboardInput.cs b/DepthsBelow/DepthsBelow/KeyboardInput.cs index eac839a..c7953bf 100755 --- a/DepthsBelow/DepthsBelow/KeyboardInput.cs +++ b/DepthsBelow/DepthsBelow/KeyboardInput.cs @@ -203,10 +203,10 @@ namespace DepthsBelow }*/ core.TestMonster.X = 12; core.TestMonster.Y = 4; - } - if (ks.IsKeyDown(Keys.N)) + } + if (ks.IsKeyUp(Keys.O) && lastKeyboardState.IsKeyDown(Keys.O)) { - + EntityManager.GetEntities()[0].Toggle(); } if (ks.IsKeyDown(Keys.S) || ks.IsKeyDown(Keys.R)) { diff --git a/DepthsBelow/DepthsBelow/Map.cs b/DepthsBelow/DepthsBelow/Map.cs index 958b855..c6519b6 100755 --- a/DepthsBelow/DepthsBelow/Map.cs +++ b/DepthsBelow/DepthsBelow/Map.cs @@ -90,6 +90,14 @@ namespace DepthsBelow enemy.X = mapObjectGridPos.X; enemy.Y = mapObjectGridPos.Y; } + if (mapObject.Type == "Door") + { + var door = new Door(); + var mapObjectPos = new Vector2(mapObject.Bounds.X, mapObject.Bounds.Y); + var mapObjectGridPos = Grid.WorldToGrid(mapObjectPos); + door.X = mapObjectGridPos.X; + door.Y = mapObjectGridPos.Y; + } } } } diff --git a/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj b/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj index a7facc7..5bf067d 100755 --- a/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj +++ b/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj @@ -65,20 +65,6 @@ TextureProcessor - - - collision - TextureImporter - TextureProcessor - - - - - cave - TextureImporter - TextureProcessor - - Monster @@ -182,13 +168,6 @@ TextureProcessor - - - aztek - TextureImporter - TextureProcessor - - Aztek.Test @@ -196,13 +175,6 @@ MapProcessor - - - Cave.Level1 - TmxImporter - MapProcessor - - soldier3 @@ -238,6 +210,30 @@ TextureProcessor + + + prototyp + TmxImporter + MapProcessor + + + + + door_closed + TextureImporter + TextureProcessor + + + door_destroyed + TextureImporter + TextureProcessor + + + door_open + TextureImporter + TextureProcessor + +