示例#1
0
 private void SetSkin()
 {
     if (IsUnlocked)
     {
         _skinService.SetSkin(SkinImage.sprite);
     }
 }
示例#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);
            }
        }
        public SiteInitController()
        {
            skinService = new SkinService();
            skinService.SetSkin(new SpaceSkin());

            feedService = new FeedService();
            pageService = new PageService();
        }