修了不少东西
This commit is contained in:
@@ -1140,17 +1140,37 @@ public class AllyCombatant : MonoBehaviour, ICombatant
|
||||
private static AllyHero_SO.AllyLevelInfo GetEffectiveLevelForExp(AllyHero_SO so, int exp)
|
||||
{
|
||||
if (so == null || so.levelStats == null || so.levelStats.Count == 0) return null;
|
||||
AllyHero_SO.AllyLevelInfo best = null;
|
||||
foreach (var lvl in so.levelStats)
|
||||
|
||||
List<AllyHero_SO.AllyLevelInfo> sorted = new List<AllyHero_SO.AllyLevelInfo>();
|
||||
foreach (var levelInfo in so.levelStats)
|
||||
{
|
||||
if (lvl == null) continue;
|
||||
if (exp >= lvl.requiredEXP)
|
||||
if (levelInfo != null)
|
||||
{
|
||||
if (best == null || lvl.requiredEXP >= best.requiredEXP)
|
||||
best = lvl;
|
||||
sorted.Add(levelInfo);
|
||||
}
|
||||
}
|
||||
return best ?? so.levelStats[0];
|
||||
|
||||
if (sorted.Count == 0) return null;
|
||||
sorted.Sort((left, right) => left.requiredEXP.CompareTo(right.requiredEXP));
|
||||
|
||||
int expQualifiedIndex = 0;
|
||||
int safeExp = Mathf.Max(0, exp);
|
||||
for (int i = 0; i < sorted.Count; i++)
|
||||
{
|
||||
if (safeExp >= Mathf.Max(0, sorted[i].requiredEXP))
|
||||
{
|
||||
expQualifiedIndex = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int unlockedIndex = Mathf.Clamp(so.ally_growthUnlockedTierIndex, 0, sorted.Count - 1);
|
||||
int effectiveIndex = Mathf.Min(expQualifiedIndex, unlockedIndex);
|
||||
|
||||
return sorted[Mathf.Clamp(effectiveIndex, 0, sorted.Count - 1)];
|
||||
}
|
||||
|
||||
// Scoring API
|
||||
|
||||
Reference in New Issue
Block a user