Beispiel #1
0
        public void SetHeroData(int heroId, int addHeroExp, float delay = 0)
        {
            HeroInfo info = HeroProxy.instance.GetHeroInfo((uint)heroId);

            if (info == null)
            {
                return;
            }
            HeroInfo temp     = new HeroInfo(info.instanceID, info.heroData.id, 0, 0, info.advanceLevel);
            int      totalExp = info.TotalLevelUpExp - addHeroExp;

            HeroExpData oldData = HeroExpData.GetHeroExpData(totalExp);
            bool        isMax   = oldData == null;

            if (isMax)
            {
                temp = info;
            }
            else
            {
                temp.level = HeroExpData.GetHeroExpData(totalExp).lv;
                temp.exp   = totalExp - HeroExpData.GetHeroExpDataByLv(temp.level - 1).exp_total;
            }

            //Debugger.Log(string.Format("[HeroView][SetHeroData]heroid: {0}, old exp:{1}, old level: {2}, new exp:{3},  new level :{4}, addExp:{5}",heroId,temp.exp,temp.level,info.exp,info.level,addHeroExp));
            SetHeroData(temp, addHeroExp, delay);
        }
Beispiel #2
0
        public void SetMainHeroData(int addHeroExp, int addAccountExp, float delay = 0)
        {
            PlayerInfo playerInfo = GameProxy.instance.PlayerInfo;

            PlayerInfo temp = new PlayerInfo(playerInfo.instanceID, playerInfo.playerData.Id, 0, 0, 0, 0, "");

            int         expTotal = playerInfo.TotalLevelUpExp - addHeroExp;
            HeroExpData oldData  = HeroExpData.GetHeroExpData(expTotal);
            bool        isMax    = oldData == null;

            if (isMax)
            {
                temp = playerInfo;
            }
            else
            {
                temp.level = HeroExpData.GetHeroExpData(expTotal).lv;
                temp.exp   = expTotal - HeroExpData.GetHeroExpDataByLv(temp.level - 1).exp_total;
            }

            //Debugger.Log(string.Format("[HeroView][SetMainHeroData]playerid: {0}, old exp:{1}, old level: {2}, addheroExp:{3},addAccount:{4}",playerInfo.instanceID,temp.exp,temp.level,addHeroExp,addAccountExp));

            SetMainHeroData(temp, addHeroExp, addAccountExp, delay);
        }
Beispiel #3
0
        private void InitBar()
        {
            float percent = 0;

            if (_isLeader)
            {
                HeroExpData curHeroExpData = HeroExpData.GetHeroExpDataByLv(_oldPlayerInfo.level);
                HeroExpData next           = HeroExpData.GetHeroExpData(_oldPlayerInfo.TotalLevelUpExp, _addHeroExp);
                if (curHeroExpData == null)
                {
                    exp_hero_bar.ChangeValue(0);
                }
                else
                {
                    percent = (_oldPlayerInfo.exp + 0.0f) / curHeroExpData.exp;
                    exp_hero_bar.ChangeValue(percent);
                }

                if (next == null)
                {
                    _nextHeroLevel = GameProxy.instance.PlayerInfo.level;
                }
                else
                {
                    _nextHeroLevel = next.lv;
                }


                exp_profession_bar.ChangeValue(0);
                //account
                InitAccountBar();
                if (_addAcountExp != 0)
                {
                    StartCoroutine(UpdateAccountBarDelay(_delayTime));
                }
            }
            else
            {
                exp_profession_bar.gameObject.SetActive(false);


                HeroExpData curHeroExpData = HeroExpData.GetHeroExpDataByLv(_oldHeroInfo.level);
                HeroExpData next           = HeroExpData.GetHeroExpData(_oldHeroInfo.TotalLevelUpExp, _addHeroExp);
                if (curHeroExpData == null)
                {
                    exp_hero_bar.ChangeValue(0);
                }
                else
                {
                    percent = (_oldHeroInfo.exp + 0.0f) / curHeroExpData.exp;
                    exp_hero_bar.ChangeValue(percent);
                }
                if (next == null)
                {
                    _nextHeroLevel = HeroProxy.instance.GetHeroInfo(_oldHeroInfo.instanceID).level;
                }
                else
                {
                    _nextHeroLevel = next.lv;
                }
            }
            if (expAddText != null)
            {
                expAddText.text = string.Format(Localization.Get("ui.fightResultView.hero_exp_add"), _addHeroExp);
            }
            text_lv.text = string.Format(Localization.Get("common.role_icon.role_lv"), _curHeroLevel);
            if (_addHeroExp != 0)
            {
                StartCoroutine(UpdateHeroBarDelay(_delayTime));
            }
        }