diff --git a/client/Assets/Game/Scripts/ECS/Component/SkillComponent.cs b/client/Assets/Game/Scripts/ECS/Component/SkillComponent.cs index 5fd9440..c2085b4 100644 --- a/client/Assets/Game/Scripts/ECS/Component/SkillComponent.cs +++ b/client/Assets/Game/Scripts/ECS/Component/SkillComponent.cs @@ -11,10 +11,8 @@ public class SkillComponent : IComponent public bool IsRunning; //是否技能释放中 public Vector3 CastDir; //技能释放方向 - public Dictionary, SkillHitInfo> - SkillHitInfo = new Dictionary, SkillHitInfo>(); //技能命中信息 - - public List HitInfo = new List(); //受击命中信息 + public HashSet> HitSet = new HashSet>(); //技能命中信息 生命周期为一次技能释放 + public List HitInfo = new List(); //受击命中信息 结算时清空 } namespace Game @@ -24,7 +22,7 @@ namespace Game public static void CastSkill(GameEntity entity, string skillId, string skillTimeline, Vector3 castDir) { TimelineManager.Instance.EndSkillTimeline(entity); - entity.skill.SkillHitInfo.Clear(); + entity.skill.HitSet.Clear(); var skill = entity.skill; var move = entity.move; @@ -64,8 +62,7 @@ namespace Game public static void ClearSkill(GameEntity entity) { var skill = entity.skill; - skill.SkillHitInfo.Clear(); - skill.HitInfo.Clear(); + skill.HitSet.Clear(); skill.IsRunning = false; skill.SkillId.Value = ""; } diff --git a/client/Assets/Game/Scripts/ECS/System/BulletSystem.cs b/client/Assets/Game/Scripts/ECS/System/BulletSystem.cs index dc6dd3e..35efcaf 100644 --- a/client/Assets/Game/Scripts/ECS/System/BulletSystem.cs +++ b/client/Assets/Game/Scripts/ECS/System/BulletSystem.cs @@ -33,7 +33,7 @@ public class BulletSystem : IExecuteSystem, IInitializeSystem //击中墙壁 Util.DestroyEntity(entity); } - if (entity.skill.SkillHitInfo.Count > 0) + if (entity.skill.HitSet.Count > 0) { //命中 Util.DestroyEntity(entity); diff --git a/client/Assets/Game/Scripts/ECS/System/SettleSystem.cs b/client/Assets/Game/Scripts/ECS/System/SettleSystem.cs index c390c56..13d7f88 100644 --- a/client/Assets/Game/Scripts/ECS/System/SettleSystem.cs +++ b/client/Assets/Game/Scripts/ECS/System/SettleSystem.cs @@ -19,7 +19,6 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem { SettleDebugDraw(entity); SettleSkill(entity.skill); - SettleHit(entity.skill); } } @@ -35,71 +34,39 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem private static void SettleSkill(SkillComponent skill) { - foreach (var hitInfo in skill.SkillHitInfo.Values) + foreach (var hitInfo in skill.HitInfo) { - if (hitInfo.IsDealed) - { - continue; - } - - hitInfo.IsDealed = true; - var isEntity = hitInfo.HitEntity != 0; - if (isEntity) - { - var target = Util.GetEntity(hitInfo.HitEntity); - target.skill.HitInfo.Add(hitInfo); - } + SettleHit(hitInfo); } + + skill.HitInfo.Clear(); } - private void SettleHit(SkillComponent skill) + private static void SettleHit(SkillHitInfo hitInfo) { - while (true) + var entity = Util.GetEntity(hitInfo.OwnerEntity); + var target = Util.GetEntity(hitInfo.HitEntity); + if (entity == null || target == null) { - _tempHitInfo.Clear(); - _tempHitInfo.AddRange(skill.HitInfo); - skill.HitInfo.Clear(); - foreach (var hitInfo in _tempHitInfo) - { - var isEntity = hitInfo.HitEntity != 0; - if (!isEntity) - { - continue; - } - - var entity = Util.GetEntity(hitInfo.OwnerEntity); - var target = Util.GetEntity(hitInfo.HitEntity); - if (entity == null || target == null) - { - continue; - } - - var damageResult = SettleDamage(hitInfo, entity, target); //伤害结算 - var hitLevel = SettleHitLevel(hitInfo, damageResult, entity, target); //命中效果等级 - var flowSpeed = SettleFlowSpeed(hitInfo, hitLevel, entity, target); //强制位移(击退、击飞、击落等) - var pauseTime = SettlePause(hitInfo, hitLevel, entity, target); //卡帧 - SettleSelfMoveForceScale(hitLevel, entity, target); //攻击者移动速度调整 - SettleBreak(flowSpeed, hitLevel, damageResult, entity, target); //打断技能/动画 - SettleBuff(hitLevel, entity, target); //添加硬直/击晕buff - SettleTrigger(hitInfo, entity, target); //命中触发器 - - //纯表现 - SettleHitText(hitLevel, damageResult, entity, target); //跳字 - SettleHitEffect(flowSpeed, hitLevel, hitInfo.HitType, entity, target); //命中特效 - SettleFlash(hitLevel, entity, target); //闪白 - SettleShake(hitLevel, entity, target); //抖动 - SettleScale(flowSpeed, entity, target); //抖动 - SettleGlobalEffect(target, pauseTime); //全局特效 - } - - if (skill.HitInfo.Count > 0) - { - //结算过程中可能引入新的受击 直接继续结算 - continue; - } - - break; + return; } + + var damageResult = SettleDamage(hitInfo, entity, target); //伤害结算 + var hitLevel = SettleHitLevel(hitInfo, damageResult, entity, target); //命中效果等级 + var flowSpeed = SettleFlowSpeed(hitInfo, hitLevel, entity, target); //强制位移(击退、击飞、击落等) + var pauseTime = SettlePause(hitInfo, hitLevel, entity, target); //卡帧 + SettleSelfMoveForceScale(hitLevel, entity, target); //攻击者移动速度调整 + SettleBreak(flowSpeed, hitLevel, damageResult, entity, target); //打断技能/动画 + SettleBuff(hitLevel, entity, target); //添加硬直/击晕buff + SettleTrigger(hitInfo, entity, target); //命中触发器 + + //纯表现 + SettleHitText(hitLevel, damageResult, entity, target); //跳字 + SettleHitEffect(flowSpeed, hitLevel, hitInfo.SkillParam.hitType, entity, target); //命中特效 + SettleFlash(hitLevel, entity, target); //闪白 + SettleShake(hitLevel, entity, target); //抖动 + SettleScale(flowSpeed, entity, target); //抖动 + SettleGlobalEffect(target, pauseTime); //全局特效 } public struct SettleDamageResult @@ -207,7 +174,7 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem staggerDef += Util.GetProperty(target, EProperty.ShieldStaggerDefLevel); } - var sub = hitInfo.StaggerLevel - staggerDef; + var sub = hitInfo.SkillParam.staggerLevel - staggerDef; sub = Mathf.Clamp(sub, 0, 3); var ret = EHitLevel.None; switch (sub) @@ -462,11 +429,6 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem { //触发buffTrigger UtilBuff.BuffEffectAll(target.ID(), EBuffEffectTimingType.BeAttack); - if (((hitInfo.Performance & (1 << ((int)ESKillPerformance.Heavy - 1))) != 0) || - (hitInfo.Performance & (1 << ((int)ESKillPerformance.Floating - 1))) != 0) - { - UtilBuff.BuffEffectAll(target.ID(), EBuffEffectTimingType.BeAttackHeavy); - } //触发SkillTrigger UtilSkillTrigger.Trigger(entity.ID(), target.ID(), hitInfo.SkillId, ESkillTriggerTimingType.Hit); diff --git a/client/Assets/Game/Scripts/Timeline/TimelineClip/ClipAttack.cs b/client/Assets/Game/Scripts/Timeline/TimelineClip/ClipAttack.cs index 9817542..c310d2f 100644 --- a/client/Assets/Game/Scripts/Timeline/TimelineClip/ClipAttack.cs +++ b/client/Assets/Game/Scripts/Timeline/TimelineClip/ClipAttack.cs @@ -6,17 +6,13 @@ namespace Game public class SkillHitInfo { public AttackBehaviour SkillParam; - public float AttackRate; - public float StunkRate; + public Vector3 HitDir; public int OwnerEntity; public int HitEntity; //0为非实体对象 - public Vector3 HitDir; - public bool IsDealed; //已经结算 + public float AttackRate; + public float StunkRate; public string SkillId; //是否技能造成的伤害 - public uint Performance; //性能tag的mask - public int StaggerLevel; public bool IsBreak; - public EHitType HitType; } public class ClipAttack : TimelineClipBase @@ -42,39 +38,37 @@ namespace Game Util.ForeachEnemies(Owner.Team(), target => { var isHit = UtilShape.IsOverlap(castShape, castPos, castDir, target.hp.HitBoxShape, target.Pos()); - if (isHit) + if (!isHit) return; + + var targetID = target.ID(); + + var hitKey = new Tuple(targetID, param.hitId); + if (Owner.skill.HitSet.Contains(hitKey)) return; + Owner.skill.HitSet.Add(hitKey); + + var skillHitInfo = new SkillHitInfo { - var targetID = target.ID(); - var hitKey = new Tuple(targetID, param.hitId); - if (Owner.skill.SkillHitInfo.ContainsKey(hitKey)) return; - var skillHitInfo = new SkillHitInfo - { - SkillParam = param, - AttackRate = 1, - StunkRate = 1, - OwnerEntity = Owner.ID(), - HitEntity = targetID, - HitDir = castDir, - IsDealed = false, - SkillId = skill.SkillId.Value, - Performance = 0, - StaggerLevel = param.staggerLevel, - IsBreak = true, - HitType = param.hitType, - }; - if (!string.IsNullOrEmpty(skillHitInfo.SkillId)) + SkillParam = param, + AttackRate = 1, + StunkRate = 1, + OwnerEntity = Owner.ID(), + HitEntity = targetID, + HitDir = castDir, + SkillId = skill.SkillId.Value, + IsBreak = true, + }; + if (!string.IsNullOrEmpty(skillHitInfo.SkillId)) + { + var skillCfg = Util.GetSkillMasterConfigData(skillHitInfo.SkillId); + if (skillCfg != null) { - var skillCfg = Util.GetSkillMasterConfigData(skillHitInfo.SkillId); - if (skillCfg != null) - { - var featureSkill = skillCfg.GetFeatureSkill(); - skillHitInfo.AttackRate = featureSkill.AttackRate; - skillHitInfo.StunkRate = featureSkill.StunRate; - } + var featureSkill = skillCfg.GetFeatureSkill(); + skillHitInfo.AttackRate = featureSkill.AttackRate; + skillHitInfo.StunkRate = featureSkill.StunRate; } - - Owner.skill.SkillHitInfo[hitKey] = skillHitInfo; } + + target.skill.HitInfo.Add(skillHitInfo); }); } diff --git a/client/Assets/Game/Scripts/Util/ElementBuff/UtilBuffEffect.cs b/client/Assets/Game/Scripts/Util/ElementBuff/UtilBuffEffect.cs index 045f9bb..0282599 100644 --- a/client/Assets/Game/Scripts/Util/ElementBuff/UtilBuffEffect.cs +++ b/client/Assets/Game/Scripts/Util/ElementBuff/UtilBuffEffect.cs @@ -45,9 +45,7 @@ namespace Game OwnerEntity = owner.ID(), HitEntity = target.ID(), HitDir = Vector3.up, - IsDealed = false, SkillId = "", - Performance = (uint)0, IsBreak = buffAttack.IsStun, }); } diff --git a/client/Assets/Game/Scripts/_Define/Enum.cs b/client/Assets/Game/Scripts/_Define/Enum.cs index 1c491f0..aba423a 100644 --- a/client/Assets/Game/Scripts/_Define/Enum.cs +++ b/client/Assets/Game/Scripts/_Define/Enum.cs @@ -1,3 +1,5 @@ +using UnityEngine; + namespace Game { public enum EFunctionKey @@ -151,4 +153,13 @@ namespace Game Slash, Blunt, } + + public enum EHitDirType + { + Center, + Forward, + Backward, + Clockwise, + CounterClockwise, + } } \ No newline at end of file diff --git a/client/Assets/Generated/Game/Components/GameSkillComponent.cs b/client/Assets/Generated/Game/Components/GameSkillComponent.cs index 19a7ef1..11c2543 100644 --- a/client/Assets/Generated/Game/Components/GameSkillComponent.cs +++ b/client/Assets/Generated/Game/Components/GameSkillComponent.cs @@ -17,8 +17,6 @@ public partial class GameEntity { component.SkillId = newSkillId; component.IsRunning = newIsRunning; component.CastDir = newCastDir; - component.SkillHitInfo = newSkillHitInfo; - component.HitInfo = newHitInfo; AddComponent(index, component); } @@ -28,8 +26,6 @@ public partial class GameEntity { component.SkillId = newSkillId; component.IsRunning = newIsRunning; component.CastDir = newCastDir; - component.SkillHitInfo = newSkillHitInfo; - component.HitInfo = newHitInfo; ReplaceComponent(index, component); }