Пример #1
0
        /// <summary>
        /// Click on new game button.
        /// </summary>
        public void OnClickWinNewGame()
        {
            _winLayer.GetComponent <Animator>().SetTrigger(_disappearTrigger);
            StartCoroutine(InvokeAction(delegate
            {
                _winLayer.SetActive(false);
                _cardLayer.SetActive(!_statisticLayer.activeInHierarchy && !_ruleLayer.activeInHierarchy && !_winLayer.activeInHierarchy);
            }, 0.42f));

            _cardLogic.Shuffle(false);
            _undoPerformComponent.ResetUndoStates();

            Analytics.CustomEvent("newGame", new Dictionary <string, object> {
                { "newGameSource", "Win State/New Game" }
            });


            if (StatisticsController.Instance.PlayedGames != null)
            {
                StatisticsController.Instance.PlayedGames.Invoke();
            }

            adsManager.ShowAd("newGameSkippable");
        }
Пример #2
0
        /// <summary>
        /// Action of Undo all decks/cards states.
        /// </summary>
        public void Undo()
        {
            if (StatesData.States.Count > 0)
            {
                //if undos are countable and there are undos to be used, subtract the undo and update the text
                if (IsCountable && _availableUndoCounts > 0)
                {
                    _availableUndoCounts--;
                    gameUndoCount++;
                    _undoAvailableCountsText.text = _availableUndoCounts.ToString();
                }
                //else if undos are countable and there are no remaining undos, trigger an ad to reset the undo count
                else if (IsCountable && _availableUndoCounts == 0)
                {
                    //_gameMgrComponent.OnClickGetUndoAdsBtn();

                    //if the Player doesn't have any more undos, trigger an ad to get more
                    if (_adsComponent.adsActive == true)
                    {
                        _adsComponent.ShowAd("refillUndos");

                        return;
                    }
                    else
                    {
                        return;
                    }
                }

                _hintComponent.IsHintWasUsed        = false;
                _cardLogicComponent.IsNeedResetPack = false;

                //go through each card in the alldeckarray(master of all cards)
                for (int i = 0; i < _cardLogicComponent.AllDeckArray.Length; i++)
                {
                    //_cardLogicComponent.faceDownCardsCount = 0;

                    //assign deck to the all deck array, so all cards
                    Deck deck = _cardLogicComponent.AllDeckArray[i];
                    //assign the deck record to the current state -1, so the previous state
                    DeckRecord deckRecord = StatesData.States[StatesData.States.Count - 1].DecksRecord[i];
                    //assign deck's card list to the deckRecord cards list of the previous state
                    deck.CardsArray = new List <Card>(deckRecord.Cards);

                    for (int j = 0; j < deckRecord.CardsRecord.Count; j++)
                    {
                        Card       card       = deck.CardsArray[j];
                        CardRecord cardRecord = deckRecord.CardsRecord[j];

                        card.CardType                = cardRecord.CardType;
                        card.CardNumber              = cardRecord.CardNumber;
                        card.Number                  = cardRecord.Number;
                        card.CardStatus              = cardRecord.CardStatus;
                        card.CardColor               = cardRecord.CardColor;
                        card.IsDraggable             = cardRecord.IsDraggable;
                        card.IndexZ                  = cardRecord.IndexZ;
                        card.Deck                    = cardRecord.Deck;
                        card.transform.localPosition = cardRecord.Position;
                        card.transform.SetSiblingIndex(cardRecord.SiblingIndex);
                        card.isFaceDown = cardRecord.IsFaceDown;

                        //if (card.isFaceDown == true)
                        //{
                        //	_cardLogicComponent.faceDownCardsCount++;
                        //}
                    }
                    //_cardLogicComponent.faceDownCardsCount =  deckRecord.faceDownCardsCount;

                    deck.UpdateCardsPosition(false);
                }

                _cardLogicComponent.faceDownCardsCount = 0;
                for (int k = 0; k < _cardLogicComponent.CardsArray.Length; k++)
                {
                    Card card = _cardLogicComponent.CardsArray[k];
                    if (card.isFaceDown == true)
                    {
                        _cardLogicComponent.faceDownCardsCount++;
                    }
                }
                //_gameMgrComponent._scoreCount = StatesData.States[StatesData.States.Count - 1].Score;
                _hintComponent.UpdateAvailableForDragCards();
                _cardLogicComponent.GameManagerComponent.CardMove();
                StatesData.States.RemoveAt(StatesData.States.Count - 1);
                ActivateUndoButton();
            }
        }