Exemplo n.º 1
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);
            }
        }
    }
Exemplo n.º 2
0
    private static void OnReward(System.Action onClose)
    {
        var reward = PlayModel.GetReward();

        Game.Instance.OpenPopup <Popup_Rewards>().Setup(0, reward.gems, 0, 0, 0, true, true, onClose);
    }