Пример #1
0
        public void LoadCards(int page, Enumerators.SetType setType)
        {
            _toggleGroup.transform.GetChild((int)setType).GetComponent <Toggle>().isOn = true;

            CardSet set = SetTypeUtility.GetCardSet(_dataManager, setType);

            List <Card> cards = set.Cards;

            int startIndex = page * CardPositions.Count;

            int endIndex = Mathf.Min(startIndex + CardPositions.Count, cards.Count);

            ResetBoardCards();

            for (int i = startIndex; i < endIndex; i++)
            {
                if (i >= cards.Count)
                {
                    break;
                }

                Card card = cards[i];
                CollectionCardData cardData = _dataManager.CachedCollectionData.GetCardData(card.Name);

                // hack !!!! CHECK IT!!!
                if (cardData == null)
                {
                    continue;
                }

                GameObject go;
                BoardCard  boardCard;
                switch (card.CardKind)
                {
                case Enumerators.CardKind.CREATURE:
                    go        = Object.Instantiate(CardCreaturePrefab);
                    boardCard = new UnitBoardCard(go);
                    break;

                case Enumerators.CardKind.SPELL:
                    go        = Object.Instantiate(CardSpellPrefab);
                    boardCard = new SpellBoardCard(go);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                int amount = cardData.Amount;
                boardCard.Init(card, amount);
                boardCard.SetHighlightingEnabled(false);
                boardCard.Transform.position   = CardPositions[i % CardPositions.Count].position;
                boardCard.Transform.localScale = Vector3.one * 0.32f;
                boardCard.GameObject.GetComponent <SortingGroup>().sortingLayerID = SRSortingLayers.GameUI1;

                _createdBoardCards.Add(boardCard);
            }

            HighlightCorrectIcon();
        }
Пример #2
0
 private void CalculateNumberOfPages()
 {
     _numElementPages = Mathf.CeilToInt(SetTypeUtility.GetCardSet(_dataManager, _currentSet).Cards.Count /
                                        (float)CardPositions.Count);
 }