Exemplo n.º 1
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
                //
            });
        }