示例#1
0
 private void GetBonus()
 {
     _gameDataService.Coins *= 2;
     SetEndGameData();
     _bonusButton.gameObject.SetActive(false);
     _achievementsService.UnlockAchievement(GPGSIds.achievement_i_want_it_all);
 }
示例#2
0
        private void GetRandomSkin()
        {
            var lockedSkins = _skinsList.Where(skin => !skin.IsUnlocked).ToList();
            var skinCost    = GetSkinCost();

            if (lockedSkins.Count <= 0 || skinCost > CloudVariables.ImportantValues[1])
            {
                return;
            }
            {
                var newSkin = lockedSkins[Random.Range(0, lockedSkins.Count - 1)].UnlockSkin().SkinImage.sprite;
                _skinService.SetSkin(newSkin);

                int newSkinPageId = (int)Math.Truncate((decimal)Convert.ToInt32(newSkin.name.Split('_')[1]) / 9);

                int deltaPage = newSkinPageId - _scroll.CurrentScreen();

                if (deltaPage > 0)
                {
                    _scroll.NextScreen(Math.Abs(deltaPage));
                }
                else
                {
                    _scroll.PreviousScreen(Math.Abs(deltaPage));
                }


                CloudVariables.ImportantValues[1] -= skinCost;

                var binString = "1";
                _skinsList.ForEach(skin =>
                {
                    if (skin.SkinImage.sprite.name == "Train_0")
                    {
                        return;
                    }

                    if (skin.IsUnlocked)
                    {
                        binString += "1";
                    }
                    else
                    {
                        binString += "0";
                    }
                });

                CloudVariables.ImportantValues[3] = Convert.ToInt64(binString, 2);

                _playGamesService.SaveData();
                _uiService.UpdateMainMenu();
                UpdateStoreCoins?.Invoke();
                _randomSkinButtonText.text = $"{GetSkinCost()} COINS";

                _achievementsService.UnlockAchievement(GPGSIds.achievement_new_customer);
                _achievementsService.IncrementAchievement(GPGSIds.achievement_train_station, 1);
                _achievementsService.IncrementAchievement(GPGSIds.achievement_railway_tycoon, 1);
            }
        }
示例#3
0
        private void OnTriggerEnter2D(Collider2D col)
        {
            PoolObject poolObject = col.GetComponent <PoolObject>();

            if (col.CompareTag("Point"))
            {
                if (IsBoosted)
                {
                    poolObject.ReturnToPool(0.5f);
                }
                else
                {
                    poolObject.ReturnToPool();
                }

                Points++;
                if (Points > 2 * Trains.Count)
                {
                    GenerateNewTrain();
                    Points = 1;
                }

                UpdateTrainPoints();

                _gameDataService.Coins++;
                _uiService.UpdateInGameCoins(_gameDataService.Coins);
                _achievementsService.UnlockAchievement(GPGSIds.achievement_coin_of_luck);
                if (_gameDataService.Coins == 100)
                {
                    _achievementsService.UnlockAchievement(GPGSIds.achievement_small_collection);
                }
                else if (_gameDataService.Coins == 500)
                {
                    _achievementsService.UnlockAchievement(GPGSIds.achievement_numismatist);
                }
                else if (_gameDataService.Coins == 1000)
                {
                    _achievementsService.UnlockAchievement(GPGSIds.achievement_good_catch);
                }

                _audioService.Play(AudioClipType.Coin);
            }
            else if (col.CompareTag("Boost"))
            {
                poolObject.ReturnToPool();
                StartCoroutine(ActivateBoost());
                _achievementsService.UnlockAchievement(GPGSIds.achievement_lone_star);
                _starsInOneRun++;
                if (_starsInOneRun == 3)
                {
                    _achievementsService.UnlockAchievement(GPGSIds.achievement_a_pinch_of_stardust);
                }
                else if (_starsInOneRun == 5)
                {
                    _achievementsService.UnlockAchievement(GPGSIds.achievement_starlight);
                }
                else if (_starsInOneRun == 10)
                {
                    _achievementsService.UnlockAchievement(GPGSIds.achievement_speed_of_light);
                }
                _achievementsService.IncrementAchievement(GPGSIds.achievement_constellation, 1);
                _achievementsService.IncrementAchievement(GPGSIds.achievement_star_cluster, 1);
            }
            else if (col.CompareTag("Stop") && !IsBoosted)
            {
                poolObject.ReturnToPool();

                Points = 1;
                UpdateTrainPoints();

                _levelService.ResetSpeed();

                var trainToRemove = Trains.Last();

                if (trainToRemove != this)
                {
                    Trains.Remove(trainToRemove);
                    trainToRemove.IsDead = true;
                    trainToRemove.ReturnToPool(1.5f);
                }
                else
                {
                    _uiService.IsInGame = false;
                    _uiService.ShowReviveMenu(!_gameDataService.Revived);
                }
                _audioService.Play(AudioClipType.StopHit);
                _stopsSurvived++;
                if (_stopsSurvived == 30)
                {
                    _achievementsService.UnlockAchievement(GPGSIds.achievement_just_a_scratch);
                }
            }
        }
示例#4
0
 private void ShowPauseMenu()
 {
     SetActivePanel(false);
     _uiService.SetPause();
     _achievementsService.UnlockAchievement(GPGSIds.achievement_dont_stop_me_now);
 }