using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Interface.Entity; using Milimoe.FunGame.Core.Library.Constant; namespace Milimoe.FunGame.Core.Entity { public class Character : BaseEntity, ICopyable { /// /// 角色的姓 /// public override string Name { get; set; } = ""; /// /// 角色的名字 /// public string FirstName { get; set; } = ""; /// /// 角色的昵称 /// public string NickName { get; set; } = ""; /// /// 角色所属的玩家 /// public User? User { get; set; } = null; /// /// 角色统计数据 /// public CharacterStatistics? Statistics { get; set; } = null; /// /// 魔法属性 /// public MagicType MagicType { get; set; } = MagicType.Particle; /// /// 角色定位1 /// public RoleType FirstRoleType { get; set; } = RoleType.Core; /// /// 角色定位2 /// public RoleType SecondRoleType { get; set; } = RoleType.Guardian; /// /// 角色定位3 /// public RoleType ThirdRoleType { get; set; } = RoleType.Vanguard; /// /// 角色评级 /// public RoleRating RoleRating { get; set; } = RoleRating.E; /// /// 晋升点数 /// public int Promotion { get; set; } = 0; /// /// 等级 /// public int Level { get; set; } = 1; /// /// 经验值 /// public double EXP { get; set; } = 0; /// /// 基础生命值 /// public double BaseHP { get; set; } = 1; /// /// 生命值 /// public double HP { get; set; } = 0; /// /// 基础魔法值 /// public double BaseMP { get; set; } = 0; /// /// 魔法值 /// public double MP { get; set; } = 0; /// /// 爆发能量 /// public double EP { get; set; } = 0; /// /// 基础攻击力 /// public double BaseATK { get; set; } = 1; /// /// 攻击力 /// public double ATK { get; set; } = 0; /// /// 基础物理护甲 /// public double BaseDEF { get; set; } = 5; /// /// 物理护甲 /// public double DEF { get; set; } = 0; /// /// 物理伤害减免(%) /// public double PDR { get { double value = Math.Round((BaseDEF + DEF) / BaseDEF + DEF + 300, 4, MidpointRounding.AwayFromZero) + ExPDR; return value > 1 ? 1 : value; } } /// /// 额外物理伤害减免(%) /// public double ExPDR { get; set; } = 0; /// /// 魔法抗性(%) /// public double MDF { get; set; } = 0; /// /// 物理穿透(%) /// public double PhysicalPenetration { get; set; } = 0; /// /// 魔法穿透(%) /// public double MagicalPenetration { get; set; } = 0; /// /// 生命回复力 /// public double HR { get; set; } = 0; /// /// 魔法回复力 /// public double MR { get; set; } = 0; /// /// 能量回复力 /// public double ER { get; set; } = 0; /// /// 基础力量 /// public double BaseSTR { get; set; } = 0; /// /// 基础敏捷 /// public double BaseAGI { get; set; } = 0; /// /// 基础智力 /// public double BaseINT { get; set; } = 0; /// /// 力量 /// public double STR { get; set; } = 0; /// /// 敏捷 /// public double AGI { get; set; } = 0; /// /// 智力 /// public double INT { get; set; } = 0; /// /// 力量成长值 /// public double STRGrowth { get; set; } = 0; /// /// 敏捷成长值 /// public double AGIGrowth { get; set; } = 0; /// /// 智力成长值 /// public double INTGrowth { get; set; } = 0; /// /// 行动速度 /// public double SPD { get; set; } = 0; /// /// 行动系数(%) /// public double ActionCoefficient { get { double value = Math.Round(SPD / 1500.00, 4, MidpointRounding.AwayFromZero) + ExActionCoefficient; return value > 1 ? 1 : value; } } /// /// 额外行动系数(%) /// public double ExActionCoefficient { get; set; } = 0; /// /// 加速系数(%) /// public double AccelerationCoefficient { get; set; } = 0; /// /// 冷却缩减(%) /// public double CDR { get; set; } = 0; /// /// 攻击距离 /// public double ATR { get; set; } = 0; /// /// 暴击率(%) /// public double CritRate { get; set; } = 0.05; /// /// 暴击伤害(%) /// public double CritDMG { get; set; } = 1.25; /// /// 闪避率(%) /// public double EvadeRate { get; set; } = 0.05; /// /// 角色的技能组 /// public Dictionary Skills { get; set; } = []; /// /// 角色携带的物品 /// public Dictionary Items { get; set; } = []; protected Character() { } internal static Character GetInstance() { return new(); } public void Init() { STR = BaseSTR; AGI = BaseAGI; INT = BaseINT; HP = BaseHP; MP = BaseMP; ATK = BaseATK; DEF = BaseDEF; // STR HP = Math.Round(HP + STR * 17, 2, MidpointRounding.AwayFromZero); HR = Math.Round(HR + STR * 0.7, 2, MidpointRounding.AwayFromZero); DEF = Math.Round(DEF + STR * 0.75, 2, MidpointRounding.AwayFromZero); CritDMG = Math.Round(CritDMG + STR * 0.00575, 4, MidpointRounding.AwayFromZero); // AGI SPD = Math.Round(SPD + AGI * 0.65, 2, MidpointRounding.AwayFromZero); EvadeRate = Math.Round(EvadeRate + AGI * 0.0025, 4, MidpointRounding.AwayFromZero); CritRate = Math.Round(CritRate + AGI * 0.00235, 4, MidpointRounding.AwayFromZero); // INT MP = Math.Round(MP + INT * 8, 2, MidpointRounding.AwayFromZero); MR = Math.Round(MR + INT * 0.4, 2, MidpointRounding.AwayFromZero); CDR = Math.Round(CDR + INT * 0.0025, 4, MidpointRounding.AwayFromZero); } public override bool Equals(IBaseEntity? other) { return other is Character c && c.Name == Name; } public override string ToString() { bool isChineseName = NetworkUtility.IsChineseName(Name + FirstName); string str = isChineseName ? (Name + FirstName).Trim() : (Name + " " + FirstName).Trim(); if (NickName != "") { if (str != "") str += ", "; str += NickName; } if (User != null && User.Username != "") { str += "(" + User.Username + ")"; } return str; } public Character Copy() { Character c = new() { Name = Name, FirstName = FirstName, NickName = NickName, Statistics = Statistics, MagicType = MagicType, FirstRoleType = FirstRoleType, SecondRoleType = SecondRoleType, ThirdRoleType = ThirdRoleType, RoleRating = RoleRating, Promotion = Promotion, Level = Level, EXP = EXP, BaseHP = BaseHP, HP = HP, BaseMP = BaseMP, MP = MP, EP = EP, BaseATK = BaseATK, ATK = ATK, BaseDEF = BaseDEF, DEF = DEF, MDF = MDF, PhysicalPenetration = PhysicalPenetration, MagicalPenetration = MagicalPenetration, HR = HR, MR = MR, ER = ER, BaseSTR = BaseSTR, BaseAGI = BaseAGI, BaseINT = BaseINT, STR = STR, AGI = AGI, INT = INT, STRGrowth = STRGrowth, AGIGrowth = AGIGrowth, INTGrowth = INTGrowth, SPD = SPD, AccelerationCoefficient = AccelerationCoefficient, ATR = ATR, CritRate = CritRate, CritDMG = CritDMG, EvadeRate = EvadeRate, Skills = Skills, Items = Items, }; return c; } } }