示例#1
0
        private void PackItemAnimationComplete()
        {
            CardPack cardPack = new CardPack(Enumerators.CardPackType.DEFAULT);

            if (!_dataManager.CachedUserLocalData.OpenedFirstPack)
            {
                _activatedTemporaryPack = true;
                _dataManager.CachedUserLocalData.OpenedFirstPack = true;
                _dataManager.SaveCache(Enumerators.CacheDataType.USER_LOCAL_DATA);
            }

            List <Card> cardsInPack = cardPack.OpenPack(_activatedTemporaryPack);

            _activatedTemporaryPack = false;

            for (int i = 0; i < Constants.CardsInPack; i++)
            {
                Card card = cardsInPack[i];

                GameObject go;
                switch (card.CardKind)
                {
                case Enumerators.CardKind.CREATURE:
                    go = Object.Instantiate(_cardCreaturePrefab);
                    break;

                case Enumerators.CardKind.SPELL:
                    go = Object.Instantiate(_cardSpellPrefab);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                go.transform.SetParent(_cardsContainer);
                go.transform.Find("Back").gameObject.SetActive(true);
                go.transform.Find("Amount").gameObject.SetActive(false);

                // todo imrpoveE!!!!
                BoardCard boardCard = new BoardCard(go);

                boardCard.Init(card);
                boardCard.SetHighlightingEnabled(false);
                boardCard.Transform.position = _centerPos;
                boardCard.GameObject.GetComponent <SortingGroup>().sortingLayerID = SRSortingLayers.Default.id;
                boardCard.GameObject.GetComponent <SortingGroup>().sortingOrder   = 1;

                Vector3 pos      = _cardPlaceholders.transform.GetChild(i).position;
                Vector3 rotation = _cardPlaceholders.transform.GetChild(i).eulerAngles;

                go.transform.localScale = Vector3.one * .28f;
                go.transform.DOMove(pos, 1.0f);
                go.transform.DORotate(rotation, 1.0f);

                _createdBoardCards.Add(boardCard);
            }
        }
示例#2
0
        private void PlayCardCompleteHandler(WorkingCard card, object target)
        {
            WorkingCard workingCard =
                _gameplayManager.OpponentPlayer.CardsOnBoard[_gameplayManager.OpponentPlayer.CardsOnBoard.Count - 1];

            switch (card.LibraryCard.CardKind)
            {
            case Enumerators.CardKind.CREATURE:
            {
                BoardUnit  boardUnitElement = new BoardUnit(GameObject.Find("OpponentBoard").transform);
                GameObject boardCreature    = boardUnitElement.GameObject;
                boardCreature.tag = SRTags.OpponentOwned;
                boardCreature.transform.position = Vector3.zero;
                boardUnitElement.OwnerPlayer     = card.Owner;

                boardUnitElement.SetObjectInfo(workingCard);
                _battlegroundController.OpponentBoardCards.Add(boardUnitElement);

                boardCreature.transform.position +=
                    Vector3.up * 2f;     // Start pos before moving cards to the opponents board

                // PlayArrivalAnimation(boardCreature, libraryCard.cardType);
                _gameplayManager.OpponentPlayer.BoardCards.Add(boardUnitElement);

                _actionsQueueController.PostGameActionReport(_actionsQueueController.FormatGameActionReport(
                                                                 Enumerators.ActionType.PLAY_UNIT_CARD, new object[]
                    {
                        boardUnitElement.OwnerPlayer, boardUnitElement
                    }));

                boardUnitElement.PlayArrivalAnimation();

                _battlegroundController.UpdatePositionOfBoardUnitsOfOpponent(
                    () =>
                    {
                        bool createTargetArrow = false;

                        if (card.LibraryCard.Abilities != null && card.LibraryCard.Abilities.Count > 0)
                        {
                            createTargetArrow =
                                _abilitiesController.IsAbilityCanActivateTargetAtStart(
                                    card.LibraryCard.Abilities[0]);
                        }

                        if (target != null)
                        {
                            CreateOpponentTarget(
                                createTargetArrow,
                                false,
                                boardCreature.gameObject,
                                target,
                                () =>
                            {
                                _abilitiesController.CallAbility(card.LibraryCard, null, workingCard,
                                                                 Enumerators.CardKind.CREATURE, boardUnitElement, null, false, null, target);
                            });
                        }
                        else
                        {
                            _abilitiesController.CallAbility(card.LibraryCard, null, workingCard,
                                                             Enumerators.CardKind.CREATURE, boardUnitElement, null, false, null);
                        }
                    });
                break;
            }

            case Enumerators.CardKind.SPELL:
            {
                GameObject spellCard = Object.Instantiate(_cardsController.SpellCardViewPrefab);
                spellCard.transform.position = GameObject.Find("OpponentSpellsPivot").transform.position;

                CurrentSpellCard = new SpellBoardCard(spellCard);

                CurrentSpellCard.Init(workingCard);
                CurrentSpellCard.SetHighlightingEnabled(false);

                BoardSpell boardSpell = new BoardSpell(spellCard, workingCard);

                spellCard.gameObject.SetActive(false);

                bool createTargetArrow = false;

                if (card.LibraryCard.Abilities != null && card.LibraryCard.Abilities.Count > 0)
                {
                    createTargetArrow =
                        _abilitiesController.IsAbilityCanActivateTargetAtStart(card.LibraryCard.Abilities[0]);
                }

                if (target != null)
                {
                    CreateOpponentTarget(
                        createTargetArrow,
                        false,
                        _gameplayManager.OpponentPlayer.AvatarObject,
                        target,
                        () =>
                        {
                            _abilitiesController.CallAbility(card.LibraryCard, null, workingCard,
                                                             Enumerators.CardKind.SPELL, boardSpell, null, false, null, target);
                        });
                }
                else
                {
                    _abilitiesController.CallAbility(card.LibraryCard, null, workingCard,
                                                     Enumerators.CardKind.SPELL, boardSpell, null, false, null);
                }

                break;
            }
            }
        }