Ejemplo n.º 1
0
        private void onReleaseItem()
        {
            if (BuildDeckList.Select(i => i.count).Sum() >= 30)
            {
                //最多30张牌
                return;
            }
            var deckItem = BuildDeckList.getItems().FirstOrDefault(i => i.card == DragCard.BuildDeckListItem.card);

            if (deckItem != null)
            {
                deckItem.count++;
                deckItem.getChild("Root").display();
                deckItem.rectTransform.sizeDelta = BuildDeckList.defaultItem.rectTransform.sizeDelta;
            }
            else
            {
                var newItem = BuildDeckList.addItem();
                newItem.update(DragCard.BuildDeckListItem.card, parent.game.cards.GetCardSkin(DragCard.BuildDeckListItem.card.id), 1);
            }
            BuildDeckList.sortItems((a, b) =>
            {
                if (a.card.getCost() != b.card.getCost())
                {
                    return(a.card.getCost() - b.card.getCost());
                }
                else
                {
                    return(a.card.id - b.card.id);
                }
            });
        }
Ejemplo n.º 2
0
        private void Update()
        {
            DeckCountText.text = BuildDeckList.getItems().Select(i => i.count).Sum() + "/30";

            //if (DragCard.isDisplaying)
            //{
            //    var input = EventSystem.current.currentInputModule.input;
            //    DragCard.transform.position = input.mousePosition;
            //    Vector2 position = input.mousePosition;
            //    if (DeckViewScroll.GetComponent<RectTransform>().rect.Contains(DeckViewScroll.GetComponent<RectTransform>().InverseTransformPoint(position)))
            //    {
            //        if (!DragCard.BuildDeckListItem.isDisplaying)
            //        {
            //            DragCard.BuildDeckListItem.display();
            //            DragCard.BuildDeckListItem.update(DragCard.BuildDeckListItem.card, parent.game.cards.GetCardSkin(DragCard.BuildDeckListItem.card.id), 1);
            //        }
            //        DragCard.Card.hide();
            //    }
            //    else
            //    {
            //        if (!DragCard.Card.isDisplaying)
            //        {
            //            DragCard.Card.display();
            //            DragCard.Card.update(DragCard.BuildDeckListItem.card, parent.game.cards.GetCardSkin(DragCard.BuildDeckListItem.card.id));
            //        }
            //        DragCard.BuildDeckListItem.hide();
            //    }
            //    if (input.GetMouseButtonUp(0))
            //    {
            //        //停止拖拽
            //        stopDrag(position);
            //    }
            //}
        }
Ejemplo n.º 3
0
        protected override void onDisplay()
        {
            base.onDisplay();
            //目前只有一个卡组
            cards = parent.game.getManager <CardManager>().GetCardDefines(d => d.GetType().Assembly == typeof(THHGame).Assembly);
            int[]        deck       = parent.game.deck;
            CardSkinData masterSkin = parent.game.cards.getSkin(deck[0]);

            MasterButton.setSprite(masterSkin.image);
            MasterNameText.text = masterSkin.name;
            BuildDeckList.clearItems();
            foreach (var cards in deck.Skip(1).Select(id => cards.FirstOrDefault(c => c.id == id)).Where(c => c != null).GroupBy(c => c.id))
            {
                var item = BuildDeckList.addItem();
                var skin = parent.game.cards.getSkin(cards.First().id);
                item.update(cards.First(), skin, cards.Count());
            }
            reloadCardList();
            BuildDeckList.sortItems((a, b) =>
            {
                if (a.card.getCost() != b.card.getCost())
                {
                    return(a.card.getCost() - b.card.getCost());
                }
                else
                {
                    return(a.card.id - b.card.id);
                }
            });
            DragCard.hide();
        }
Ejemplo n.º 4
0
        public void onReleaseDeckItem(BuildDeckListItem item, PointerEventData pointer)
        {
            DragCard.hide();
            Vector3 localPosition = DeckViewScroll.GetComponent <RectTransform>().InverseTransformPoint(pointer.position);

            if (DeckViewScroll.GetComponent <RectTransform>().rect.Contains(localPosition))
            {
                onReleaseItem();
            }
            else
            {
                if (item.count < 1)
                {
                    BuildDeckList.removeItem(item);
                }
            }
        }
Ejemplo n.º 5
0
 partial void onAwake()
 {
     ReturnButton.onClick.AddListener(() =>
     {
         PlayerPrefs.SetInt("DeckCount", BuildDeckList.Select(i => i.count).Sum() + 1);
         int index = 1;
         foreach (var item in BuildDeckList.getItems())
         {
             for (int i = 0; i < item.count; i++)
             {
                 PlayerPrefs.SetInt("Deck" + index, item.card.id);
                 parent.game.deck[index] = item.card.id;
                 index++;
             }
         }
         PlayerPrefs.Save();
         parent.display(parent.MainMenu);
     });
 }
Ejemplo n.º 6
0
        public void stopDrag(Vector2 position)
        {
            DragCard.hide();
            Vector3 localPosition = DeckViewScroll.GetComponent <RectTransform>().InverseTransformPoint(position);

            if (!DeckViewScroll.GetComponent <RectTransform>().rect.Contains(localPosition))
            {
                return;
            }
            if (BuildDeckList.Select(i => i.count).Sum() >= 30)
            {
                //你不能带更多的卡牌
                return;
            }
            var item = BuildDeckList.getItems().FirstOrDefault(i => i.card == DragCard.BuildDeckListItem.card);

            if (item != null)
            {
                item.count++;
            }
            else
            {
                var newItem = BuildDeckList.addItem();
                newItem.update(DragCard.BuildDeckListItem.card, parent.game.cards.GetCardSkin(DragCard.BuildDeckListItem.card.id), 1);
            }
            BuildDeckList.sortItems((a, b) =>
            {
                if (a.card.getCost() != b.card.getCost())
                {
                    return(a.card.getCost() - b.card.getCost());
                }
                else
                {
                    return(a.card.id - b.card.id);
                }
            });
        }