增加收获属性逻辑,优化掉落物表现效果
This commit is contained in:
@@ -6,16 +6,22 @@ namespace SepCore.CustomUtility
|
||||
{
|
||||
public static class RarityUtility
|
||||
{
|
||||
public static Rarity SelectRarityForLevel(int level)
|
||||
public static Rarity SelectRarityForLevel(int level, float luck = 0f)
|
||||
{
|
||||
int configId = level >= 1000 ? level : 1000 + level;
|
||||
LevelDropConfig dropConfig = GameEntry.Luban.Get<LevelDropConfig>(configId);
|
||||
return SelectRarity(dropConfig);
|
||||
return SelectRarity(dropConfig, luck);
|
||||
}
|
||||
|
||||
public static Rarity SelectRarity(LevelDropConfig dropConfig)
|
||||
public static Rarity SelectRarity(LevelDropConfig dropConfig, float luck = 0f)
|
||||
{
|
||||
float total = dropConfig.WhiteWeight + dropConfig.BlueWeight + dropConfig.PurpleWeight + dropConfig.RedWeight;
|
||||
float whiteWeight = dropConfig.WhiteWeight;
|
||||
float luckMultiplier = Mathf.Max(0f, 1f + luck * 0.015f);
|
||||
float blueWeight = dropConfig.BlueWeight * luckMultiplier;
|
||||
float purpleWeight = dropConfig.PurpleWeight * luckMultiplier;
|
||||
float redWeight = dropConfig.RedWeight * luckMultiplier;
|
||||
|
||||
float total = whiteWeight + blueWeight + purpleWeight + redWeight;
|
||||
if (total <= 0f)
|
||||
{
|
||||
Log.Error("LevelDropConfig '{0}' has invalid total weight '{1}'.", dropConfig.Id, total);
|
||||
@@ -23,11 +29,11 @@ namespace SepCore.CustomUtility
|
||||
}
|
||||
|
||||
float roll = Random.Range(0f, total);
|
||||
if (roll < dropConfig.WhiteWeight) return Rarity.White;
|
||||
roll -= dropConfig.WhiteWeight;
|
||||
if (roll < dropConfig.BlueWeight) return Rarity.Blue;
|
||||
roll -= dropConfig.BlueWeight;
|
||||
if (roll < dropConfig.PurpleWeight) return Rarity.Purple;
|
||||
if (roll < whiteWeight) return Rarity.White;
|
||||
roll -= whiteWeight;
|
||||
if (roll < blueWeight) return Rarity.Blue;
|
||||
roll -= blueWeight;
|
||||
if (roll < purpleWeight) return Rarity.Purple;
|
||||
return Rarity.Red;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user