diff --git a/DepthsBelow/DepthsBelow/Component/Collision.cs b/DepthsBelow/DepthsBelow/Component/Collision.cs index d8f1180..4123c1b 100644 --- a/DepthsBelow/DepthsBelow/Component/Collision.cs +++ b/DepthsBelow/DepthsBelow/Component/Collision.cs @@ -1,31 +1,31 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.Xna.Framework; - -namespace DepthsBelow.Component -{ - public class Collision : Component - { - - public Rectangle Rectangle; - - public int Width; - public int Height; - - public Collision(Entity parent, int width, int height) - : base(parent) - { - this.Width = width; - this.Height = height; - this.Rectangle = new Rectangle(0, 0, width, height); - } - public void Update(GameTime gameTime) - { - PixelTransform pt = this.Parent.GetComponent(); - this.Rectangle.X = (int)pt.X; - this.Rectangle.Y = (int)pt.Y; - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; + +namespace DepthsBelow.Component +{ + public class Collision : Component + { + + public Rectangle Rectangle; + + public int Width; + public int Height; + + public Collision(Entity parent, int width, int height) + : base(parent) + { + this.Width = width; + this.Height = height; + this.Rectangle = new Rectangle(0, 0, width, height); + } + public void Update(GameTime gameTime) + { + PixelTransform pt = this.Parent.GetComponent(); + this.Rectangle.X = (int)pt.X; + this.Rectangle.Y = (int)pt.Y; + } + } +} diff --git a/DepthsBelow/DepthsBelow/Component/Collision.cs.orig b/DepthsBelow/DepthsBelow/Component/Collision.cs.orig new file mode 100644 index 0000000..ac6bd86 --- /dev/null +++ b/DepthsBelow/DepthsBelow/Component/Collision.cs.orig @@ -0,0 +1,65 @@ +<<<<<<< HEAD +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; + +namespace DepthsBelow.Component +{ + public class Collision : Component + { + + public Rectangle Rectangle; + + public int Width; + public int Height; + + public Collision(Entity parent, int width, int height) + : base(parent) + { + this.Width = width; + this.Height = height; + this.Rectangle = new Rectangle(0, 0, width, height); + } + public void Update(GameTime gameTime) + { + PixelTransform pt = this.Parent.GetComponent(); + this.Rectangle.X = (int)pt.X; + this.Rectangle.Y = (int)pt.Y; + } + } +} +======= +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; + +namespace DepthsBelow.Component +{ + public class Collision : Component + { + + public Rectangle Rectangle; + + public int Width; + public int Height; + + public Collision(Entity parent, int width, int height) + : base(parent) + { + this.Width = width; + this.Height = height; + this.Rectangle = new Rectangle(0, 0, width, height); + } + public void Update(GameTime gameTime) + { + PixelTransform pt = this.Parent.GetComponent(); + this.Rectangle.X = (int)pt.X; + this.Rectangle.Y = (int)pt.Y; + } + } +} +>>>>>>> Made Soldier Public and Made MouseInput Collision diff --git a/DepthsBelow/DepthsBelow/Component/Component.cs b/DepthsBelow/DepthsBelow/Component/Component.cs index 3af72dd..1b5b935 100644 --- a/DepthsBelow/DepthsBelow/Component/Component.cs +++ b/DepthsBelow/DepthsBelow/Component/Component.cs @@ -1,23 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.Xna.Framework; - -namespace DepthsBelow.Component -{ - public class Component - { - public Entity Parent; - - public Component(Entity parent) - { - Parent = parent; - } - - public virtual void Update(GameTime gameTime) - { - - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; + +namespace DepthsBelow.Component +{ + public class Component + { + public Entity Parent; + + public Component(Entity parent) + { + Parent = parent; + } + + public virtual void Update(GameTime gameTime) + { + + } + } +} diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index fdc3d44..d5f15a4 100644 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -21,7 +21,7 @@ namespace DepthsBelow public Camera camera; MouseInput mouse; - Soldier soldier; + public Soldier soldier; public Core() { diff --git a/DepthsBelow/DepthsBelow/DepthsBelow.csproj.user b/DepthsBelow/DepthsBelow/DepthsBelow.csproj.user index 43ea7bc..9c62ad0 100644 --- a/DepthsBelow/DepthsBelow/DepthsBelow.csproj.user +++ b/DepthsBelow/DepthsBelow/DepthsBelow.csproj.user @@ -1,16 +1,16 @@ - - - - publish\ - - - - - - en-US - false - - - false - + + + + publish\ + + + + + + en-US + false + + + false + \ No newline at end of file diff --git a/DepthsBelow/DepthsBelow/Entity.cs b/DepthsBelow/DepthsBelow/Entity.cs index 9f19c31..e68e706 100644 --- a/DepthsBelow/DepthsBelow/Entity.cs +++ b/DepthsBelow/DepthsBelow/Entity.cs @@ -1,47 +1,47 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.Xna.Framework; - -namespace DepthsBelow -{ - public class Entity - { - List Components; - public Component.PixelTransform pixelTransform; - public Component.GridTransform gridTransform; - - public Entity() - { - Components = new List(); - pixelTransform = new Component.PixelTransform(this); - AddComponent(pixelTransform); - gridTransform = new Component.GridTransform(this); - AddComponent(gridTransform); - } - - public T GetComponent() where T : Component.Component - { - foreach (Component.Component c in Components) - { - if (c is T) - return (T)c; - } - - return null; - } - - public void AddComponent(Component.Component c) - { - Components.Add(c); - } - - public virtual void Update(GameTime gameTime) - { - // Update components - foreach (Component.Component c in Components) - c.Update(gameTime); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; + +namespace DepthsBelow +{ + public class Entity + { + List Components; + public Component.PixelTransform pixelTransform; + public Component.GridTransform gridTransform; + + public Entity() + { + Components = new List(); + pixelTransform = new Component.PixelTransform(this); + AddComponent(pixelTransform); + gridTransform = new Component.GridTransform(this); + AddComponent(gridTransform); + } + + public T GetComponent() where T : Component.Component + { + foreach (Component.Component c in Components) + { + if (c is T) + return (T)c; + } + + return null; + } + + public void AddComponent(Component.Component c) + { + Components.Add(c); + } + + public virtual void Update(GameTime gameTime) + { + // Update components + foreach (Component.Component c in Components) + c.Update(gameTime); + } + } +} diff --git a/DepthsBelow/DepthsBelow/MouseInput.cs b/DepthsBelow/DepthsBelow/MouseInput.cs index f88abb2..104c3b3 100644 --- a/DepthsBelow/DepthsBelow/MouseInput.cs +++ b/DepthsBelow/DepthsBelow/MouseInput.cs @@ -49,10 +49,10 @@ namespace DepthsBelow if (ms.LeftButton == ButtonState.Released && selectionRectangle != Rectangle.Empty) { - /*if (selectionRectangle.Intersects()) + if (selectionRectangle.Intersects(core.soldier.collision.Rectangle)) { - - }*/ + core.soldier.selected = true; + } selectionRectangle = Rectangle.Empty; } diff --git a/DepthsBelow/DepthsBelow/Program.cs b/DepthsBelow/DepthsBelow/Program.cs index f016b28..557401d 100644 --- a/DepthsBelow/DepthsBelow/Program.cs +++ b/DepthsBelow/DepthsBelow/Program.cs @@ -1,21 +1,21 @@ -using System; - -namespace DepthsBelow -{ -#if WINDOWS || XBOX - static class Program - { - /// - /// The main entry point for the application. - /// - static void Main(string[] args) - { - using (Core game = new Core()) - { - game.Run(); - } - } - } -#endif -} - +using System; + +namespace DepthsBelow +{ +#if WINDOWS || XBOX + static class Program + { + /// + /// The main entry point for the application. + /// + static void Main(string[] args) + { + using (Core game = new Core()) + { + game.Run(); + } + } + } +#endif +} + diff --git a/DepthsBelow/DepthsBelow/Soldier.cs b/DepthsBelow/DepthsBelow/Soldier.cs index 12bd430..b949fb2 100644 --- a/DepthsBelow/DepthsBelow/Soldier.cs +++ b/DepthsBelow/DepthsBelow/Soldier.cs @@ -1,54 +1,54 @@ -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 Soldier : Entity - { - Core game; - bool selected = false; - static Texture2D Texture; - - private KeyboardState lastKeyboardState; - - static public void LoadContent(Core game) - { - Texture = game.Content.Load("images/soldier"); - } - - public Soldier(Core game) - { - if (Texture == null) - LoadContent(game); - - Component.SpriteRenderer rc = new Component.SpriteRenderer(this); - rc.Texture = Texture; - rc.Color = Color.HotPink; - this.AddComponent(rc); - - Component.Collision cc = new Component.Collision(this, 32, 32); - this.AddComponent(cc); - } - - public override void Update(GameTime gameTime) - { - base.Update(gameTime); - /*KeyboardState ks = Keyboard.GetState(); - if (ks.IsKeyDown(Keys.Right) && lastKeyboardState.IsKeyUp(Keys.Right)) - gridTransform.Position.X += 1; - lastKeyboardState = ks;*/ - - if (pixelTransform.Position.X < gridTransform.X * 32) - { - pixelTransform.Position.X += 2; - } - } - } -} +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 Soldier : Entity + { + Core game; + public bool selected = false; + static Texture2D Texture; + + private KeyboardState lastKeyboardState; + + static public void LoadContent(Core game) + { + Texture = game.Content.Load("images/soldier"); + } + + public Soldier(Core game) + { + if (Texture == null) + LoadContent(game); + + Component.SpriteRenderer rc = new Component.SpriteRenderer(this); + rc.Texture = Texture; + rc.Color = Color.HotPink; + this.AddComponent(rc); + + Component.Collision cc = new Component.Collision(this, 32, 32); + this.AddComponent(cc); + } + + public override void Update(GameTime gameTime) + { + base.Update(gameTime); + /*KeyboardState ks = Keyboard.GetState(); + if (ks.IsKeyDown(Keys.Right) && lastKeyboardState.IsKeyUp(Keys.Right)) + gridTransform.Position.X += 1; + lastKeyboardState = ks;*/ + + if (pixelTransform.Position.X < gridTransform.X * 32) + { + pixelTransform.Position.X += 2; + } + } + } +} diff --git a/DepthsBelow/DepthsBelow/Soldier.cs.orig b/DepthsBelow/DepthsBelow/Soldier.cs.orig new file mode 100644 index 0000000..d1dc31a --- /dev/null +++ b/DepthsBelow/DepthsBelow/Soldier.cs.orig @@ -0,0 +1,50 @@ +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 Soldier : Entity + { + Core game; + public bool selected = false; + static Texture2D Texture; + + private KeyboardState lastKeyboardState; + + static public void LoadContent(Core game) + { + Texture = game.Content.Load("images/soldier"); + } + + public Soldier(Core game) + { + if (Texture == null) + LoadContent(game); + + Component.SpriteRenderer rc = new Component.SpriteRenderer(this); + rc.Texture = Texture; + rc.Color = Color.HotPink; + this.AddComponent(rc); + } + + public void Update(GameTime gameTime) + { + /*KeyboardState ks = Keyboard.GetState(); + if (ks.IsKeyDown(Keys.Right) && lastKeyboardState.IsKeyUp(Keys.Right)) + gridTransform.Position.X += 1; + lastKeyboardState = ks;*/ + + if (pixelTransform.Position.X < gridTransform.X * 32) + { + pixelTransform.Position.X += 2; + } + } + } +} diff --git a/README.md b/README.md index d7d134c..6039a59 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -DepthsBelow +DepthsBelow =========== \ No newline at end of file