public ExpChangeResult AddExp(int heroId, int exp) { Hero hero = GetHero(heroId); DataHeroGroup dataHeroGroup = DataManager.instance.dataHeroGroup; int maxExp = dataHeroGroup.GetMaxExp(heroId); exp = (int)Mathf.Min(exp, maxExp - hero.exp); ExpChangeResult r = new ExpChangeResult(); r.heroId = heroId; r.expChanged = exp; int oldLevel = GetCurrentLevel(heroId); hero.exp += exp; r.exp = hero.exp; int newLevel = GetCurrentLevel(heroId); r.level = newLevel; r.levelChanged = newLevel - oldLevel; return(r); }
public void Init() { allHeroDataList.Clear(); heroGroupData = DataManager.instance.dataHeroGroup; heroesMap = heroGroupData.heroesMap; foreach (KeyValuePair <int, DataHero> kvp in heroesMap) { HeroData heroData = new HeroData(); heroData = InitHeroData(kvp.Value); allHeroDataList.Add(heroData); } }