| | |
| | | private void HandleDamageType() |
| | | { |
| | | if (hurt == null) return; |
| | | |
| | | |
| | | uint originalAttackTypes = hurt.AttackTypes; |
| | | int convertedAttackTypes = 0; |
| | | |
| | | |
| | | // 遍历服务器发来的所有伤害类型标记 |
| | | foreach (ServerDamageType serverDamageType in System.Enum.GetValues(typeof(ServerDamageType))) |
| | | { |
| | | int serverValue = (int)serverDamageType; |
| | | |
| | | |
| | | // 检查服务器类型是否存在 |
| | | if ((originalAttackTypes & serverValue) != serverValue) |
| | | continue; |
| | | |
| | | |
| | | // 转换映射 |
| | | switch (serverDamageType) |
| | | { |
| | |
| | | |
| | | case ServerDamageType.DamageReverse: |
| | | convertedAttackTypes |= (int)DamageType.Damage; |
| | | // Debug.LogWarning($"[BattleDmgInfo] 服务器伤害类型 DamageReverse({serverValue}) 在客户端没有对应的枚举值"); |
| | | break; |
| | | |
| | | case ServerDamageType.SuckHpReverse: |
| | | convertedAttackTypes |= (int)DamageType.Damage; |
| | | // Debug.LogWarning($"[BattleDmgInfo] 服务器伤害类型 SuckHpReverse({serverValue}) 在客户端没有对应的枚举值"); |
| | | break; |
| | | |
| | | case ServerDamageType.SelfHarm: |
| | | convertedAttackTypes |= (int)DamageType.Damage; |
| | | // Debug.LogWarning($"[BattleDmgInfo] 服务器伤害类型 SelfHarm({serverValue}) 在客户端没有对应的枚举值"); |
| | | break; |
| | | |
| | | default: |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | // DOT技能特殊处理(SkillType == 3 或 4) |
| | | if (skillConfig != null && (skillConfig.SkillType == 3 || skillConfig.SkillType == 4)) |
| | | { |
| | | // 如果是伤害类型,替换为流血类型 |
| | | if ((convertedAttackTypes & (int)DamageType.Damage) != 0) |
| | | { |
| | | // 流血标记 |
| | | convertedAttackTypes = (int)DamageType.Bloody; |
| | | } |
| | | // 治疗类型保持不变 |
| | | } |
| | | |
| | | // 检查是否包含占位符类型 |
| | | if ((convertedAttackTypes & (int)DamageType.TakePlace2) == (int)DamageType.TakePlace2) |
| | | { |
| | | Debug.LogWarning($"[BattleDmgInfo] 转换后的伤害类型包含占位符 TakePlace2(256)"); |
| | | } |
| | | |
| | | |
| | | hurt.AttackTypes = (uint)convertedAttackTypes; |
| | | Debug.Log($"[BattleDmgInfo] 伤害类型转换: {originalAttackTypes} -> {hurt.AttackTypes}"); |
| | | } |