43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using Microsoft.Xna.Framework;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Solitaire.Entities {
|
|
public class EmptyDeck: CardPosition {
|
|
public bool Selected;
|
|
|
|
public EmptyDeck(Vector2 position): base(position) {
|
|
|
|
}
|
|
|
|
private bool inRectangle(Vector2 point, Rectangle rectangle) {
|
|
return (
|
|
point.X >= rectangle.Left &&
|
|
point.X <= rectangle.Right &&
|
|
point.Y > rectangle.Top &&
|
|
point.Y < rectangle.Bottom
|
|
);
|
|
}
|
|
|
|
public void SetSelected(Vector2 mPosition, bool mHolding) {
|
|
int height = 48;
|
|
|
|
Rectangle spritePosition = new Rectangle(
|
|
(int)Position.X, (int)Position.Y, 32, height
|
|
);
|
|
if (child == null && inRectangle(mPosition, spritePosition) && !mHolding) {
|
|
Selected = true;
|
|
} else if ((!inRectangle(mPosition, spritePosition) && Selected) || child != null) {
|
|
Selected = false;
|
|
}
|
|
}
|
|
|
|
public override void Update(GameTime gameTime, Vector2 mPosition, bool mReleased, bool mHolding, List<IGameEntity> entities) {
|
|
SetSelected(mPosition, mHolding);
|
|
|
|
if (Selected && mReleased) {
|
|
SolitaireGame.logic.FlipDeck();
|
|
}
|
|
}
|
|
|
|
}
|
|
} |