Exemplo n.º 1
0
        /// <summary>
        /// Shuffle cards by state type.
        /// </summary>
        /// <param name="bReplay">Replay game or start new</param>
        public void Shuffle(bool bReplay)
        {
            HintManagerComponent.IsHintWasUsed = false;
            IsNeedResetPack    = false;
            faceDownCardsCount = 0;
            //faceDownCardsCount = 52;
            autoCompleteActive = false;
            GameManagerComponent.RestoreInitialState();
            RestoreInitialState();
            UndoPerformerComponent.gameUndoCount = 0;
            GameManagerComponent.gamesPlayed++;
            SaveLoadManager.SaveGameData(GameManagerComponent);

            if (!bReplay)
            {
                GenerateRandomCardNums();
            }

            for (int i = 0; i < Public.CARD_NUMS; i++)
            {
                Card card = CardsArray[i];
                card.InitWithNumber(CardNumberArray[i]);
                card.CardRect.gameObject.name = "Card_" + card.GetTypeName() + "_" + card.Number;
                PackDeck.PushCard(card);
            }
            InitDeckCards();
            SetPackDeckBg();
            HintManagerComponent.UpdateAvailableForDragCards();

            HintManagerComponent.hintTimerCount = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Win game action.
        /// </summary>
        public void HasWinGame()
        {
            _cardLayer.SetActive(false);
            _winLayer.SetActive(true);
            adsManager.doubleXPButton.gameObject.SetActive(true);
            doubleXPIcon.gameObject.SetActive(false);

            StopGameTimer();
            _congratManagerComponent.CongratulationTextFill();
            var score = _scoreCount + Public.SCORE_NUMBER / _timeCount;

            _timeWinLabel.text  = "YOUR TIME: " + _timeLabel.text;
            _scoreWinLabel.text = score.ToString();
            _stepsWinLabel.text = "YOUR MOVES: " + _stepCount;
            PlayGameAudio(SoundType.AUDIO_TYPE_WIN);
            SetBestValuesToPrefs(score);

            _winLayer.GetComponent <Animator>().SetTrigger(_appearTrigger);

            if (StatisticsController.Instance.PlayedGamesTime != null)
            {
                StatisticsController.Instance.PlayedGamesTime.Invoke(_timeCount);
            }
            if (StatisticsController.Instance.AverageTime != null)
            {
                StatisticsController.Instance.AverageTime.Invoke();
            }
            if (StatisticsController.Instance.IncreaseScore != null)
            {
                StatisticsController.Instance.IncreaseScore.Invoke(score);
            }
            if (StatisticsController.Instance.IncreaseWonGames != null)
            {
                StatisticsController.Instance.IncreaseWonGames.Invoke();
            }
            if (StatisticsController.Instance.BestTime != null)
            {
                StatisticsController.Instance.BestTime.Invoke(_timeCount);
            }
            if (StatisticsController.Instance.BestMoves != null)
            {
                StatisticsController.Instance.BestMoves.Invoke(_stepCount);
            }


            //add winXP to playerXP
            //TEMP----------------------------------------------------------------------------------------------------------------------------
            //change winXP to the player's score
            StartCoroutine(HandleXPOnWin(score));


            gamesWon++;

            SaveLoadManager.SaveGameData(this);

            Analytics.CustomEvent("gameWon", new Dictionary <string, object>
            {
                { "score", score },
                { "time", _timeLabel.text },
                { "moves", _stepCount },
                { "undos used", _undoPerformComponent.gameUndoCount }
                //playerID
                //
            });
        }