diff --git a/DepthsBelow/DepthsBelow/Component/Collision.cs b/DepthsBelow/DepthsBelow/Component/Collision.cs index e01eb29..d8f1180 100644 --- a/DepthsBelow/DepthsBelow/Component/Collision.cs +++ b/DepthsBelow/DepthsBelow/Component/Collision.cs @@ -6,7 +6,7 @@ using Microsoft.Xna.Framework; namespace DepthsBelow.Component { - class Collision : Component + public class Collision : Component { public Rectangle Rectangle; diff --git a/DepthsBelow/DepthsBelow/Component/Component.cs b/DepthsBelow/DepthsBelow/Component/Component.cs index 9efe208..3af72dd 100644 --- a/DepthsBelow/DepthsBelow/Component/Component.cs +++ b/DepthsBelow/DepthsBelow/Component/Component.cs @@ -1,17 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace DepthsBelow.Component -{ - public class Component - { - public Entity Parent; - - public Component(Entity parent) - { - Parent = parent; - } - } -} +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/Entity.cs b/DepthsBelow/DepthsBelow/Entity.cs index d29b9c2..9f19c31 100644 --- a/DepthsBelow/DepthsBelow/Entity.cs +++ b/DepthsBelow/DepthsBelow/Entity.cs @@ -1,41 +1,47 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -namespace DepthsBelow -{ - public class Entity - { - List Components; - public Component.PixelTransform pixelTransform; - public Component.GridTransform gridTransform; - public Component.Collision collision; - - public Entity() - { - Components = new List(); - pixelTransform = new Component.PixelTransform(this); - AddComponent(pixelTransform); - gridTransform = new Component.GridTransform(this); - AddComponent(gridTransform); - collision = new Component.Collision(this, 32, 32); - AddComponent(collision); - } - - 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); - } - } -} +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/Soldier.cs b/DepthsBelow/DepthsBelow/Soldier.cs index cc253c9..12bd430 100644 --- a/DepthsBelow/DepthsBelow/Soldier.cs +++ b/DepthsBelow/DepthsBelow/Soldier.cs @@ -10,7 +10,7 @@ using Microsoft.Xna.Framework.Media; namespace DepthsBelow { - class Soldier : Entity + public class Soldier : Entity { Core game; bool selected = false; @@ -32,10 +32,14 @@ namespace DepthsBelow rc.Texture = Texture; rc.Color = Color.HotPink; this.AddComponent(rc); + + Component.Collision cc = new Component.Collision(this, 32, 32); + this.AddComponent(cc); } - public void Update(GameTime gameTime) + 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;