Esempio n. 1
0
        public void ResetLevel(double curExp)
        {
            int           curLevel    = m_Data.level;
            Hero_dataItem levelConfig = Global.gApp.gGameData.HeroDataConfig.Get(curLevel);

            if (levelConfig == null)
            {
                levelConfig = Global.gApp.gGameData.HeroDataConfig.Get(Global.gApp.gGameData.HeroDataConfig.items.Length);
            }
            //等级发生变化
            if (curExp >= levelConfig.expRequire)
            {
                curLevel++;
                levelConfig = Global.gApp.gGameData.HeroDataConfig.Get(curLevel);
                while (curLevel <= Global.gApp.gGameData.HeroDataConfig.items.Length && curExp >= levelConfig.expRequire)
                {
                    curLevel++;
                    levelConfig = Global.gApp.gGameData.HeroDataConfig.Get(curLevel);
                }
                if (curLevel == Global.gApp.gGameData.HeroDataConfig.items.Length + 1)
                {
                    curLevel = Global.gApp.gGameData.HeroDataConfig.items.Length;
                }
            }
            else
            {
                while (curLevel > 1 && Global.gApp.gGameData.HeroDataConfig.Get(curLevel - 1).expRequire > curExp)
                {
                    curLevel--;
                    levelConfig = Global.gApp.gGameData.HeroDataConfig.Get(curLevel);
                }
                if (curLevel == 0)
                {
                    curLevel = 1;
                }
            }

            m_Data.exp = curExp;
            if (m_Data.level < curLevel)
            {
                LvUp = true;
            }
            m_Data.level = curLevel;
            SaveData();
            Global.gApp.gSystemMgr.GetQuestMgr().QuestChange(FilterTypeConstVal.CHAR_LEVEL, 0f);
            Global.gApp.gMsgDispatcher.Broadcast <double, int>(MsgIds.ExpChanged, curExp, curLevel);
        }
Esempio n. 2
0
        private void ExpChanged(double newExp, int newLevel)
        {
            level.text.text = newLevel.ToString();
            float beginExp;

            if (newLevel == 1)
            {
                beginExp = 0f;
            }
            else
            {
                Hero_dataItem lastConfig = Global.gApp.gGameData.HeroDataConfig.Get(newLevel - 1);
                beginExp = lastConfig.expRequire;
            }
            Hero_dataItem curConfig = Global.gApp.gGameData.HeroDataConfig.Get(newLevel);

            exp.image.fillAmount = (float)(newExp - beginExp) / (curConfig.expRequire - beginExp);
            Global.gApp.gMsgDispatcher.Broadcast(MsgIds.UIFresh);
        }