Added Collision component
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace DepthsBelow.Component
|
||||
{
|
||||
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<PixelTransform>();
|
||||
this.Rectangle.X = (int)pt.X;
|
||||
this.Rectangle.Y = (int)pt.Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace DepthsBelow
|
||||
graphics.PreferredBackBufferHeight = 720;
|
||||
graphics.IsFullScreen = false;
|
||||
|
||||
graphics.SynchronizeWithVerticalRetrace = false;
|
||||
//graphics.SynchronizeWithVerticalRetrace = false;
|
||||
this.IsFixedTimeStep = false;
|
||||
graphics.ApplyChanges();
|
||||
|
||||
|
||||
@@ -121,6 +121,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Camera.cs" />
|
||||
<Compile Include="Component\Collision.cs" />
|
||||
<Compile Include="Component\Component.cs" />
|
||||
<Compile Include="Component\GridTransform.cs" />
|
||||
<Compile Include="Core.cs" />
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace DepthsBelow
|
||||
List<Component.Component> Components;
|
||||
public Component.PixelTransform pixelTransform;
|
||||
public Component.GridTransform gridTransform;
|
||||
public Component.Collision collision;
|
||||
|
||||
public Entity()
|
||||
{
|
||||
@@ -17,6 +18,8 @@ namespace DepthsBelow
|
||||
AddComponent(pixelTransform);
|
||||
gridTransform = new Component.GridTransform(this);
|
||||
AddComponent(gridTransform);
|
||||
collision = new Component.Collision(this, 32, 32);
|
||||
AddComponent(collision);
|
||||
}
|
||||
|
||||
public T GetComponent<T>() where T : Component.Component
|
||||
|
||||
@@ -49,6 +49,10 @@ namespace DepthsBelow
|
||||
|
||||
if (ms.LeftButton == ButtonState.Released && selectionRectangle != Rectangle.Empty)
|
||||
{
|
||||
/*if (selectionRectangle.Intersects())
|
||||
{
|
||||
|
||||
}*/
|
||||
selectionRectangle = Rectangle.Empty;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace DepthsBelow
|
||||
class Soldier : Entity
|
||||
{
|
||||
Core game;
|
||||
bool selected = false;
|
||||
static Texture2D Texture;
|
||||
|
||||
private KeyboardState lastKeyboardState;
|
||||
|
||||
Reference in New Issue
Block a user