using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Library.Constant; namespace Milimoe.FunGame.Core.Entity { /// /// 角色的魔法抗性,对不同的魔法类型有不同抗性 /// public class MagicResistance { /// /// 无属性魔法抗性 /// public double None { get; set; } = 0; /// /// 星痕魔法抗性 /// public double Starmark { get; set; } = 0; /// /// 纯粹结晶魔法抗性 /// public double PurityNatural { get; set; } = 0; /// /// 纯现代结晶魔法抗性 /// public double PurityContemporary { get; set; } = 0; /// /// 光魔法抗性 /// public double Bright { get; set; } = 0; /// /// 影魔法抗性 /// public double Shadow { get; set; } = 0; /// /// 元素魔法抗性 /// public double Element { get; set; } = 0; /// /// 紫宛魔法抗性 /// public double Aster { get; set; } = 0; /// /// 时空魔法抗性 /// public double SpatioTemporal { get; set; } = 0; /// /// 平均魔法抗性 /// public double Avg { get { double mdf = Calculation.Round4Digits((None + Starmark + PurityNatural + PurityContemporary + Bright + Shadow + Element + Aster + SpatioTemporal) / 9); if (Calculation.IsApproximatelyZero(mdf)) mdf = 0; return mdf; } } /// /// 获取或设置抗性值 /// /// /// public double this[MagicType type] { get { return type switch { MagicType.Starmark => Starmark, MagicType.PurityNatural => PurityNatural, MagicType.PurityContemporary => PurityContemporary, MagicType.Bright => Bright, MagicType.Shadow => Shadow, MagicType.Element => Element, MagicType.Aster => Aster, MagicType.SpatioTemporal => SpatioTemporal, _ => None }; } set { switch (type) { case MagicType.Starmark: Starmark = value; break; case MagicType.PurityNatural: PurityNatural = value; break; case MagicType.PurityContemporary: PurityContemporary = value; break; case MagicType.Bright: Bright = value; break; case MagicType.Shadow: Shadow = value; break; case MagicType.Element: Element = value; break; case MagicType.Aster: Aster = value; break; case MagicType.SpatioTemporal: SpatioTemporal = value; break; default: None = value; break; } } } /// /// 增加所有抗性,传入负数来减少 /// /// public void AddAllValue(double value) { None += value; Starmark += value; PurityNatural += value; PurityContemporary += value; Element += value; Bright += value; Shadow += value; Aster += value; SpatioTemporal += value; } /// /// 复制一个魔法抗性对象 /// /// public MagicResistance Copy() { return new() { None = None, Starmark = Starmark, PurityNatural = PurityNatural, PurityContemporary = PurityContemporary, Bright = Bright, Shadow = Shadow, Element = Element, Aster = Aster, SpatioTemporal = SpatioTemporal }; } } }