public void Add(CardViewModel value) { if (view.Count() >= Settings.MAXCARDS) return; //var duplicateKeys = view.GroupBy(x => x) // .Where(group => group.Count() > 3) // .Select(group => group.Key).Count() >= Settings.MAXDUPLICATES; //var maxDups = (view.Where(x => x == view).Select(x => x).Count() >= Settings.MAXDUPLICATES); //if (duplicateKeys == true) return; view.Add(value); }
//public void Load(ContentManager content) //{ // if (view != null) // { // foreach (var items in view) // { // var value = new CardViewModel(items.Card); // value.LoadContent(content); // } // } //} public void Draw(SpriteBatch spriteBatch, SpriteFont spriteFont) { //if (preview != null) // preview.Draw(spriteBatch, spriteFont); int i = 0; if (view != null) { foreach (var items in view) { var value = new CardViewModel(items.Card); value.Card.Position = new Vector2(drawPosition.X, drawPosition.Y + (i * 50)); value.Card.Source = new Rectangle((int)value.Card.Position.X, (int)value.Card.Position.Y, 100, 50); DrawCard(spriteBatch, spriteFont, value.Card); Vector2 countPosition = new Vector2(value.Card.Source.Right - value.Card.costPreview.Width / 2, value.Card.Source.Top - value.Card.costPreview.Height / 2); //TextureContent.DrawText(spriteBatch, spriteFont, view.Sum(list => list.Count()) + " / " + Settings.MAXCARDS.ToString(), Color.Black, Color.White, 1.0f, new Vector2(drawPosition.X + 50, drawPosition.Y - 50)); i++; } } }
public CardPreview(CardViewModel item) { this.item = item; }
public override void HandleInput(GameTime gameTime, InputState input) { cardView.HandleInput(input, gameTime); //deckView.HandleInput(input, gameTime); if (preview != null) preview.Update(gameTime, true, true); CardViewModel hoverView = cardView.GetHoverCard(input); if (hoverView != null) { ScreenManager.Game.Window.Title = hoverView.Name.ToString(); preview = (CardViewModel)hoverView.Clone(); preview.Show(); } else { if(preview != null) preview.Hide(); } //CardViewModel selectedView = cardView.GetSelectedCard(input); //if (selectedView != null) //{ // //deckView.Add(selectedView); //} if (preview != null) preview.Update(gameTime, true, true); //MouseState ms = Mouse.GetState(); //Vector2 mousePosition = new Vector2(ms.Position.X, ms.Position.Y); //cardView.HandleInput(input, gameTime); //for (int index = 0; index < cardView.Count(); index++) //{ // CardViewModel view = cardView[index]; // view.Update(gameTime, true, true); // if (input.OnMouseOver(view.Card, mousePosition)) // { // preview = (CardViewModel)view.Clone(); // preview.isVisible = true; // if (input.CurrentCursorState.LeftButton == ButtonState.Pressed && // input.LastCursorState.LeftButton == ButtonState.Released) // { // cardView.Add(view); // return; // } // } // else // { // if (preview != null) // preview.isVisible = false; // } //} base.HandleInput(gameTime, input); }