Selection indication

This commit is contained in:
Simon Holmberg
2012-09-25 22:21:01 +02:00
parent 3e4d4bd5a7
commit b6218e4600
2 changed files with 21 additions and 5 deletions
+8 -4
View File
@@ -33,6 +33,7 @@ namespace DepthsBelow
public void Update(GameTime gameTime)
{
MouseState ms = Mouse.GetState();
KeyboardState ks = Keyboard.GetState();
if (ms.LeftButton == ButtonState.Pressed)
{
@@ -49,11 +50,14 @@ namespace DepthsBelow
if (ms.LeftButton == ButtonState.Released && selectionRectangle != Rectangle.Empty)
{
if (!ks.IsKeyDown(Keys.LeftControl))
core.soldier.Selected = false;
if (selectionRectangle.Intersects(core.soldier.GetComponent<Component.Collision>().Rectangle))
{
core.soldier.selected = true;
}
if (selectionRectangle.Intersects(core.soldier.GetComponent<Component.Collision>().Rectangle))
{
core.soldier.Selected = true;
}
selectionRectangle = Rectangle.Empty;
}
+13 -1
View File
@@ -13,7 +13,19 @@ namespace DepthsBelow
public class Soldier : Entity
{
Core game;
public bool selected = false;
private bool _selected;
public bool Selected
{
get
{
return _selected;
}
set
{
_selected = value;
this.GetComponent<Component.SpriteRenderer>().Color = (value) ? Color.Blue : Color.HotPink;
}
}
static Texture2D Texture;
private KeyboardState lastKeyboardState;