private void ToLevel(int exp) { if (LevelIni != null) { var count = LevelIni.Count; var i = 1; for (; i <= count; i++) { if (LevelIni.ContainsKey(i)) { if (LevelIni[i].LevelUpExp > exp) { break; } } } SetLevelTo(i); } }
public override void SetLevelTo(int level) { if (LevelIni == null) { Level = level; return; } Utils.LevelDetail detail = null, currentDetail = null; if (LevelIni.ContainsKey(level) && LevelIni.ContainsKey(Level)) { detail = LevelIni[level]; currentDetail = LevelIni[Level]; } if (detail != null) { LifeMax += (detail.LifeMax - currentDetail.LifeMax); ThewMax += (detail.ThewMax - currentDetail.ThewMax); ManaMax += (detail.ManaMax - currentDetail.ManaMax); Life = LifeMax; Thew = ThewMax; Mana = ManaMax; Attack += (detail.Attack - currentDetail.Attack); Defend += (detail.Defend - currentDetail.Defend); Evade += (detail.Evade - currentDetail.Evade); LevelUpExp = detail.LevelUpExp; if (!string.IsNullOrEmpty(detail.NewMagic)) { AddMagic(detail.NewMagic); } } else { Exp = 0; LevelUpExp = 0; } Level = level; }