using Cielonos.MainGame.Characters;
using UnityEngine;
namespace Cielonos.MainGame.Inventory.Collections
{
///
/// 激情系统配套被动装备
/// - 提供与激情系统等级相关的属性加成。
/// - 加成效果根据激情等级逐级递增,最高可达 SSS 级别。
/// 具体效果如下:
/// - C级:+8 能量回复,+0 攻击获得能量,0% 攻击速度,0% 暴击率,0% 受到的最终伤害倍率
/// - B级:+4 能量回复,+0 攻击获得能量,1% 攻击速度,2% 暴击率,0% 受到的最终伤害倍率
/// - A级:+2 能量回复,+0 攻击获得能量,2% 攻击速度,4% 暴击率,0% 受到的最终伤害倍率
/// - S级:+1 能量回复,+1 攻击获得能量,3% 攻击速度,6% 暴击率,5% 受到的最终伤害倍率
/// - SS级:+1 能量回复,+1 攻击获得能量,4% 攻击速度,8% 暴击率,10% 受到的最终伤害倍率
/// - SSS级:+1 能量回复,+1 攻击获得能量,5% 攻击速度,10% 暴击率,20% 受到的最终伤害倍率
///
public partial class Passion : PassiveEquipmentBase
{
private PassionSystem _passionSystem;
private int PassionLevel => _passionSystem.LevelIndex;
public override void Initialize()
{
base.Initialize();
_passionSystem = CombatManager.GetCombatSystem();
passiveAttributeSm = new AttributeSubmodule(this, passiveAttributeData);
}
public override void OnObtained()
{
base.OnObtained();
_passionSystem.OnLevelChanged += Refresh;
UpdateAttributes();
passiveAttributeSm.RefreshAllModifiedAttributes();
}
public override void OnDiscarded()
{
base.OnDiscarded();
_passionSystem.OnLevelChanged -= Refresh;
}
private void Refresh(int oldLevel, int newLevel)
{
UpdateAttributes();
passiveAttributeSm.RefreshAllModifiedAttributes();
}
private void UpdateAttributes()
{
passiveAttributeSm.charAttrNumericChange[CharacterAttribute.EnergyRegeneration] = GetEnergyRegen();
passiveAttributeSm.chaAttrPercentageChangeOfAccumulation[CharacterAttribute.AttackSpeed] = GetAttackSpeed();
passiveAttributeSm.charAttrNumericChange[CharacterAttribute.CriticalAttackProbability] = GetCriticalAttackProbability();
passiveAttributeSm.chaAttrPercentageChangeOfMultiplication[CharacterAttribute.FinalDamageReceivedMultiplier] = GetFinalDamageReceivedMultiplier();
}
}
public partial class Passion
{
private float GetEnergyRegen()
{
return PassionLevel switch
{
0 => 8.0f, // C-Rank
1 => 4.0f, // B-Rank
2 => 2.0f, // A-Rank
_ => 1.0f // S, SS, SSS (Ranks 3, 4, 5)
};
}
private float GetEnergyGainByAttack()
{
if (PassionLevel < 3) return 0f; // C, B, A ranks have no extra energy gain
return 1f; // S, SS, SSS ranks provide +1 energy gain on attack
}
private float GetAttackSpeed()
{
return PassionLevel * 0.01f;
}
private float GetCriticalAttackProbability()
{
return PassionLevel * 0.02f;
}
private float GetFinalDamageReceivedMultiplier()
{
return PassionLevel switch
{
3 => 1.05f, // S-Rank (LevelIndex 3)
4 => 1.10f, // SS-Rank (LevelIndex 4)
5 => 1.20f, // SSS-Rank (LevelIndex 5)
_ => 1.00f // C, B, A-Ranks (0, 1, 2)
};
}
}
}