Пример #1
0
    private void SetProgress(CapsuleBattleResultData data, PlayerModel playerModel)
    {
        var player = playerModel.PlayerVo;

        _levelText.text  = "Lv." + player.Level;
        _expAddText.text = "+" + data.Exp + " exp";

        var isOnVip = GlobalData.PlayerModel.PlayerVo.IsOnVip;

        _vip.gameObject.SetActive(isOnVip);
        _userNameText.text = I18NManager.Get("Battle_Name", player.UserName);
        int lastNeedExp = player.NeedExp;

        _expText.text         = player.CurrentLevelExp + "/" + player.NeedExp;
        _progressBar.DeltaX   = 0;
        _progressBar.Progress = (int)((float)player.CurrentLevelExp / player.NeedExp * 100);
        bool isLevelup = playerModel.AddExp(data.Exp);
        int  rate      = (int)((float)player.CurrentLevelExp / player.NeedExp * 100);

        if (isLevelup)
        {
            if (player.Level >= 100)
            {
                _expText.text = "MAX";
            }
            else
            {
                DOTween.To(() => _progressBar.Progress, x => _progressBar.Progress = x, 100, 0.3f).SetDelay(0.9f)
                .onComplete =
                    () =>
                {
                    _expText.text         = player.CurrentLevelExp + "/" + player.NeedExp;
                    _progressBar.DeltaX   = 0;
                    _progressBar.Progress = 0;
                    DOTween.To(() => _progressBar.Progress, x => _progressBar.Progress = x, rate, 0.3f)
                    .SetDelay(1.3f);
                    Util.TweenTextNum(_expText, 0.3f, player.CurrentLevelExp, "", "/" + player.NeedExp);
                    _levelText.text = "Lv." + player.Level;
                };

                Util.TweenTextNum(_expText, 0.3f, lastNeedExp, "", "/" + lastNeedExp);
            }
        }
        else
        {
            if (player.Level >= 100)
            {
                _expText.text = "MAX";
            }
            else
            {
                DOTween.To(() => _progressBar.Progress, x => _progressBar.Progress = x, rate, 0.3f).SetDelay(0.9f);
                Util.TweenTextNum(_expText, 0.3f, player.CurrentLevelExp, "", "/" + player.NeedExp);
            }
        }
    }
Пример #2
0
 public void AddExp(float exp)
 {
     if (_playerModel.AddExp(exp))
     {
         Instantiate(_playerModel.LvlUpEffect, this.transform);
         _healthBar.SetLvl(_playerModel.level.ToString());
         _healthBar.SetSize(_playerModel.CurrentHealth / _playerModel.baseHealth);
         _healthBar.SetMaxProgress(_playerModel.expToNextLvl.ToString());
     }
     _healthBar.SetProgress(_playerModel.exp.ToString());
 }
    public void SetData(VisitBattleResultData data, PlayerModel playerModel)
    {
        transform.Find("StarAndGrade/Star").GetComponent <VisitStarComponent>().ShowStar(data.Star);
        // transform.Find("StarAndGrade/Text").GetComponent<Text>().text = "应援热度:<b> " + data.Cap + "</b>";
        transform.Find("StarAndGrade/Text/Text").GetComponent <Text>().text = data.Cap.ToString();
        var propContainer = transform.Find("Reward/Props");
        var cardContainer = transform.Find("Cards");

        for (int i = 0; i < data.RewardList.Count; i++)
        {
            GameObject item = InstantiatePrefab("VisitBattle/FinalEstimate/VisitBattleRewardItem");
            item.transform.SetParent(propContainer, false);

            DrawActivityDropItemVo extReward;
            data.DrawActivityDropItemDict.TryGetValue(i, out extReward);

            item.transform.gameObject.AddComponent <VisitBattleRewardItem>().SetData(data.RewardList[i], extReward);
            item.GetComponent <ItemShowEffect>().OnShowEffect(0.3f + i * 0.2f);
        }

        PlayerVo player = playerModel.PlayerVo;

        _levelText.text  = "Lv." + player.Level;
        _expAddText.text = "+" + data.Exp + " exp";

        var isOnVip = GlobalData.PlayerModel.PlayerVo.IsOnVip;

        _vip.gameObject.SetActive(isOnVip);

        _userNameText.text = I18NManager.Get("Battle_Name", player.UserName);

        int lastNeedExp = player.NeedExp;

        _expText.text = player.CurrentLevelExp + "/" + player.NeedExp;

        progressBar.DeltaX   = 0;
        progressBar.Progress = (int)((float)player.CurrentLevelExp / player.NeedExp * 100);

        bool isLevelup = playerModel.AddExp(data.Exp);

        int rate = (int)((float)player.CurrentLevelExp / player.NeedExp * 100);

        if (isLevelup)
        {
            if (player.Level >= 100)
            {
                _expText.text = "MAX";
            }
            else
            {
                DOTween.To(() => progressBar.Progress, x => progressBar.Progress = x, 100, 0.3f).SetDelay(0.9f)
                .onComplete =
                    () =>
                {
                    _expText.text        = player.CurrentLevelExp + "/" + player.NeedExp;
                    progressBar.DeltaX   = 0;
                    progressBar.Progress = 0;
                    DOTween.To(() => progressBar.Progress, x => progressBar.Progress = x, rate, 0.3f)
                    .SetDelay(1.3f);
                    Util.TweenTextNum(_expText, 0.3f, player.CurrentLevelExp, "", "/" + player.NeedExp);
                    _levelText.text = "Lv." + player.Level;
                };

                Util.TweenTextNum(_expText, 0.3f, lastNeedExp, "", "/" + lastNeedExp);
            }
        }
        else
        {
            if (player.Level >= 100)
            {
                _expText.text = "MAX";
            }
            else
            {
                DOTween.To(() => progressBar.Progress, x => progressBar.Progress = x, rate, 0.3f).SetDelay(0.9f);
                Util.TweenTextNum(_expText, 0.3f, player.CurrentLevelExp, "", "/" + player.NeedExp);
            }
        }

        for (int i = 0; i < data.UserCards.Count; i++)
        {
            GameObject item = InstantiatePrefab("Battle/FinalEstimate/RewardHeroCard");
            item.transform.SetParent(cardContainer, false);
            item.AddComponent <ItemShowEffect>().OnShowEffect(1 + i * 0.2f);

            var cardData = GlobalData.CardModel.GetUserCardById(data.UserCards[i].CardId);
            item.transform.GetComponent <RewardHeroCard>().SetData(cardData, data.CardExp);
        }

        StartCoroutine(StarRotation());
    }