Esempio n. 1
0
    private void Start()
    {
        playerGolds.SetFormatedText(gameManager.PlayerGolds);
        items[0].Setup(gameManager.shopItems[0]);
        items[1].Setup(gameManager.shopItems[1]);
        items[2].Setup(gameManager.shopItems[2]);
#if DATABEEN
        DataBeen.SendStartLevelData("shop");
#endif
    }
Esempio n. 2
0
    // Use this for initialization
    private IEnumerator Start()
    {
        UiShowHide.ShowAll(transform);

        buyButton.onClick.AddListener(() =>
        {
            Game.SpendGems(GlobalConfig.Shop.heartPrice, () =>
            {
                Profile.Hearts += GlobalConfig.ProfilePreset.hearts;
                Back();
                GlobalAnalytics.SinkGem(GlobalConfig.Shop.heartPrice, "profile", "heart");
            });
        });


        price.SetText(GlobalConfig.Shop.heartPrice.ToString());
        var wait = new WaitForSeconds(1);

        while (true)
        {
            hearts.SetText(Profile.Hearts.ToString());
            int seconds = Online.Timer.GetRemainSeconds(GlobalConfig.Heart.timerId, GlobalConfig.Heart.interval);
            title.SetFormatedText(seconds / 60, seconds % 60);
            yield return(wait);
        }
    }
Esempio n. 3
0
    // Start is called before the first frame update
    private void Start()
    {
        gemsLabel.SetFormatedText(GlobalConfig.Friends.rewardGems);

        friendsButton.onClick.AddListener(() =>
        {
            Game.Instance.ClosePopup(true);

            if (Profile.HasNickname)
            {
                Game.Instance.OpenState <State_Friends>();
            }
            else
            {
                Game.Instance.OpenPopup <Popup_Confirm>().Setup(111121, true, false, ok =>
                {
                    if (ok)
                    {
                        Game.Instance.OpenPopup <Popup_Profile>().SetOnClose(() =>
                        {
                            if (Profile.HasNickname)
                            {
                                Game.Instance.OpenPopup <Popup_Confirm>().Setup(111122, true, false, done => Game.Instance.OpenState <State_Friends>());
                            }
                        });
                    }
                });
            }
        });
    }
Esempio n. 4
0
    private void UpdateVisual()
    {
        var openedLevels = Profile.GetSeasonProgress(CurrentSeason);

        if (season == null)
        {
            seasonState = SeasonState.Null;
        }
        else
        {
            seasonProgress = openedLevels / (float)season.levelCount;
            if (openedLevels < season.levelCount)
            {
                seasonState = SeasonState.Progressing;
            }
            else if (Profile.GetSeasonRewarded(CurrentSeason) < 1)
            {
                seasonState = SeasonState.CanClaimReward;
            }
            else
            {
                seasonState = SeasonState.Completed;
            }

            GlobalFactory.Theme.Select(season.id);
            themeImage.sprite = GlobalFactory.Theme.Selected.previewBackground;
        }

        title.SetFormatedText(CurrentSeason + 1);
        chestButton.gameObject.SetActive(seasonState == SeasonState.Progressing || seasonState == SeasonState.CanClaimReward);
        claimReward.SetActive(seasonState == SeasonState.CanClaimReward);
        comingSoon.SetActive(seasonState == SeasonState.Null);

        progressImage.fillAmount = 0.1f + 0.8f * seasonProgress;
        progressHighlight.SetActive(seasonProgress > 0.7f);

        if (seasonProgress > 0.8f)
        {
            chestAnimation.Play();
        }
        else
        {
            chestAnimation.Stop();
            chestAnimation.transform.AsRectTransform().localRotation = Quaternion.identity;
        }

        CheckTutorial();


        if (GlobalConfig.DebugMode)
        {
            nextButton.SetInteractable(season != null);
            prevButton.SetInteractable(CurrentSeason > 0);
        }
        else
        {
            nextButton.SetInteractable(season != null && Profile.GetSeasonRewarded(season.id) > 0);
            prevButton.SetInteractable(CurrentSeason > 0);
        }
    }
Esempio n. 5
0
    private void Awake()
    {
        InGameItem.all.Clear();

        maxScoreLabel.SetFormatedText(gameManager.MaxScore);

        bricksManager.Setup(OnGameOver, item =>
        {
            if (item is InGameItemBall)
            {
                score++;
                if (score.Current > gameManager.MaxScore)
                {
                    gameManager.MaxScore = score.Current;
                }

                ballsManager.AddExtraBall(item.transform.position);
            }
        });

        controller.Setup(direction => ballsManager.Shoot(direction, () => StartCoroutine(TakeReady())));

        score.SetOnValueChanged((lv, cv) => scoreLabel.SetFormatedText(cv));
        score.Current = 0;
    }
Esempio n. 6
0
 private IEnumerator Start()
 {
     while (true)
     {
         goldLabel.SetFormatedText(gameManager.PlayerGolds);
         yield return(new WaitForSeconds(1));
     }
 }
Esempio n. 7
0
    private void Start()
    {
        friendsDesc.SetFormatedText(GlobalConfig.Friends.rewardGems);

        friendsButton.onClick.AddListener(() =>
        {
            if (Profile.HasNickname)
            {
                Game.Instance.OpenState <State_Friends>();
            }
            else
            {
                Game.Instance.OpenPopup <Popup_Confirm>().Setup(111121, true, false, ok =>
                {
                    if (ok)
                    {
                        Game.Instance.OpenPopup <Popup_Profile>().SetOnClose(() =>
                        {
                            if (Profile.HasNickname)
                            {
                                Game.Instance.OpenPopup <Popup_Confirm>().Setup(111122, true, false, null);
                            }
                        });
                    }
                });
            }
        });

        UIBackground.Show();
        if (Profile.IsLoggedIn)
        {
            UiShowHide.ShowAll(transform);
        }
        else
        {
            Loading.Show();
            Profile.Sync(false, success =>
            {
                Loading.Hide();
                if (success)
                {
                    UiShowHide.ShowAll(transform);
                }
                else
                {
                    Back();
                }
            });
        }
    }
Esempio n. 8
0
    private IEnumerator Start()
    {
        scoreLabel.SetText("0");

        int totalBalls = PlayModel.result.totalBalls + PlayModel.level.startBallCount;

        descLabel.SetFormatedText(PlayModel.result.totalTurn.ToString(), PlayModel.result.totalBlocks.ToString(), totalBalls);

        inviteButton.onClick.AddListener(() =>
        {
            var str = string.Format(GlobalConfig.Socials.invitationText, Profile.Username, GlobalConfig.Market.storeUrl);
            SocialAndSharing.ShareText(str);
        });

        replayButton.onClick.AddListener(() =>
        {
            onReplayFunc(() =>
            {
                base.Back();
                UIBackground.Hide();
                Game.Instance.ClosePopup(true);
                Game.Instance.OpenState <State_Playing>();
            });
        });

        baloon.gameObject.SetActive(false);
        UiShowHide.ShowAll(transform);
        yield return(new WaitForSeconds(0.5f));

        // Incentive  text
        {
            var index        = BaloonIndex++ % 25;
            var incentiveStr = LocalizationService.Get(111090 + index);
            baloon.SetText(incentiveStr);
            baloon.gameObject.SetActive(true);
        }

        float t = 0;
        float curscore = 0, maxscore = PlayModel.GetScore();
        var   wait = new WaitForEndOfFrame();

        while (t < 1)
        {
            t       += Time.deltaTime * 0.75f;
            curscore = Mathf.Lerp(0, maxscore, t);
            scoreLabel.SetText(Mathf.RoundToInt(curscore).ToString());
            yield return(wait);
        }
    }
Esempio n. 9
0
    private void UpdateView()
    {
        if (LeagueLogics.data == null)
        {
            return;
        }

        var mine = LeagueLogics.leaderboard.current.Find(x => x.username == Profile.Username);

        if (mine != null)
        {
            if (mine.score > LeagueLogics.data.score)
            {
                LeagueLogics.data.score = mine.score;
            }
            if (mine.rank > LeagueLogics.data.rank)
            {
                LeagueLogics.data.rank = mine.rank;
            }
        }

        var seconds = Online.League.GetRemainedSeconds(LeagueLogics.data.start_time, LeagueLogics.data.duration, Online.Timer.CurrentSeconds);

#if UNITY_EDITOR
        {
            var D = seconds / 86400;
            var H = (seconds % 86400) / 3600;
            var M = (seconds % 3600) / 60;
            var S = seconds % 60;
            Debug.LogWarning("Seconds: " + seconds + " D:" + D + " H:" + H + " M:" + M + " S:" + S);
        }
#endif


        var subleague = GlobalFactory.Leagues.GetByScore(LeagueLogics.info, LeagueLogics.data.score);
        medalImage.sprite = GlobalFactory.Leagues.GetMedal(LeagueLogics.info, LeagueLogics.data.score);
        medalLabel.SetText(subleague.name);
        timeLabel.SetFormatedText(TimeToString(seconds));
        scoreLabel.SetFormatedText(LeagueLogics.data.score);
        rankLabel.SetFormatedText((LeagueLogics.data.rank > 0 && LeagueLogics.data.score > 0) ? LeagueLogics.data.rank.ToString() : "-");
        rewardLabel.SetFormatedText(subleague.rewardGems, subleague.name);
        rewardButton.gameObject.SetActive(LeagueLogics.data.end_rank > 0);
        rewardsButton.gameObject.SetActive(LeagueLogics.data.end_rank <= 0);
        boardButton.SetInteractable(true);
        playButton.SetInteractable(true);

        var topleague = GlobalFactory.Leagues.GetByScore(LeagueLogics.info, 9999999);
        rewardLabelTop.SetFormatedText(topleague.rewardGems, topleague.name);
    }
Esempio n. 10
0
    // Start is called before the first frame update
    private IEnumerator Start()
    {
        gemsLabel.SetFormatedText(GlobalConfig.Advertise.shopFreeGems.rewardGems);

        button.onClick.AddListener(() =>
        {
            var seconds = Online.Timer.GetRemainSeconds(GlobalConfig.Advertise.shopFreeGems.timerId, GlobalConfig.Advertise.shopFreeGems.interval);
            if (seconds > 0)
            {
                Game.Instance.OpenPopup <Popup_Confirm>().SetText(111018, TimeToString(seconds)).Setup(true, false, null);
            }
            else
            {
                Game.Instance.OpenPopup <Popup_VideoAd>().Setup(GlobalConfig.Advertise.shopFreeGems, "shopad", success =>
                {
                    if (success == false)
                    {
                        return;
                    }
                    Online.Timer.Set(GlobalConfig.Advertise.shopFreeGems.timerId, GlobalConfig.Advertise.shopFreeGems.interval);
                    Profile.EarnGems(GlobalConfig.Advertise.shopFreeGems.rewardGems);
                    Game.Instance.OpenPopup <Popup_Rewards>().Setup(0, GlobalConfig.Advertise.shopFreeGems.rewardGems, 0, 0, 0, true);
                    GlobalAnalytics.SourceGem(GlobalConfig.Advertise.shopFreeGems.rewardGems, "shopad");
                });
            }
        });

        var wait = new WaitForSeconds(1);

        while (true)
        {
            var seconds = Online.Timer.GetRemainSeconds(GlobalConfig.Advertise.shopFreeGems.timerId, GlobalConfig.Advertise.shopFreeGems.interval);
            if (seconds > 0)
            {
                timeLabel.transform.SetActiveChild(1);
                var h = seconds / 3600;
                var m = (seconds % 3600) / 60;
                var s = seconds % 60;
                timeLabel.SetFormatedText(h, m, s);
            }
            else
            {
                timeLabel.transform.SetActiveChild(0);
            }

            yield return(wait);
        }
    }
Esempio n. 11
0
    public Popup_LevelInfo Setup(SeasonModel season, int index, bool startLevelButton)
    {
        var levelmodel = season.GetLevelModel(index, Profile.Skill);

        title.SetFormatedText(season.id + 1, GlobalFactory.Seasons.GetLevelNumber(season.id, index + 1));
        ballsLabel.SetFormatedText(levelmodel.startBallCount);
        allitemsDesc.SetActive(levelmodel.IsTargetExist == false);
        targetItemsDesc.SetActive(levelmodel.IsTargetExist == true);

        var ballsprite = GlobalFactory.Balls.GetSprite(Profile.Avatar.BallId);

        foreach (var ballimage in ballImages)
        {
            ballimage.sprite = ballsprite;
        }

        targetItem0Image.sprite = GlobalFactory.Theme.Selected.items[0];
        targetItem1Image.sprite = GlobalFactory.Theme.Selected.items[1];

        targetItem0Label.text  = levelmodel.targetItem0.ToString();
        targetItem1Label.text  = levelmodel.targetItem1.ToString();
        targetBallsLabel.text  = levelmodel.targetBalls.ToString();
        targetBlocksLabel.text = levelmodel.targetBlocks.ToString();

        targetItem0Label.transform.parent.gameObject.SetActive(levelmodel.targetItem0 > 0);
        targetItem1Label.transform.parent.gameObject.SetActive(levelmodel.targetItem1 > 0);
        targetBallsLabel.transform.parent.gameObject.SetActive(levelmodel.targetBalls > 0);
        targetBlocksLabel.transform.parent.gameObject.SetActive(levelmodel.targetBlocks > 0);

        startButton.onClick.AddListener(() =>
        {
            if (startLevelButton)
            {
                if (StoryLogic.SetPlayModel(season, index))
                {
                    Back();
                    StoryLogic.StartPlaying(null);
                }
            }
            else
            {
                Back();
            }
        });

        return(this);
    }
Esempio n. 12
0
    // Use this for initialization
    private IEnumerator Start()
    {
        PurchaseOffer.Setup(
            GlobalConfig.Offers.startIndex,
            GlobalConfig.Shop.offers.Count,
            GlobalConfig.Offers.firstDelay,
            GlobalConfig.Offers.offerDuration,
            GlobalConfig.Offers.coolTime,
            GlobalConfig.Offers.minResource,
            GlobalConfig.Offers.resourceTime,
            GlobalConfig.Offers.lastPurchaseTime);

#if UNITY_EDITOR
        PurchaseOffer.Setup(1, GlobalConfig.Shop.offers.Count, 10, 15, 10, 99999999, 5, 60);
#endif

        pack = Game.GetOfferPackage();
        if (pack != null)
        {
            PopupQueue.Add(0.5f, () => Game.Instance.OpenPopup <Popup_Offer>().Setup(pack));
        }

        button.onClick.AddListener(() => Game.Instance.OpenPopup <Popup_Offer>().Setup(pack));

        var wait = new WaitForSeconds(1);
        while (true)
        {
            pack = Game.GetOfferPackage();
            if (pack != null)
            {
                discountLabel.SetFormatedText(pack.discount);
                timeLabel.SetText(Utilities.TimeToString(PurchaseOffer.RemainedTime, 0));
            }
            presenter.SetActive(pack != null && pack.discount > 0);

            yield return(wait);
        }
    }
Esempio n. 13
0
    private void Start()
    {
        titleLabel.SetFormatedText(GlobalConfig.Friends.rewardGems);
        descLabel.SetFormatedText(GlobalConfig.Friends.maxCount);

        inviteButton.onClick.AddListener(() =>
        {
            var str = string.Format(GlobalConfig.Socials.invitationText, Profile.Username, GlobalConfig.Market.storeUrl);
            SocialAndSharing.ShareText(str);
        });

        addButton.onClick.AddListener(() =>
        {
            var username = usernameInput.text.CleanFromCode();
            if (username.HasContent(2))
            {
                Loading.Show();
                addButton.SetInteractable(false);
                Online.Friends.Add(username, (success, friend) =>
                {
                    Loading.Hide();
                    Back();
                    if (success && onSuccessFunc != null)
                    {
                        onSuccessFunc(friend);
                    }
                    else
                    {
                        Game.Instance.OpenPopup <Popup_Confirm>().Setup(111124, true, false, null);
                    }
                });
            }
        });

        UiShowHide.ShowAll(transform);
    }
Esempio n. 14
0
 private void Start()
 {
     maxScoreLabel.SetFormatedText(gameManager.MaxScore);
     playerGold.SetFormatedText(gameManager.PlayerGolds);
     playerScore.SetFormatedText(gameManager.MaxScore);
 }
Esempio n. 15
0
    public UiShopItem Setup(string sku, System.Action <bool> onClick = null)
    {
        pack = GlobalConfig.Shop.GetPackage(sku);
        if (pack == null)
        {
            return(this);
        }

        images.SetActiveChild(pack.image);
        if (title)
        {
            title.SetText(pack.title);
        }
        if (gemsLabel)
        {
            gemsLabel.SetFormatedText(pack.gems);
        }
        if (bombLabel)
        {
            bombLabel.SetFormatedText(pack.bombs);
        }
        if (hammerLabel)
        {
            hammerLabel.SetFormatedText(pack.hammers);
        }
        if (missileLabel)
        {
            missileLabel.SetFormatedText(pack.missiles);
        }
        if (priceLabel)
        {
            priceLabel.SetFormatedText(pack.price);
        }
        if (lastPriceLabel)
        {
            lastPriceLabel.SetFormatedText(pack.lastPrice);
        }
        if (discountLabel)
        {
            if (pack.discount > 0)
            {
                discountLabel.SetFormatedText(pack.discount);
            }
            else
            {
                discountLabel.transform.parent.gameObject.SetActive(false);
            }
        }

        button.onClick.AddListener(() =>
        {
            button.SetInteractable(false);
            PurchaseSystem.Purchase(PurchaseProvider.Market, sku, (succeed, token) =>
            {
                if (succeed)
                {
                    Purchased(sku, token, () => onClick?.Invoke(true));
                }
                else
                {
                    onClick?.Invoke(false);
                }

                button.SetInteractable(true);
            });
        });

        return(this);
    }
Esempio n. 16
0
 public UIShopItem Setup(ShopItem item)
 {
     goldLabel.SetFormatedText(item.gold);
     priceLabel.SetFormatedText(item.price);
     return(this);
 }
Esempio n. 17
0
    // Use this for initialization
    private IEnumerator Start()
    {
        var rewards     = PlayModel.GetReward();
        int rewardStars = PlayModel.GetRewardStars();

        // verify that player has been passed this level
        if (Profile.IsLevelPassed(PlayModel.level.season, PlayModel.level.index))
        {
            rewards.gems = rewards.bombs = rewards.hammers = rewards.missiles = 0;
        }

        Profile.SetLevelStars(PlayModel.level.season, PlayModel.level.index, rewardStars);

        int totalBalls = PlayModel.result.totalBalls + PlayModel.level.startBallCount;

        desc.SetFormatedText(PlayModel.result.totalTurn.ToString(), PlayModel.result.totalBlocks.ToString(), totalBalls);

        if (rewards.exist)
        {
            continueButton.gameObject.SetActive(true);
            nextLevelButton.gameObject.SetActive(false);
            goHomeButton.gameObject.SetActive(false);
        }
        else
        {
            continueButton.gameObject.SetActive(false);
            nextLevelButton.gameObject.SetActive(true);
            goHomeButton.gameObject.SetActive(true);
        }

        nextLevelButton.onClick.AddListener(() =>
        {
            base.Back();
            nextTaskFunc?.Invoke(true);
        });

        goHomeButton.onClick.AddListener(() =>
        {
            base.Back();
            nextTaskFunc?.Invoke(false);
        });

        continueButton.onClick.AddListener(() =>
        {
            continueButton.gameObject.SetActive(false);

            Profile.EarnGems(rewards.gems);
            Profile.Bombs    += rewards.bombs;
            Profile.Hammers  += rewards.hammers;
            Profile.Missiles += rewards.missiles;
            Game.Instance.OpenPopup <Popup_Rewards>().Setup(0, rewards.gems, rewards.bombs, rewards.hammers, rewards.missiles, true, true, () =>
            {
                continueButton.gameObject.SetActive(false);
                nextLevelButton.gameObject.SetActive(true);
                goHomeButton.gameObject.SetActive(true);
            });
            GlobalAnalytics.SourceGem(rewards.gems, "level");
        });

        UiShowHide.ShowAll(transform);
        var wait = new WaitForSeconds(0.3f);

        yield return(wait);

        yield return(wait);

        yield return(wait);

        stars[0].SetActive(rewardStars > 0);
        yield return(wait);

        stars[1].SetActive(rewardStars > 1);
        yield return(wait);

        stars[2].SetActive(rewardStars > 2);
        yield return(wait);

        // Incentive  text
        {
            var index        = BaloonIndex++ % 25;
            var incentiveStr = LocalizationService.Get(111090 + index);
            if (BaloonIndex < 25 || Random.Range(0, 100) < rewardStars * 25)
            {
                baloon.SetText(incentiveStr);
                baloon.gameObject.SetActive(true);
            }
        }
    }
Esempio n. 18
0
    public UIFriendItem Setup(Online.Friends.Friendship friend, int rank)
    {
        if (avatar)
        {
            avatar.Setup(friend.avatar);
        }
        if (nicknameLabel)
        {
            nicknameLabel.SetText(friend.nickname);
        }
        if (descLabel)
        {
            descLabel.SetText(friend.status);
        }
        if (levelLabel)
        {
            levelLabel.SetText(friend.level);
        }
        if (rankLabel)
        {
            rankLabel.SetText(rank.ToString());
        }
        if (cupImage && rank < 4)
        {
            cupImage.material = null;
        }
        if (background && friend.username == Profile.Username)
        {
            background.color = Color.green;
        }

        int leagueIndex = GlobalFactory.Friends.GetLeagueIndex(friend.level.ToInt());

        medalImage.sprite = GlobalFactory.Friends.GetMedalSprite(leagueIndex);

        if (friend.username == Profile.Username || Profile.IsFriendRewarded(friend.id.ToInt(), friend.level.ToInt()))
        {
            descLabel.gameObject.SetActive(true);
            medalImage.gameObject.SetActive(true);
            cupImage.gameObject.SetActive(true);
            rewardButton.transform.parent.gameObject.SetActive(false);
        }
        else if (friend.level.ToInt() < GlobalConfig.Friends.minRewardLevel)
        {
            descLabel.gameObject.SetActive(false);
            medalImage.gameObject.SetActive(false);
            cupImage.gameObject.SetActive(false);
            rewardButton.transform.parent.gameObject.SetActive(true);
            rewardButton.SetInteractable(false);
            rewardDescLabel.gameObject.SetActive(true);
            rewardDescLabel.SetFormatedText(friend.level.ToInt(), GlobalConfig.Friends.minRewardLevel);
        }
        else
        {
            descLabel.gameObject.SetActive(false);
            medalImage.gameObject.SetActive(false);
            cupImage.gameObject.SetActive(false);
            rewardButton.transform.parent.gameObject.SetActive(true);
            rewardButton.SetInteractable(true);
            rewardDescLabel.gameObject.SetActive(true);
            rewardDescLabel.SetFormatedText(friend.level.ToInt(), GlobalConfig.Friends.minRewardLevel);

            rewardButton.onClick.AddListener(() =>
            {
                rewardButton.gameObject.SetActive(false);
                Profile.EarnGems(GlobalConfig.Friends.rewardGems);
                Profile.SetFriendRewarded(friend.id.ToInt(), GlobalConfig.Friends.rewardGems);
                Game.Instance.OpenPopup <Popup_Rewards>().Setup(0, GlobalConfig.Friends.rewardGems, 0, 0, 0, true, false, () =>
                {
                    descLabel.gameObject.SetActive(true);
                    medalImage.gameObject.SetActive(true);
                    cupImage.gameObject.SetActive(true);
                    rewardButton.transform.parent.gameObject.SetActive(false);
                });
                GlobalAnalytics.SourceGem(GlobalConfig.Friends.rewardGems, "friend");
            });
        }

        if (friend.username == Profile.Username)
        {
            return(this);
        }

        button.onClick.AddListener(() =>
        {
            Loading.Show();
            button.SetInteractable(false);
            Online.Userdata.GetPublic(friend.username, (succeed, data) =>
            {
                Loading.Hide();
                button.SetInteractable(true);
                if (succeed)
                {
                    Game.Instance.OpenPopup <Popup_ProfileInfo>().Setup(friend, data, rank);
                }
                else
                {
                    Game.Instance.OpenPopup <Popup_Confirm>().SetText(111010, friend.nickname).Setup(false, true, null);
                }
            });
        });

        return(this);
    }
Esempio n. 19
0
    private IEnumerator Start()
    {
        UIBackground.Show();
        UiShowHide.ShowAll(transform);

        onlineButton.onClick.AddListener(() =>
        {
            if (Profile.GetSeasonRewarded(0) > 0)
            {
                Game.Instance.OpenState <State_SelectLeague>();
            }
            else
            {
                tutorial.Display(0, false, 111034, null);
            }
        });

        classicButton.onClick.AddListener(() =>
        {
            if (ClassicLogics.SetPlayModel())
            {
                UIBackground.Hide();
                Game.Instance.OpenState <State_Playing>();
            }
        });

        if (Profile.IsFirstSession)
        {
            levelsButton.GetComponent <Animation>().Play();
        }
        levelsButton.onClick.AddListener(() => Game.Instance.OpenState <State_Levels>());

        luckyButton.onClick.AddListener(() =>
        {
            var seconds = Online.Timer.GetRemainSeconds(GlobalConfig.Luckyspin.timerId, GlobalConfig.Luckyspin.interval);
            if (seconds > 0)
            {
                Game.Instance.OpenPopup <Popup_Confirm>().SetText(111018, TimeToString(seconds)).Setup(true, false, null);
            }
            else
            {
                Online.Timer.Set(GlobalConfig.Luckyspin.timerId, GlobalConfig.Luckyspin.interval);
                Game.Instance.OpenPopup <Popup_LuckySpine>();
            }
        });


        if (Profile.IsFirstSession == false &&
            Profile.Version < GlobalConfig.Instance.version &&
            GlobalConfig.Update.mode == GlobalConfig.Data.Update.Mode.Null &&
            GlobalConfig.Update.rewardGems > 0)
        {
            Profile.Version = GlobalConfig.Instance.version;
            Game.Instance.OpenPopup <Popup_Confirm>().Setup(111129, true, false, ok =>
            {
                Game.Instance.OpenPopup <Popup_Rewards>().Setup(0, GlobalConfig.Update.rewardGems, 0, 0, 0, true, false, () => Profile.EarnGems(GlobalConfig.Update.rewardGems));
                GlobalAnalytics.SourceGem(GlobalConfig.Update.rewardGems, "update");
            });
        }

        var displayed = tutorial.Display(1, true, 111031, () => tutorial.Display(0, true, 111032, null));

        if (displayed == false)
        {
            tutorial.DisplayJoke(1);
        }

        var wait = new WaitForSeconds(1);

        while (true)
        {
            var seconds = Online.Timer.GetRemainSeconds(GlobalConfig.Luckyspin.timerId, GlobalConfig.Luckyspin.interval);
            if (seconds > 0)
            {
                luckyTimeLabel.transform.SetActiveChild(1);
                var h = seconds / 3600;
                var m = (seconds % 3600) / 60;
                var s = seconds % 60;
                luckyTimeLabel.SetFormatedText(h, m, s);
            }
            else
            {
                luckyTimeLabel.transform.SetActiveChild(0);
            }

            yield return(wait);
        }
    }