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 Vector3 CastDir; //技能释放方向
public Dictionary<Tuple<int, int>, SkillHitInfo>
SkillHitInfo = new Dictionary<Tuple<int, int>, SkillHitInfo>(); //技能命中信息
public List<SkillHitInfo> HitInfo = new List<SkillHitInfo>(); //受击命中信息
public HashSet<Tuple<int, int>> HitSet = new HashSet<Tuple<int, int>>(); //技能命中信息 生命周期为一次技能释放
public List<SkillHitInfo> HitInfo = new List<SkillHitInfo>(); //受击命中信息 结算时清空
}
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 = "";
}

@ -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);

@ -19,7 +19,6 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
{
SettleDebugDraw(entity);
SettleSkill(entity.skill);
SettleHit(entity.skill);
}
}
@ -35,43 +34,21 @@ 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;
SettleHit(hitInfo);
}
hitInfo.IsDealed = true;
var isEntity = hitInfo.HitEntity != 0;
if (isEntity)
{
var target = Util.GetEntity(hitInfo.HitEntity);
target.skill.HitInfo.Add(hitInfo);
}
}
}
private void SettleHit(SkillComponent skill)
{
while (true)
{
_tempHitInfo.Clear();
_tempHitInfo.AddRange(skill.HitInfo);
skill.HitInfo.Clear();
foreach (var hitInfo in _tempHitInfo)
{
var isEntity = hitInfo.HitEntity != 0;
if (!isEntity)
{
continue;
}
private static void SettleHit(SkillHitInfo hitInfo)
{
var entity = Util.GetEntity(hitInfo.OwnerEntity);
var target = Util.GetEntity(hitInfo.HitEntity);
if (entity == null || target == null)
{
continue;
return;
}
var damageResult = SettleDamage(hitInfo, entity, target); //伤害结算
@ -85,23 +62,13 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
//纯表现
SettleHitText(hitLevel, damageResult, entity, target); //跳字
SettleHitEffect(flowSpeed, hitLevel, hitInfo.HitType, 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); //全局特效
}
if (skill.HitInfo.Count > 0)
{
//结算过程中可能引入新的受击 直接继续结算
continue;
}
break;
}
}
public struct SettleDamageResult
{
public float Damage; //伤害
@ -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);

@ -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,11 +38,14 @@ 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<int, int>(targetID, param.hitId);
if (Owner.skill.SkillHitInfo.ContainsKey(hitKey)) return;
if (Owner.skill.HitSet.Contains(hitKey)) return;
Owner.skill.HitSet.Add(hitKey);
var skillHitInfo = new SkillHitInfo
{
SkillParam = param,
@ -55,12 +54,8 @@ namespace Game
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))
{
@ -73,8 +68,7 @@ namespace Game
}
}
Owner.skill.SkillHitInfo[hitKey] = skillHitInfo;
}
target.skill.HitInfo.Add(skillHitInfo);
});
}

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

@ -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,
}
}

@ -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);
}

Loading…
Cancel
Save