public BuyDecisionModel(BuyDecision decision, Textures textures) : base(decision, textures) { this.decision = decision; haloTexture = textures.White; OnSelected(RevealedCollection, s => { PlaySelectedCards(CollectionIdentifier.Revealed); return true; }); OnSelected(HiddenCollection, s => { PlaySelectedCards(CollectionIdentifier.Hidden); return true; }); foreach(var card in CardsInHand) { OnSelected(card, s => { var activatedCard = (Card)s; if(selectedCards.Remove(activatedCard)) { return false; } else { selectedCards.Add(activatedCard); return false; } }); } }
public SellDecisionModel(SellDecision decision, Textures textures) : base(decision, textures) { this.decision = decision; OnSelected(RevealedCollection, s => { decision.Sell(); return true; }); }
protected DecisionModel(ISpaceBeansDecision decision, Textures textures) { this.decision = decision; var trader = decision.Trader; cardsInHand = CreateCardsFromBeans(trader.BeansInHand, textures, index => LeftMargin + (CardOffsetX * (index + 1)), index => TopMargin); cardsInRevealed = CreateCardsFromBeans(trader.RevealedCollection, textures, index => LeftMargin + CardOffsetX, index => TopMargin + (CardOffsetY * (index + 2))); cardsInHidden = CreateCardsFromBeans(trader.HiddenCollection, textures, index => LeftMargin + CardOffsetX + CollectionOffsetX, index => TopMargin + (CardOffsetY * (index + 2))); deck = new RectangleSprite(new Rectangle(LeftMargin, TopMargin, CardWidth, CardHeight), textures.CardBack); revealedCollection = new CollectionSprite(new Rectangle(LeftMargin + CardOffsetX, TopMargin + CardOffsetY, CollectionWidth, CardHeight), textures.White); hiddenCollection = new CollectionSprite(new Rectangle(LeftMargin + CardOffsetX + CollectionOffsetX, TopMargin + CardOffsetY, CollectionWidth, CardHeight), textures.Black); var passableDecision = decision as PassableDecision; if(null != passableDecision && passableDecision.CanPass()) { passSprite = new RectangleSprite(new Rectangle(LeftMargin, TopMargin + CardOffsetY, CardWidth, 20), textures.Pass); OnSelected(passSprite, s => { passableDecision.Pass(); return true; }); } selectableTexture = textures.White; }
private static Texture2D GetCardColorFromBeanSuit(Bean bean, Textures textures) { switch(bean.Suit) { case Suit.Blue: return textures.Blue; case Suit.Green: return textures.Green; case Suit.Orange: return textures.Orange; case Suit.Purple: return textures.Purple; case Suit.Red: return textures.Red; case Suit.Silver: return textures.Silver; case Suit.Yellow: return textures.Yellow; default: return textures.Black; } }
/// <summary> /// Load your graphics content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be use to draw textures. spriteBatch = new SpriteBatch(graphics.GraphicsDevice); textures = new Textures(graphics.GraphicsDevice, Content); }
private static List<Card> CreateCardsFromBeans(IEnumerable<Bean> beans, Textures textures, Func<int, int> rectX, Func<int, int> rectY) { return beans.Select((bean, index) => new Card(bean, new Rectangle(rectX(index), rectY(index), CardWidth, CardHeight), textures)).ToList(); }
public Card(Bean bean, Rectangle position, Textures textures) : base(position, GetCardColorFromBeanSuit(bean, textures)) { this.bean = bean; this.digit = textures.GetDigit(bean.Rank); }