Selection indication
This commit is contained in:
@@ -33,6 +33,7 @@ namespace DepthsBelow
|
|||||||
public void Update(GameTime gameTime)
|
public void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
MouseState ms = Mouse.GetState();
|
MouseState ms = Mouse.GetState();
|
||||||
|
KeyboardState ks = Keyboard.GetState();
|
||||||
|
|
||||||
if (ms.LeftButton == ButtonState.Pressed)
|
if (ms.LeftButton == ButtonState.Pressed)
|
||||||
{
|
{
|
||||||
@@ -49,11 +50,14 @@ namespace DepthsBelow
|
|||||||
|
|
||||||
if (ms.LeftButton == ButtonState.Released && selectionRectangle != Rectangle.Empty)
|
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;
|
selectionRectangle = Rectangle.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,19 @@ namespace DepthsBelow
|
|||||||
public class Soldier : Entity
|
public class Soldier : Entity
|
||||||
{
|
{
|
||||||
Core game;
|
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;
|
static Texture2D Texture;
|
||||||
|
|
||||||
private KeyboardState lastKeyboardState;
|
private KeyboardState lastKeyboardState;
|
||||||
|
|||||||
Reference in New Issue
Block a user