예제 #1
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);
        }
    }
예제 #2
0
 private void BuyBooster(int count, int price, string booster, System.Action <int> onSuccess)
 {
     Game.Instance.OpenPopup <Popup_Confirm>().SetText(111003, count, price).Setup(true, true, yes =>
     {
         if (yes == false)
         {
             return;
         }
         Game.SpendGems(price, () =>
         {
             onSuccess(count);
             UpdateTexts();
             if (PlayModel.IsClassic)
             {
                 GlobalAnalytics.SinkGem(price, "classic", booster);
             }
             else if (PlayModel.IsLeague)
             {
                 GlobalAnalytics.SinkGem(price, "leagues", booster);
             }
             else if (PlayModel.IsLevels)
             {
                 GlobalAnalytics.SinkGem(price, "levels", booster);
             }
         });
     });
 }
예제 #3
0
    public UiProfileBallItem Setup(int ballId)
    {
        id = ballId;
        ballImage.sprite = GlobalFactory.Balls.GetSprite(ballId);
        UpdateState();

        button.onClick.AddListener(() =>
        {
            switch (currState)
            {
            case State.Owned:
                {
                    Profile.Avatar.BallId = ballId;
                    transform.root.Broadcast(Messages.Type.AvatarChanged, Profile.Avatar.Current);
                }
                break;

            case State.Enabled:
                {
                    var price = GlobalFactory.Balls.GetPrice(ballId);
                    Game.SpendGems(price, () =>
                    {
                        Profile.AddBall(ballId);
                        Profile.Avatar.BallId = ballId;
                        Game.Instance.OpenPopup <Popup_Rewards>().Setup(ballId, 0, 0, 0, 0, true, false, () =>
                        {
                            transform.parent.Broadcast(Messages.Type.BallPurchased);
                            transform.root.Broadcast(Messages.Type.AvatarChanged, Profile.Avatar.Current);
                        });
                        GlobalAnalytics.SinkGem(price, "profile", "ball");
                    });
                }
                break;

            case State.Disabled:
                break;
            }
        });
        return(this);
    }