✨
This commit is contained in:
43
Entities/EmptyDeck.cs
Normal file
43
Entities/EmptyDeck.cs
Normal file
@ -0,0 +1,43 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user