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();
        }
        public void DrawCardInfo(WorkingCard card)
        {
            GameObject go;
            BoardCard  boardCard;

            switch (card.LibraryCard.CardKind)
            {
            case Enumerators.CardKind.CREATURE:
                go = Object.Instantiate(
                    _loadObjectsManager.GetObjectByPath <GameObject>("Prefabs/Gameplay/Cards/CreatureCard"));
                boardCard = new UnitBoardCard(go);
                break;

            case Enumerators.CardKind.SPELL:
                go = Object.Instantiate(
                    _loadObjectsManager.GetObjectByPath <GameObject>("Prefabs/Gameplay/Cards/SpellCard"));
                boardCard = new SpellBoardCard(go);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            boardCard.Init(card);
            go.transform.position   = new Vector3(-6, 0, 0);
            go.transform.localScale = Vector3.one * .3f;
            boardCard.SetHighlightingEnabled(false);

            Object.Destroy(go, 2f);
        }
        public GameObject CreateCardPreview(WorkingCard card, Vector3 pos)
        {
            BoardCard  boardCard;
            GameObject currentBoardCard;

            CardsController.GetSetOfCard(card.LibraryCard);

            switch (card.LibraryCard.CardKind)
            {
            case Enumerators.CardKind.CREATURE:
                currentBoardCard = Object.Instantiate(CardsController.CreatureCardViewPrefab,
                                                      _reportActionPreviewPanel.transform, false);
                boardCard = new UnitBoardCard(currentBoardCard);
                break;

            case Enumerators.CardKind.SPELL:
                currentBoardCard = Object.Instantiate(CardsController.SpellCardViewPrefab,
                                                      _reportActionPreviewPanel.transform, false);
                boardCard = new SpellBoardCard(currentBoardCard);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            boardCard.Init(card);
            boardCard.SetHighlightingEnabled(false);
            boardCard.IsPreview = true;
            currentBoardCard.transform.localPosition = pos;
            currentBoardCard.transform.localRotation = Quaternion.Euler(Vector3.zero);
            currentBoardCard.transform.localScale    = new Vector2(.4f, .4f);
            currentBoardCard.GetComponent <SortingGroup>().sortingOrder = 1000;
            currentBoardCard.layer = LayerMask.NameToLayer("Ignore Raycast");

            return(currentBoardCard);
        }
        private BoardCard CreateBoardCard(WorkingCard card)
        {
            GameObject go;
            BoardCard  boardCard;

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

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

            default:
                throw new ArgumentOutOfRangeException();
            }

            boardCard.Init(card);
            boardCard.CurrentTurn = _battlegroundController.CurrentTurn;

            HandBoardCard handCard = new HandBoardCard(go, boardCard);

            handCard.OwnerPlayer    = card.Owner;
            handCard.BoardZone      = _playerBoard;
            boardCard.HandBoardCard = handCard;
            handCard.CheckStatusOfHighlight();
            boardCard.Transform.localScale = Vector3.one * .3f;

            _abilitiesController.CallAbilitiesInHand(boardCard, card);

            return(boardCard);
        }
Example #5
0
        // rewrite
        public IEnumerator CreateCardPreviewAsync(object target, Vector3 pos, bool highlight)
        {
            yield return(new WaitForSeconds(0.3f));

            WorkingCard card = null;

            switch (target)
            {
            case BoardCard card1:
                card = card1.WorkingCard;
                break;

            case BoardUnit unit:
                card = unit.Card;
                break;
            }

            BoardCard boardCard;

            switch (card.LibraryCard.CardKind)
            {
            case Enumerators.CardKind.CREATURE:
                CurrentBoardCard = Object.Instantiate(_cardsController.CreatureCardViewPrefab);
                boardCard        = new UnitBoardCard(CurrentBoardCard);
                break;

            case Enumerators.CardKind.SPELL:
                CurrentBoardCard = Object.Instantiate(_cardsController.SpellCardViewPrefab);
                boardCard        = new SpellBoardCard(CurrentBoardCard);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            boardCard.Init(card);
            if (highlight)
            {
                highlight = boardCard.CanBePlayed(card.Owner) && boardCard.CanBeBuyed(card.Owner);
            }

            boardCard.SetHighlightingEnabled(highlight);
            boardCard.IsPreview = true;

            InternalTools.SetLayerRecursively(boardCard.GameObject, 0);

            switch (target)
            {
            case BoardUnit boardUnit:
                boardCard.DrawTooltipInfoOfUnit(boardUnit);
                break;

            case BoardCard tooltipCard:
                boardCard.DrawTooltipInfoOfCard(tooltipCard);
                break;
            }

            Vector3 newPos = pos;

            newPos.y += 2.0f;
            CurrentBoardCard.transform.position      = newPos;
            CurrentBoardCard.transform.localRotation = Quaternion.Euler(Vector3.zero);

            Vector3 sizeOfCard = Vector3.one;

            sizeOfCard = !InternalTools.IsTabletScreen() ? new Vector3(.8f, .8f, .8f) : new Vector3(.4f, .4f, .4f);

            CurrentBoardCard.transform.localScale = sizeOfCard;

            CurrentBoardCard.GetComponent <SortingGroup>().sortingLayerID = SRSortingLayers.GameUI3;
            CurrentBoardCard.layer = LayerMask.NameToLayer("Default");
            CurrentBoardCard.transform.DOMoveY(newPos.y + 1.0f, 0.1f);
        }