示例#1
0
    public Popup_ProfileInfo Setup(int leagueId, Online.League.Profile profile, string userdata)
    {
        avatar.Setup(profile.avatar);
        nicknameLabel.SetText(profile.nickname);
        statusLabel.SetText(profile.status);
        scoreLabel.SetText(profile.score.ToString());
        rankLabel.SetText(profile.rank > 0 ? profile.rank.ToString() : "-");

        var league    = GlobalFactory.Leagues.GetById(leagueId);
        var subleague = GlobalFactory.Leagues.GetByScore(league, profile.score);

        medalImage.sprite = GlobalFactory.Leagues.GetMedal(league, profile.score);
        medalLabel.SetText(subleague.name);
        medalButton.onClick.AddListener(() => Game.Instance.OpenPopup <Popup_MedalInfo>().Setup(league));

        if (userdata != null)
        {
            var data = JsonUtility.FromJson <ProfileData.PublicData>(Utilities.DecompressString(userdata, "{}"));
            data.balls.Reverse();
            foreach (var ballId in data.balls)
            {
                ballPrefab.Clone <Image>().sprite = GlobalFactory.Balls.GetSprite(ballId);
            }
            Destroy(ballPrefab.gameObject);
        }
        else
        {
            ballPrefab.sprite = GlobalFactory.Balls.GetSprite(0);
        }

        return(this);
    }
示例#2
0
    private void UpdateState()
    {
        if (Profile.HasBall(id))
        {
            currState       = lastState = State.Owned;
            backImage.color = Color.white;
            if (priceLabel)
            {
                priceLabel.transform.parent.gameObject.SetActive(false);
                Destroy(priceLabel.transform.parent.gameObject);
            }
        }
        else if (lastState == State.Owned) // remain from previuse item
        {
            currState       = lastState = State.Enabled;
            backImage.color = Color.white;
            priceLabel.SetText(GlobalFactory.Balls.GetPrice(id).ToString());
        }
        else
        {
            currState       = lastState = State.Disabled;
            backImage.color = Color.gray;
#if UNITY_EDITOR && OFF
            var price = GlobalFactory.Balls.GetPrice(id);
            totalPrice += price;
            priceLabel.SetText(price.ToString());
            Debug.LogWarning(totalPrice);
#else
            priceLabel.SetText("?");
#endif
        }
    }
示例#3
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);
        }
    }
示例#4
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);
        }
    }
示例#5
0
    // Use this for initialization
    private IEnumerator Start()
    {
        UIBackground.Show();
        LeagueLogics.info = GlobalConfig.Leagues[LeagueLogics.LeagueIndex];

        title.SetText(LeagueLogics.info.name);
        descLabel.SetText(LeagueLogics.info.desc);
        iconImage.sprite = GlobalFactory.Leagues.GetCupSprite(LeagueLogics.info.playType);
        boardButton.SetInteractable(false);
        playButton.SetInteractable(false);

        medalButton.onClick.AddListener(() => Game.Instance.OpenPopup <Popup_MedalInfo>().Setup(LeagueLogics.info));
        rewardButton.onClick.AddListener(() => OnRewardButton(LeagueLogics.info));
        boardButton.onClick.AddListener(() => Game.Instance.OpenPopup <State_Leaderboards>().Setup(LeagueLogics.info.id));
        rewardsButton.onClick = medalButton.onClick;

        playButton.onClick.AddListener(() =>
        {
            if (LeagueLogics.SetPlayerModel())
            {
                base.Back();
                UIBackground.Hide();
                Game.Instance.OpenState <State_Playing>();
            }
        });

        if (LeagueLogics.data == null)
        {
            Loading.Show();
            Online.League.GetData(LeagueLogics.info.id, (success, res) =>
            {
                Loading.Hide();
                if (success)
                {
                    LeagueLogics.data = res;
                    UpdateView();
                    UiShowHide.ShowAll(transform);
                }
                else
                {
                    base.Back();
                }
            });
        }
        else
        {
            UiShowHide.ShowAll(transform);
        }

        tutorial.Display(1, true, 111060, null);

        var wait = new WaitForSeconds(1);

        while (true)
        {
            UpdateView();
            yield return(wait);
        }
    }
示例#6
0
 public bool Display(float delay, string str, System.Action onClose)
 {
     Visible = true;
     label.SetText(str);
     onCloseFunc = onClose;
     Invoke("Show", delay);
     return(true);
 }
示例#7
0
    private void Start()
    {
        Loading.Show();
        UIBackground.Show();
        var info = GlobalConfig.Leagues[leagueIndex];

        title.SetText(info.name);
        prefabItem.gameObject.SetActive(false);
        playButton.onClick.AddListener(() => Game.Instance.OpenPopup <Popup_LeagueInfo>().Setup(leagueIndex, leaderboard));

        Online.League.GetLeaderboard(info.id, 0, 100, (succeed, board) =>
        {
            Loading.Hide();
            if (succeed)
            {
                UpdatePlayerToList(board);

                board.last.Sort((x, y) => y.score - x.score);
                board.current.Sort((x, y) => y.score - x.score);

                for (int i = 0; i < board.last.Count; i++)
                {
                    board.last[i].rank = i + 1;
                }

                for (int i = 0; i < board.current.Count; i++)
                {
                    board.current[i].rank = i + 1;
                }

                for (int i = 0; i < legends.Length; i++)
                {
                    legends[i].Setup(info.id, i < board.last.Count ? board.last[i] : new Online.League.Profile(), false);
                }

                foreach (var item in board.current)
                {
                    prefabItem.Clone <UiLeaderboardItem>().Setup(info.id, item).gameObject.SetActive(true);
                }
                Destroy(prefabItem.gameObject);

                leaderboard = board;
                UiShowHide.ShowAll(transform);
            }
            else
            {
                Back();
                return;
            }
        });
    }
示例#8
0
    // Use this for initialization
    private IEnumerator Start()
    {
        AudioManager.SetMusicVolumFactor(0.7f);

        instance = this;
        transform.SetAsFirstSibling();

        foreach (AnimationState state in backgroundAnimator)
        {
            state.time = Random.Range(0, 120);
            break;
        }

        heartsButton.onClick.AddListener(() => { if (Profile.Hearts < GlobalConfig.ProfilePreset.hearts)
                                                 {
                                                     Game.Instance.OpenPopup <Popup_BuyHearts>();
                                                 }
                                         });
        gemsButton.onClick.AddListener(() => { Game.Instance.OpenPopup <Popup_Shop>(); });
        profileButton.onClick.AddListener(() => { Game.Instance.OpenPopup <Popup_Profile>(); });
        updateButton.onClick.AddListener(() => { Application.OpenURL(GlobalConfig.Market.storeUrl); });
        settingsButton.onClick.AddListener(() => { Game.Instance.OpenPopup <Popup_Settings>(); });

        UiShowHide.ShowAll(transform);

        var wait = new WaitForSeconds(0.5f);

        while (true)
        {
            avatar.Setup(Profile.Avatar.Current);
            updateButton.gameObject.SetActive(GlobalConfig.Update.mode != GlobalConfig.Data.Update.Mode.Null);
            nickNameLabel.SetText(Profile.Nickname);
            gems.SetText(Profile.Gems.ToString("#,0"));
            heartsCount.SetText(Profile.Hearts.ToString());

            if (Profile.Hearts < GlobalConfig.ProfilePreset.hearts)
            {
                int seconds = Online.Timer.GetRemainSeconds(GlobalConfig.Heart.timerId, GlobalConfig.Heart.interval);
                heartsTime.text = (seconds / 60).ToString("00") + ":" + (seconds % 60).ToString("00");
                heartsTime.gameObject.SetActive(true);
                heartsFull.gameObject.SetActive(false);
            }
            else
            {
                heartsTime.gameObject.SetActive(false);
                heartsFull.gameObject.SetActive(true);
            }
            yield return(wait);
        }
    }
示例#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);
    }
示例#10
0
    // Use this for initialization
    private IEnumerator Start()
    {
        var wait = new WaitForSeconds(0.5f);

        while (pack != null && timeLabel && pack.discount > 0)
        {
            int seconds = PurchaseOffer.RemainedTime;
            if (seconds < 0)
            {
                gameObject.SetActive(false);
            }
            else
            {
                timeLabel.SetText(Utilities.TimeToString(seconds, 0));
            }
            yield return(wait);
        }
    }
示例#11
0
    // Use this for initialization
    private IEnumerator Start()
    {
        UiShowHide.ShowAll(transform);

        yield return(new WaitForSeconds(1));

        hint.gameObject.SetActive(true);
        hint.SetText(LocalizationService.Get(111045 + HintId++ % 5));

        var wait = new WaitForSeconds(0.5f);

        while (true)
        {
            if (PurchaseOffer.RemainedTime < 0)
            {
                Exit(false);
            }
            yield return(wait);
        }
    }
示例#12
0
    // Use this for initialization
    private void Start()
    {
        var league = GlobalConfig.Leagues[index];

        image.sprite = GlobalFactory.Leagues.GetCupSprite(league.playType);
        nameLabel.SetText(league.name);
        descLabel.SetText(league.desc);

        if (league.ribbon.HasContent())
        {
            ribbonLabel.SetText(league.ribbon);
        }
        else
        {
            ribbonLabel.gameObject.SetActive(false);
        }

        button.onClick.AddListener(() =>
        {
            if (Profile.HasNickname)
            {
                Game.Instance.OpenState <State_Leaderboards>().Setup(index);
            }
            else
            {
                Game.Instance.OpenPopup <Popup_Confirm>().Setup(111011, true, false, ok =>
                {
                    if (ok)
                    {
                        Game.Instance.OpenPopup <Popup_Profile>().SetOnClose(() =>
                        {
                            if (Profile.HasNickname)
                            {
                                Game.Instance.OpenPopup <Popup_Confirm>().Setup(111012, true, false, null);
                            }
                        });
                    }
                });
            }
        });
    }
示例#13
0
    private IEnumerator Start()
    {
        var index = PurchaseOffer.GetOfferIndex(Profile.Gems);

        if (index.Between(0, GlobalConfig.Shop.offers.Count - 1))
        {
            var item = combinedItem.Clone <UiShopItem>();
            item.Setup(GlobalConfig.Shop.offers[index].sku, success =>
            {
                PurchaseOffer.SetPurchaseResult(success);
                item.gameObject.SetActive(success == false);
            });
        }

        foreach (var item in GlobalConfig.Shop.combinedPackages)
        {
            combinedItem.Clone <UiShopItem>().Setup(item.sku);
        }

        foreach (var item in GlobalConfig.Shop.gemPackages)
        {
            gemsItem.Clone <UiShopItem>().Setup(item.sku);
        }
        gemsItem.transform.parent.SetAsLastSibling();

        Destroy(combinedItem.gameObject);
        Destroy(gemsItem.gameObject);

        UiShowHide.ShowAll(transform);

        var wait = new WaitForSeconds(0.5f);

        while (true)
        {
            gemsLabel.SetText(Profile.Gems.ToString("#,0"));
            yield return(wait);
        }
    }
示例#14
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);
        }
    }
示例#15
0
    private IEnumerator Start()
    {
        UiShowHide.ShowAll(transform);

        if (doOpenChest)
        {
            //yield return new WaitForSeconds(0.5f);
            chest.Open();
        }

        yield return(new WaitUntil(() => chest.IsOpened));

        yield return(new WaitForSeconds(1));

        while (window.anchoredPosition.sqrMagnitude > 5)
        {
            window.anchoredPosition = Vector3.Lerp(window.anchoredPosition, Vector3.zero, Time.deltaTime * 10);
            yield return(new WaitForEndOfFrame());
        }

        //if (rgems > 0)
        {
            var wait = new WaitForEndOfFrame();
            while (true)
            {
                if (rtime < 1)
                {
                    rtime += Time.deltaTime;
                    gemsLabel.SetText("+" + Mathf.RoundToInt(Mathf.Lerp(0, rgems, rtime)));
                    bombsLabel.SetText("+" + Mathf.RoundToInt(Mathf.Lerp(0, rbombs, rtime)));
                    hammersLabel.SetText("+" + Mathf.RoundToInt(Mathf.Lerp(0, rhammers, rtime)));
                    missilesLabel.SetText("+" + Mathf.RoundToInt(Mathf.Lerp(0, rmissiles, rtime)));
                }
                yield return(wait);
            }
        }
    }
示例#16
0
 private void UpdateTexts()
 {
     bombLabel.SetText(Profile.Bombs > 0 ? Profile.Bombs.ToString() : "+");
     hammerLabel.SetText(Profile.Hammers > 0 ? Profile.Hammers.ToString() : "+");
     missleLabel.SetText(Profile.Missiles > 0 ? Profile.Missiles.ToString() : "+");
 }
示例#17
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);
    }
示例#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);
    }
示例#19
0
文件: Popup_Win.cs 项目: seganx/ameza
    // 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);
            }
        }
    }
示例#20
0
    public UiLeaderboardItem Setup(int leagueId, Online.League.Profile profile, bool setCupMaterial = true)
    {
        var info = GlobalFactory.Leagues.GetById(leagueId);

        if (background)
        {
            background.color = profile.username == Profile.Username ? playerColor : Color.white;
        }
        if (avatar)
        {
            avatar.Setup(profile.avatar);
        }
        if (nicknameLabel)
        {
            nicknameLabel.SetText(profile.nickname);
        }
        if (descLabel)
        {
            descLabel.SetText(profile.status);
        }
        if (scoreLabel)
        {
            scoreLabel.SetText(profile.score.ToString());
        }
        if (rankLabel)
        {
            rankLabel.SetText(profile.rank > 0 ? profile.rank.ToString() : "-");
        }
        if (medalImage)
        {
            medalImage.sprite = GlobalFactory.Leagues.GetMedal(info, profile.score);
        }

        if (cupImage)
        {
            cupImage.sprite = GlobalFactory.Leagues.GetCupSprite(info.playType);
            if (setCupMaterial && profile.rank < 4)
            {
                cupImage.material = null;
            }
        }

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

        return(this);
    }
示例#21
0
    // Use this for initialization
    private IEnumerator Start()
    {
        UiShowHide.ShowAll(transform);
        avatar.Setup(Profile.Avatar.Current);

        nicknameInput.text = Profile.HasNickname ? Profile.Nickname : Profile.Username;
        nicknamePrice.transform.parent.gameObject.SetActive(Profile.HasNickname);
        nicknamePrice.SetText(GlobalConfig.Shop.nicknamePrice.ToString());
        nicknameButton.onClick.AddListener(() =>
        {
            if (nicknameInput.text.ComputeMD5(Core.Salt) != "AC9CD53769E38CBBD8707CA1108BA10D")
            {
                var nickname = nicknameInput.text.Trim().CleanFromCode().CleanForPersian();
#if UNITY_EDITOR_off
                SendNickname(nickname);
#else
                if (nickname != Profile.Username && nickname.HasContent(3) && nickname.IsLetterOrDigit() && BadWordsFinder.HasBadWord(nickname) == false)
                {
                    if (Profile.HasNickname)
                    {
                        Game.SpendGems(GlobalConfig.Shop.nicknamePrice, () => SendNickname(nickname));
                    }
                    else
                    {
                        SendNickname(nickname);
                    }
                }
                else
                {
                    Game.Instance.OpenPopup <Popup_Confirm>().Setup(111001, false, true, null);
                }
#endif
            }
            else
            {
                GlobalConfig.DebugMode = true;
            }
        });

        statusInput.text = Profile.Status;
        statusPrice.transform.parent.gameObject.SetActive(Profile.HasStatus);
        statusPrice.SetText(GlobalConfig.Shop.statusPrice.ToString());
        statusButton.onClick.AddListener(() =>
        {
            var status = statusInput.text.Trim().CleanFromCode().CleanForPersian();
#if UNITY_EDITOR_off
            SendStatus(status);
#else
            if (status.HasContent(3) && status.IsLetterOrDigit() && BadWordsFinder.HasBadWord(status) == false)
            {
                if (Profile.HasStatus)
                {
                    Game.SpendGems(GlobalConfig.Shop.statusPrice, () => SendStatus(status));
                }
                else
                {
                    SendStatus(status);
                }
            }
            else
            {
                Game.Instance.OpenPopup <Popup_Confirm>().Setup(111002, false, true, null);
            }
#endif
        });

        hairSlider.minValue = 0;
        hairSlider.maxValue = 360;
        hairSlider.value    = Profile.Avatar.Angle;
        hairSlider.onValueChanged.AddListener(value =>
        {
            Profile.Avatar.Angle = value.ToInt();
            avatar.Setup(Profile.Avatar.Current);
            Game.Instance.CurrentState.Broadcast(Messages.Type.AvatarChanged, Profile.Avatar.Current);
        });

        for (int i = 0; i < GlobalFactory.Balls.Count; i++)
        {
            if (GlobalFactory.Balls.GetSprite(i) != null)
            {
                itemPrefab.Clone <UiProfileBallItem>().Setup(i).gameObject.SetActive(true);
            }
        }

        yield return(new WaitForSeconds(0.1f));

        ballsScroller.content.anchoredPosition = Vector2.down * (UiProfileBallItem.unlockedPosition.y + 100);
    }
示例#22
0
    private IEnumerator Start()
    {
        levelNameLabel.SetText(PlayModel.level.name);

        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // enable or disbale information billboards
        if (PlayModel.IsLeague)
        {
            scoreImage.sprite = GlobalFactory.Leagues.GetCupSprite(PlayModel.type);
            scoreImage.gameObject.SetActive(true);
        }
        else if (PlayModel.IsClassic)
        {
            scoreImage.sprite = GlobalFactory.Balls.GetSprite(PlayModel.ballId);
            scoreImage.gameObject.SetActive(true);
        }
        else
        {
            scoreImage.gameObject.SetActive(false);
        }

        if (PlayModel.level.targetBlocks > 0)
        {
            blocksLabel.transform.parent.gameObject.SetActive(true);
        }
        else
        {
            blocksLabel.transform.parent.gameObject.SetActive(false);
        }

        if (PlayModel.level.targetBalls > 0)
        {
            ballsLabel.transform.parent.gameObject.SetActive(true);
            ballsImage.sprite = GlobalFactory.Balls.GetSprite(PlayModel.ballId);
        }
        else
        {
            ballsLabel.transform.parent.gameObject.SetActive(false);
        }

        if (PlayModel.level.targetItem0 > 0)
        {
            item0Label.transform.parent.gameObject.SetActive(true);
            item0Image.sprite = GlobalFactory.Theme.Selected.items[0];
        }
        else
        {
            item0Label.transform.parent.gameObject.SetActive(false);
        }

        if (PlayModel.level.targetItem1 > 0)
        {
            item1Label.transform.parent.gameObject.SetActive(true);
            item1Image.sprite = GlobalFactory.Theme.Selected.items[1];
        }
        else
        {
            item1Label.transform.parent.gameObject.SetActive(false);
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////


        /////////////////////////////////////////////////////////////////////////////////////////////////////
        /// entering loop and update information billboards
        var wait = new WaitForSeconds(0.1f);

        while (true)
        {
            if (PlayModel.level.targetBlocks > 0)
            {
                var diff = PlayModel.level.targetBlocks - PlayModel.result.totalBlocks;
                if (diff < 1)
                {
                    blocksLabel.gameObject.SetActive(false);
                    blocksChecked.gameObject.SetActive(true);
                }
                else
                {
                    blocksLabel.SetText(diff.ToString());
                }
            }

            if (PlayModel.level.targetBalls > 0)
            {
                var diff = PlayModel.level.targetBalls - PlayModel.result.totalBalls;
                if (diff < 1)
                {
                    ballsLabel.gameObject.SetActive(false);
                    ballsChecked.gameObject.SetActive(true);
                }
                else
                {
                    ballsLabel.SetText(diff.ToString());
                }
            }

            if (PlayModel.level.targetItem0 > 0)
            {
                var diff = PlayModel.level.targetItem0 - PlayModel.result.totalItem0;
                if (diff < 1)
                {
                    item0Label.gameObject.SetActive(false);
                    item0Checked.gameObject.SetActive(true);
                }
                else
                {
                    item0Label.SetText(diff.ToString());
                }
            }

            if (PlayModel.level.targetItem1 > 0)
            {
                var diff = PlayModel.level.targetItem1 - PlayModel.result.totalItem1;
                if (diff < 1)
                {
                    item1Label.gameObject.SetActive(false);
                    item1Checked.gameObject.SetActive(true);
                }
                else
                {
                    item1Label.SetText(diff.ToString());
                }
            }

            switch (PlayModel.type)
            {
            case PlayModel.Type.LeagueBalls:
                scoreLabel.SetText(PlayModel.result.totalBalls.ToString());
                break;

            case PlayModel.Type.LeagueBlocks:
                scoreLabel.SetText(PlayModel.result.totalBlocks.ToString());
                break;

            case PlayModel.Type.LeagueLegends:
                scoreLabel.SetText(PlayModel.result.totalLegends.ToString());
                break;

            case PlayModel.Type.Classic:
                scoreLabel.SetText(PlayModel.result.totalBalls.ToString());
                break;
            }

            yield return(wait);
        }
    }