void OnClickLevelUpEvenly() { if (battleGroup != Battle.currentBattleGroup) { return; } //가장 낮은 레벨 int minLevel = 0; battleGroup.originalMember.Min(x => minLevel = x.heroData.level); //필요한 경험치 총량 double requiredExp = 0d; for (int i = 0; i < battleGroup.originalMember.Count; i++) { BattleHero hero = battleGroup.originalMember[i]; if (hero.heroData.level == minLevel) { requiredExp += hero.LevelUpExpValue; } } //Debug.Log(minLevel + ", count: " + heroCount + ", required exp: " + requiredExp + ", totalExp" + totalExp); //균등하게 올리기 위해 필요한 경험치가 전체 경험치 보다 많으면 실행 안 됨 if (requiredExp > totalExp) { return; } //레벨 젤 낮은 애들만 레벨 올림 for (int i = 0; i < battleGroup.originalMember.Count; i++) { BattleHero hero = battleGroup.originalMember[i]; if (hero.heroData.level == minLevel) { //totalExp -= hero.LevelUpExpValue; hero.LevelUp(hero.LevelUpExpValue); } } totalExp -= requiredExp; }
void OnClickLevelUp(BattleHero battleHero) { if (heroList == null) { return; } if (battleGroup != Battle.currentBattleGroup) { return; } if (battleHero.LevelUpExpValue > totalExp) { Debug.Log("Not enough exp"); return; } totalExp -= battleHero.LevelUpExpValue; battleHero.LevelUp(battleHero.LevelUpExpValue); }