Files
Cielonos/Assets/Scripts/MainGame/Items/PassiveEquipments/Passion.cs
SoulliesOfficial 6d7ebc5825 Passion & UI
2026-06-12 17:11:39 -04:00

100 lines
3.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Cielonos.MainGame.Characters;
using UnityEngine;
namespace Cielonos.MainGame.Inventory.Collections
{
/// <summary>
/// 激情系统配套被动装备
/// - 提供与激情系统等级相关的属性加成。
/// - 加成效果根据激情等级逐级递增,最高可达 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% 受到的最终伤害倍率
/// </summary>
public partial class Passion : PassiveEquipmentBase
{
private PassionSystem _passionSystem;
private int PassionLevel => _passionSystem.LevelIndex;
public override void Initialize()
{
base.Initialize();
_passionSystem = CombatManager.GetCombatSystem<PassionSystem>();
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)
};
}
}
}