Example #1
0
        public void HandleInput(InputState input, GameTime gameTime)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            MouseState ms = Mouse.GetState();
            Vector2 mousePosition = new Vector2(ms.Position.X, ms.Position.Y);

            //if (preview != null)
                //preview.Update(gameTime);

            //foreach (var item in cards)
            //{
            //    item.Card = GetHoverCard(input);

            //    if (input.OnMouseOver(item.Card.Source, mousePosition))
            //    {
            //        GetSelectedCard(input);

            //        //preview = (CardViewModel)item.Clone();
            //        //preview.Show();
            //        return;
            //    }
            //    else
            //    {
            //        //if (preview != null)
            //            //preview.Hide();
            //    }
            //}

            if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Left))
            {
                drawPosition.X += 500 * elapsed;
            }
            if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Right))
            {
                drawPosition.X -= 500 * elapsed;
            }

            drawPosition.X = Vector2.Clamp(
                drawPosition,
                new Vector2(-(cards.Count - 7) * 160, drawPosition.Y),
                new Vector2(100, drawPosition.Y)).X;
        }
Example #2
0
        //Dictionary<CardViewModel, int> query = new Dictionary<CardViewModel, int>();
        //public void Add(CardViewModel card)
        //{
        //    if (cards.Count() >= Settings.MAXCARDS) return;
        //    var maxDups = (cards.Where(x => x == card).Select(x => x).Count() >= Settings.MAXDUPLICATES);
        //    if (maxDups == true) return;
        //    cards.Add(card);
        //    Sort();
        //}
        //private void Sort()
        //{
        //    query = cards.GroupBy(x => x)
        //      .Where(g => g.Count() >= 1)
        //      .OrderBy(x => x.Key.ManaCost)
        //      .ToDictionary(x => x.Key, y => y.Count());
        //}
        //public void Remove(CardViewModel card)
        //{
        //    cards.Remove(card);
        //    Sort();
        //}
        public CardViewModel GetSelectedCard(InputState input)
        {
            MouseState ms = Mouse.GetState();
            Vector2 mousePosition = new Vector2(ms.Position.X, ms.Position.Y);

            foreach (var item in cards)
            {
                if (input.OnMouseOver(item.Card.Source, mousePosition))
                {
                    if (input.CurrentCursorState.LeftButton == ButtonState.Pressed &&
                        input.LastCursorState.LeftButton == ButtonState.Released)
                    {
                        return item;
                    }
                }
            }

            return null;
        }
Example #3
0
        public CardViewModel GetHoverCard(InputState input)
        {
            MouseState ms = Mouse.GetState();
            Vector2 mousePosition = new Vector2(ms.Position.X, ms.Position.Y);

            foreach (var item in cards)
            {
                if (input.OnMouseOver(item.Card.Source, mousePosition))
                {
                    return item;

                }
            }

            return null;
        }
Example #4
0
        //private void Sort()
        //{
        //    query = cards.GroupBy(x => x)
        //      .Where(g => g.Count() >= 1)
        //      .OrderBy(x => x.Key.ManaCost)
        //      .ToDictionary(x => x.Key, y => y.Count());
        //}
        //public void Remove(CardViewModel card)
        //{
        //    cards.Remove(card);
        //    Sort();
        //}
        public void HandleInput(InputState input, GameTime gameTime)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            MouseState ms = Mouse.GetState();
            Vector2 mousePosition = new Vector2(ms.Position.X, ms.Position.Y);

            //if (preview != null)
            //    preview.Update(gameTime);

            if (view != null)
            {
                int index = 0;
                foreach (var items in view)
                {
                    //if (input.OnMouseOver(items.Card.Source, mousePosition))
                    //{
                    //    preview = new CardPreview(items);
                    //    preview.Show();
                    //}
                    //else
                    //{
                    //    if (preview != null)
                    //        preview.Hide();
                    //}

                    index++;
                }
            }

            //if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Left))
            //{
            //    drawPosition.X += 500 * elapsed;
            //}
            //if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Right))
            //{
            //    drawPosition.X -= 500 * elapsed;
            //}

            //if (view != null)
            //{
            //    drawPosition.X = Vector2.Clamp(
            //        drawPosition,
            //        new Vector2(-(view.Count - 7) * 160, drawPosition.Y),
            //        new Vector2(100, drawPosition.Y)).X;
            //}
        }
Example #5
0
 /// <summary>
 /// Allows the screen to handle user input. Unlike Update, this method
 /// is only called when the screen is active, and not when some other
 /// screen has taken the focus.
 /// </summary>
 public virtual void HandleInput(GameTime gameTime, InputState input)
 {
 }
Example #6
0
        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);
        }