2
0
Fork 0

重构结算

master
cd 2 years ago
parent 629687d366
commit c7610dd9cf

@ -11,10 +11,8 @@ public class SkillComponent : IComponent
public bool IsRunning; //是否技能释放中 public bool IsRunning; //是否技能释放中
public Vector3 CastDir; //技能释放方向 public Vector3 CastDir; //技能释放方向
public Dictionary<Tuple<int, int>, SkillHitInfo> public HashSet<Tuple<int, int>> HitSet = new HashSet<Tuple<int, int>>(); //技能命中信息 生命周期为一次技能释放
SkillHitInfo = new Dictionary<Tuple<int, int>, SkillHitInfo>(); //技能命中信息 public List<SkillHitInfo> HitInfo = new List<SkillHitInfo>(); //受击命中信息 结算时清空
public List<SkillHitInfo> HitInfo = new List<SkillHitInfo>(); //受击命中信息
} }
namespace Game namespace Game
@ -24,7 +22,7 @@ namespace Game
public static void CastSkill(GameEntity entity, string skillId, string skillTimeline, Vector3 castDir) public static void CastSkill(GameEntity entity, string skillId, string skillTimeline, Vector3 castDir)
{ {
TimelineManager.Instance.EndSkillTimeline(entity); TimelineManager.Instance.EndSkillTimeline(entity);
entity.skill.SkillHitInfo.Clear(); entity.skill.HitSet.Clear();
var skill = entity.skill; var skill = entity.skill;
var move = entity.move; var move = entity.move;
@ -64,8 +62,7 @@ namespace Game
public static void ClearSkill(GameEntity entity) public static void ClearSkill(GameEntity entity)
{ {
var skill = entity.skill; var skill = entity.skill;
skill.SkillHitInfo.Clear(); skill.HitSet.Clear();
skill.HitInfo.Clear();
skill.IsRunning = false; skill.IsRunning = false;
skill.SkillId.Value = ""; skill.SkillId.Value = "";
} }

@ -33,7 +33,7 @@ public class BulletSystem : IExecuteSystem, IInitializeSystem
//击中墙壁 //击中墙壁
Util.DestroyEntity(entity); Util.DestroyEntity(entity);
} }
if (entity.skill.SkillHitInfo.Count > 0) if (entity.skill.HitSet.Count > 0)
{ {
//命中 //命中
Util.DestroyEntity(entity); Util.DestroyEntity(entity);

@ -19,7 +19,6 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
{ {
SettleDebugDraw(entity); SettleDebugDraw(entity);
SettleSkill(entity.skill); SettleSkill(entity.skill);
SettleHit(entity.skill);
} }
} }
@ -35,71 +34,39 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
private static void SettleSkill(SkillComponent skill) private static void SettleSkill(SkillComponent skill)
{ {
foreach (var hitInfo in skill.SkillHitInfo.Values) foreach (var hitInfo in skill.HitInfo)
{ {
if (hitInfo.IsDealed) SettleHit(hitInfo);
{
continue;
}
hitInfo.IsDealed = true;
var isEntity = hitInfo.HitEntity != 0;
if (isEntity)
{
var target = Util.GetEntity(hitInfo.HitEntity);
target.skill.HitInfo.Add(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(); return;
_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;
} }
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 public struct SettleDamageResult
@ -207,7 +174,7 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
staggerDef += Util.GetProperty(target, EProperty.ShieldStaggerDefLevel); staggerDef += Util.GetProperty(target, EProperty.ShieldStaggerDefLevel);
} }
var sub = hitInfo.StaggerLevel - staggerDef; var sub = hitInfo.SkillParam.staggerLevel - staggerDef;
sub = Mathf.Clamp(sub, 0, 3); sub = Mathf.Clamp(sub, 0, 3);
var ret = EHitLevel.None; var ret = EHitLevel.None;
switch (sub) switch (sub)
@ -462,11 +429,6 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
{ {
//触发buffTrigger //触发buffTrigger
UtilBuff.BuffEffectAll(target.ID(), EBuffEffectTimingType.BeAttack); 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 //触发SkillTrigger
UtilSkillTrigger.Trigger(entity.ID(), target.ID(), hitInfo.SkillId, ESkillTriggerTimingType.Hit); UtilSkillTrigger.Trigger(entity.ID(), target.ID(), hitInfo.SkillId, ESkillTriggerTimingType.Hit);

@ -6,17 +6,13 @@ namespace Game
public class SkillHitInfo public class SkillHitInfo
{ {
public AttackBehaviour SkillParam; public AttackBehaviour SkillParam;
public float AttackRate; public Vector3 HitDir;
public float StunkRate;
public int OwnerEntity; public int OwnerEntity;
public int HitEntity; //0为非实体对象 public int HitEntity; //0为非实体对象
public Vector3 HitDir; public float AttackRate;
public bool IsDealed; //已经结算 public float StunkRate;
public string SkillId; //是否技能造成的伤害 public string SkillId; //是否技能造成的伤害
public uint Performance; //性能tag的mask
public int StaggerLevel;
public bool IsBreak; public bool IsBreak;
public EHitType HitType;
} }
public class ClipAttack : TimelineClipBase public class ClipAttack : TimelineClipBase
@ -42,39 +38,37 @@ namespace Game
Util.ForeachEnemies(Owner.Team(), target => Util.ForeachEnemies(Owner.Team(), target =>
{ {
var isHit = UtilShape.IsOverlap(castShape, castPos, castDir, target.hp.HitBoxShape, target.Pos()); 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<int, int>(targetID, param.hitId);
if (Owner.skill.HitSet.Contains(hitKey)) return;
Owner.skill.HitSet.Add(hitKey);
var skillHitInfo = new SkillHitInfo
{ {
var targetID = target.ID(); SkillParam = param,
var hitKey = new Tuple<int, int>(targetID, param.hitId); AttackRate = 1,
if (Owner.skill.SkillHitInfo.ContainsKey(hitKey)) return; StunkRate = 1,
var skillHitInfo = new SkillHitInfo OwnerEntity = Owner.ID(),
{ HitEntity = targetID,
SkillParam = param, HitDir = castDir,
AttackRate = 1, SkillId = skill.SkillId.Value,
StunkRate = 1, IsBreak = true,
OwnerEntity = Owner.ID(), };
HitEntity = targetID, if (!string.IsNullOrEmpty(skillHitInfo.SkillId))
HitDir = castDir, {
IsDealed = false, var skillCfg = Util.GetSkillMasterConfigData(skillHitInfo.SkillId);
SkillId = skill.SkillId.Value, if (skillCfg != null)
Performance = 0,
StaggerLevel = param.staggerLevel,
IsBreak = true,
HitType = param.hitType,
};
if (!string.IsNullOrEmpty(skillHitInfo.SkillId))
{ {
var skillCfg = Util.GetSkillMasterConfigData(skillHitInfo.SkillId); var featureSkill = skillCfg.GetFeatureSkill();
if (skillCfg != null) 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);
}); });
} }

@ -45,9 +45,7 @@ namespace Game
OwnerEntity = owner.ID(), OwnerEntity = owner.ID(),
HitEntity = target.ID(), HitEntity = target.ID(),
HitDir = Vector3.up, HitDir = Vector3.up,
IsDealed = false,
SkillId = "", SkillId = "",
Performance = (uint)0,
IsBreak = buffAttack.IsStun, IsBreak = buffAttack.IsStun,
}); });
} }

@ -1,3 +1,5 @@
using UnityEngine;
namespace Game namespace Game
{ {
public enum EFunctionKey public enum EFunctionKey
@ -151,4 +153,13 @@ namespace Game
Slash, Slash,
Blunt, Blunt,
} }
public enum EHitDirType
{
Center,
Forward,
Backward,
Clockwise,
CounterClockwise,
}
} }

@ -17,8 +17,6 @@ public partial class GameEntity {
component.SkillId = newSkillId; component.SkillId = newSkillId;
component.IsRunning = newIsRunning; component.IsRunning = newIsRunning;
component.CastDir = newCastDir; component.CastDir = newCastDir;
component.SkillHitInfo = newSkillHitInfo;
component.HitInfo = newHitInfo;
AddComponent(index, component); AddComponent(index, component);
} }
@ -28,8 +26,6 @@ public partial class GameEntity {
component.SkillId = newSkillId; component.SkillId = newSkillId;
component.IsRunning = newIsRunning; component.IsRunning = newIsRunning;
component.CastDir = newCastDir; component.CastDir = newCastDir;
component.SkillHitInfo = newSkillHitInfo;
component.HitInfo = newHitInfo;
ReplaceComponent(index, component); ReplaceComponent(index, component);
} }

Loading…
Cancel
Save