示例#1
0
        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;
                    }
                });
            }
        }
示例#2
0
        public SellDecisionModel(SellDecision decision, Textures textures)
            : base(decision, textures)
        {
            this.decision = decision;

            OnSelected(RevealedCollection, s => {
                decision.Sell();
                return true;
            });
        }
示例#3
0
 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;
 }
示例#4
0
 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;
     }
 }
示例#5
0
        /// <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);
        }
示例#6
0
 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();
 }
示例#7
0
 public Card(Bean bean, Rectangle position, Textures textures)
     : base(position, GetCardColorFromBeanSuit(bean, textures))
 {
     this.bean = bean;
     this.digit = textures.GetDigit(bean.Rank);
 }