2
0
Fork 0

结算分帧优化

master
cd 2 years ago
parent 89c34dd034
commit d20973f5ee

@ -32,10 +32,10 @@ namespace Game
return entity.pause.IsPause || entity.pause.PausePreFrame > 0; return entity.pause.IsPause || entity.pause.PausePreFrame > 0;
} }
public static void EntityPause(GameEntity entity, float pauseTime) public static void EntityPause(GameEntity entity, float pauseTime, bool isTarget = true)
{ {
entity.pause.PauseTime = pauseTime; entity.pause.PauseTime = pauseTime;
entity.pause.PausePreFrame = 1; if (isTarget) entity.pause.PausePreFrame = 1;
EntityStopMove(entity.ID()); EntityStopMove(entity.ID());
} }
} }

@ -9,14 +9,12 @@ using Game;
/// </summary> /// </summary>
public class ComboSystem : IExecuteSystem, IInitializeSystem public class ComboSystem : IExecuteSystem, IInitializeSystem
{ {
private IGroup<GameEntity> _entities;
private List<int> _tempList = new List<int>();
public void Initialize() public void Initialize()
{ {
_entities = Util.GetGroup(GameMatcher.Hp);
EventManager.Instance.AddEvent<PPlayerInput>(EEvent.PlayerInput, OnPlayerAction); EventManager.Instance.AddEvent<PPlayerInput>(EEvent.PlayerInput, OnPlayerAction);
EventManager.Instance.AddEvent<PEntityMoveInput>(EEvent.EntityMoveInput, OnEntityMove); EventManager.Instance.AddEvent<PEntityMoveInput>(EEvent.EntityMoveInput, OnEntityMove);
} }
public void Execute() public void Execute()
{ {
var entity = Util.GetMaster(); var entity = Util.GetMaster();
@ -24,8 +22,9 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
{ {
return; return;
} }
UpdateComboStance(entity); //更新技能姿态
UpdateCheckCacheTime(entity); //技能缓存时间检查 UpdateComboStance(entity); //更新技能姿态
UpdateCheckCacheTime(entity); //技能缓存时间检查
//检查技能取消 可清除buff //检查技能取消 可清除buff
if (UpdateCheckCancel(entity)) if (UpdateCheckCancel(entity))
@ -36,16 +35,17 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
//硬直状态无法释放技能 //硬直状态无法释放技能
if (!Util.EntityIsStagger(entity)) if (!Util.EntityIsStagger(entity))
{ {
UpdateComboCast(entity);//技能释放 UpdateComboCast(entity); //技能释放
} }
} }
public void RemoveControl(GameEntity entity)
private static void RemoveControl(GameEntity entity)
{ {
Util.RemoveControlBuffAll(entity.ID()); Util.RemoveControlBuffAll(entity.ID());
entity.move.IsFlowing = false; entity.move.IsFlowing = false;
} }
public void UpdateComboStance(GameEntity entity)
private static void UpdateComboStance(GameEntity entity)
{ {
var combo = entity.combo; var combo = entity.combo;
var skill = entity.skill; var skill = entity.skill;
@ -55,6 +55,7 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
{ {
combo.Stance = isGround ? EComboStance.Idle : EComboStance.AirIdle; combo.Stance = isGround ? EComboStance.Idle : EComboStance.AirIdle;
} }
var hasSkill = skill.IsRunning; var hasSkill = skill.IsRunning;
if (isGround && hasSkill) if (isGround && hasSkill)
{ {
@ -66,7 +67,7 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
} }
} }
public void UpdateCheckCacheTime(GameEntity entity) private static void UpdateCheckCacheTime(GameEntity entity)
{ {
var combo = entity.combo; var combo = entity.combo;
var dt = Time.deltaTime; var dt = Time.deltaTime;
@ -82,6 +83,7 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
info.Active = false; info.Active = false;
} }
} }
for (int i = count - 1; i >= 0; i--) for (int i = count - 1; i >= 0; i--)
{ {
var info = combo.InputQueue[i]; var info = combo.InputQueue[i];
@ -90,6 +92,7 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
combo.InputQueue.RemoveAt(i); combo.InputQueue.RemoveAt(i);
} }
} }
//取消缓存的保护时间 //取消缓存的保护时间
var safeTime = combo.TriggerCancelSafeTime; var safeTime = combo.TriggerCancelSafeTime;
if (safeTime > 0) if (safeTime > 0)
@ -99,10 +102,12 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
{ {
safeTime = 0; safeTime = 0;
} }
combo.TriggerCancelSafeTime = safeTime; combo.TriggerCancelSafeTime = safeTime;
} }
} }
public bool UpdateCheckCancel(GameEntity entity)
private static bool UpdateCheckCancel(GameEntity entity)
{ {
var combo = entity.combo; var combo = entity.combo;
var isCancel = false; var isCancel = false;
@ -115,6 +120,7 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
break; break;
} }
} }
if (isCancel) if (isCancel)
{ {
//删除取消指令之前的所有指令 //删除取消指令之前的所有指令
@ -125,12 +131,15 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
{ {
break; break;
} }
info.Active = false; info.Active = false;
} }
} }
return isCancel; return isCancel;
} }
public void UpdateComboCast(GameEntity entity)
private static void UpdateComboCast(GameEntity entity)
{ {
var combo = entity.combo; var combo = entity.combo;
var skill = entity.skill; var skill = entity.skill;
@ -153,6 +162,7 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
{ {
continue; continue;
} }
var stanceNow = combo.Stance; var stanceNow = combo.Stance;
var triggerType = GetSkillTriggerType(input.InputInfo); var triggerType = GetSkillTriggerType(input.InputInfo);
if (triggerType == EComboTriggerType.Jump) if (triggerType == EComboTriggerType.Jump)
@ -197,12 +207,14 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
skillCastId = Util.GetCombo(entity, skillKey); skillCastId = Util.GetCombo(entity, skillKey);
} }
} }
if (!string.IsNullOrEmpty(skillCastId)) if (!string.IsNullOrEmpty(skillCastId))
{ {
ComboCast(entity, skillCastId); ComboCast(entity, skillCastId);
isTrigger = true; isTrigger = true;
} }
} }
if (isTrigger) if (isTrigger)
{ {
//成功触发技能,对指令队列进行更新 //成功触发技能,对指令队列进行更新
@ -229,15 +241,17 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
break; break;
} }
} }
//更新combo最后触发时间 //更新combo最后触发时间
combo.TriggerCancelSafeTime = GameConst.InputRecordTriggerCancelSafeTime; combo.TriggerCancelSafeTime = GameConst.InputRecordTriggerCancelSafeTime;
} }
break; break;
} }
} }
} }
private void ComboCast(GameEntity entity, string skillCastId)
private static void ComboCast(GameEntity entity, string skillCastId)
{ {
var combo = entity.combo; var combo = entity.combo;
var skill = entity.skill; var skill = entity.skill;
@ -250,9 +264,9 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
var castDir = GetSkillCastDir(entity, skillCfgCombo.FreeLock); var castDir = GetSkillCastDir(entity, skillCfgCombo.FreeLock);
Util.CastSkill(entity, skillCastId, skillCfg.Skill.Timeline, castDir); Util.CastSkill(entity, skillCastId, skillCfg.Skill.Timeline, castDir);
} }
private Vector3 GetSkillCastDir(GameEntity entity, bool isFreeLock)
private static Vector3 GetSkillCastDir(GameEntity entity, bool isFreeLock)
{ {
var combo = entity.combo; var combo = entity.combo;
var move = entity.move; var move = entity.move;
@ -270,19 +284,22 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
castDir = moveDir; castDir = moveDir;
} }
} }
if (castDir.x == 0 && castDir.z == 0) if (castDir.x == 0 && castDir.z == 0)
{ {
castDir = move.IsRight ? Vector3.right : Vector3.left; castDir = move.IsRight ? Vector3.right : Vector3.left;
} }
return castDir; return castDir;
} }
private void OnEntityMove(PEntityMoveInput param) private static void OnEntityMove(PEntityMoveInput param)
{ {
var master = Util.GetMaster(); var master = Util.GetMaster();
master.combo.MoveCommand = param.Command; master.combo.MoveCommand = param.Command;
} }
private void OnPlayerAction(PPlayerInput info)
private static void OnPlayerAction(PPlayerInput info)
{ {
var master = Util.GetMaster(); var master = Util.GetMaster();
var pressSet = master.combo.KeyPressSet; var pressSet = master.combo.KeyPressSet;
@ -297,11 +314,13 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
pressSet.Remove(info.Key); pressSet.Remove(info.Key);
} }
} }
if (!Util.IsControl()) if (!Util.IsControl())
{ {
//处于Combo系统不接收输入的状态 //处于Combo系统不接收输入的状态
return; return;
} }
var weaponChangeType = GetEWeaponChangeType(info); var weaponChangeType = GetEWeaponChangeType(info);
if (weaponChangeType != EWeaponChangeType.None) if (weaponChangeType != EWeaponChangeType.None)
{ {
@ -309,6 +328,7 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
ChangeWeapon(weaponChangeType); ChangeWeapon(weaponChangeType);
return; return;
} }
if (GetSkillTriggerType(info) != EComboTriggerType.None) if (GetSkillTriggerType(info) != EComboTriggerType.None)
{ {
//技能指令输入 //技能指令输入
@ -321,7 +341,8 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
return; return;
} }
} }
private void ChangeWeapon(EWeaponChangeType changeType)
private static void ChangeWeapon(EWeaponChangeType changeType)
{ {
var master = Util.GetMaster(); var master = Util.GetMaster();
var combo = master.combo; var combo = master.combo;
@ -342,12 +363,14 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
weaponNew = (int)changeType; weaponNew = (int)changeType;
break; break;
} }
weaponNow.Value = (weaponNew + weaponNum) % weaponNum; weaponNow.Value = (weaponNew + weaponNum) % weaponNum;
//切换武器时重置姿态 //切换武器时重置姿态
// combo.stance = EComboStance.Idle; // combo.stance = EComboStance.Idle;
// combo.preStance = EComboStance.Idle; // combo.preStance = EComboStance.Idle;
} }
private EComboTriggerType GetSkillTriggerType(PPlayerInput info)
private static EComboTriggerType GetSkillTriggerType(PPlayerInput info)
{ {
if (info.Action == EKeyActionType.Press) if (info.Action == EKeyActionType.Press)
{ {
@ -355,39 +378,47 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
{ {
return EComboTriggerType.LightAttack; return EComboTriggerType.LightAttack;
} }
if (info.Key == EFunctionKey.HeavyAttack) if (info.Key == EFunctionKey.HeavyAttack)
{ {
return EComboTriggerType.HeavyAttack; return EComboTriggerType.HeavyAttack;
} }
if (info.Key == EFunctionKey.Flash) if (info.Key == EFunctionKey.Flash)
{ {
return EComboTriggerType.Flash; return EComboTriggerType.Flash;
} }
if (info.Key == EFunctionKey.Jump) if (info.Key == EFunctionKey.Jump)
{ {
return EComboTriggerType.Jump; return EComboTriggerType.Jump;
} }
} }
if (info.Action == EKeyActionType.Release) if (info.Action == EKeyActionType.Release)
{ {
if (info.Key == EFunctionKey.LightAttack) if (info.Key == EFunctionKey.LightAttack)
{ {
return EComboTriggerType.LightAttackRelease; return EComboTriggerType.LightAttackRelease;
} }
if (info.Key == EFunctionKey.HeavyAttack) if (info.Key == EFunctionKey.HeavyAttack)
{ {
return EComboTriggerType.HeavyAttackRelease; return EComboTriggerType.HeavyAttackRelease;
} }
} }
return EComboTriggerType.None; return EComboTriggerType.None;
} }
private EWeaponChangeType GetEWeaponChangeType(PPlayerInput info)
private static EWeaponChangeType GetEWeaponChangeType(PPlayerInput info)
{ {
var ret = EWeaponChangeType.None; var ret = EWeaponChangeType.None;
if (info.Action != EKeyActionType.Press) if (info.Action != EKeyActionType.Press)
{ {
return ret; return ret;
} }
switch (info.Key) switch (info.Key)
{ {
case EFunctionKey.WeaponPre: case EFunctionKey.WeaponPre:
@ -409,6 +440,7 @@ public class ComboSystem : IExecuteSystem, IInitializeSystem
ret = EWeaponChangeType.Set3; ret = EWeaponChangeType.Set3;
break; break;
} }
return ret; return ret;
} }
} }

@ -64,6 +64,10 @@ public class PauseSystem : IExecuteSystem, IInitializeSystem
if (!isChange) if (!isChange)
return; return;
if (entity.IsMaster())
{
Util.SetControl(!pause.IsPause);
}
UpdateAnimPause(entity, pause.IsPause); UpdateAnimPause(entity, pause.IsPause);
UpdateEffectPause(entity, pause.IsPause); UpdateEffectPause(entity, pause.IsPause);

@ -18,29 +18,25 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
foreach (var entity in _entities) foreach (var entity in _entities)
{ {
SettleDebugDraw(entity); SettleDebugDraw(entity);
SettleSkill(entity.skill); SettleSkill(entity);
} }
} }
private static void SettleDebugDraw(GameEntity entity) private static void SettleDebugDraw(GameEntity entity)
{ {
if (!entity.hasHp) if (!entity.hasHp)
{
return; return;
}
Util.DrawShape(entity.hp.HitBoxShape, entity.Pos(), Vector3.right, new Color(0, 1, 0, 0.4f)); Util.DrawShape(entity.hp.HitBoxShape, entity.Pos(), Vector3.right, new Color(0, 1, 0, 0.4f));
} }
private static void SettleSkill(SkillComponent skill) private static void SettleSkill(GameEntity entity)
{ {
while (skill.HitInfo.Count > 0) if (Util.IsPause(entity))
{ return;
if (SettleHit(skill.HitInfo.Dequeue())) while (entity.skill.HitInfo.Count > 0)
{ if (SettleHit(entity.skill.HitInfo.Dequeue()))
break; break;
}
}
} }
private static bool SettleHit(SkillHitInfo hitInfo) private static bool SettleHit(SkillHitInfo hitInfo)
@ -327,7 +323,12 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
break; break;
} }
Util.EntityPause(entity, pauseTime); //单次攻击命中多目标:每2帧结算一次
var isLastHit = hitInfo.hitIndex == hitInfo.hitCount - 1;
if (isLastHit)
Util.EntityPause(entity, pauseTime, false);
else
Util.EntityPause(entity, 1f / GameConst.FPS, false);
Util.EntityPause(target, pauseTime); Util.EntityPause(target, pauseTime);
return pauseTime; return pauseTime;
} }

@ -14,6 +14,8 @@ namespace Game
public float StunkRate; public float StunkRate;
public string SkillId; //是否技能造成的伤害 public string SkillId; //是否技能造成的伤害
public bool IsBreak; public bool IsBreak;
public int hitIndex;
public int hitCount;
} }
public class ClipAttack : TimelineClipBase public class ClipAttack : TimelineClipBase
@ -55,8 +57,10 @@ namespace Game
var rRank = GetRank(param.hitDirType, r, castPos, castDir); var rRank = GetRank(param.hitDirType, r, castPos, castDir);
return lRank.CompareTo(rRank); return lRank.CompareTo(rRank);
}); });
foreach (var target in _tempTargetList) var hitNum = _tempTargetList.Count;
for (var i = 0; i < hitNum; i++)
{ {
var target = _tempTargetList[i];
var targetID = target.ID(); var targetID = target.ID();
var skillHitInfo = new SkillHitInfo var skillHitInfo = new SkillHitInfo
{ {
@ -68,6 +72,8 @@ namespace Game
HitDir = castDir, HitDir = castDir,
SkillId = skill.SkillId.Value, SkillId = skill.SkillId.Value,
IsBreak = true, IsBreak = true,
hitIndex = i,
hitCount = hitNum
}; };
if (!string.IsNullOrEmpty(skillHitInfo.SkillId)) if (!string.IsNullOrEmpty(skillHitInfo.SkillId))
{ {

@ -4889,6 +4889,11 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z propertyPath: m_LocalEulerAnglesHint.z
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4518345749720285479, guid: 33da377d65010f8468eb462b6c382856,
type: 3}
propertyPath: ColorModule.gradient.maxGradient.atime2
value: 57825
objectReference: {fileID: 0}
- target: {fileID: 7116202965895556702, guid: 33da377d65010f8468eb462b6c382856, - target: {fileID: 7116202965895556702, guid: 33da377d65010f8468eb462b6c382856,
type: 3} type: 3}
propertyPath: m_Name propertyPath: m_Name

@ -712,13 +712,13 @@ MonoBehaviour:
m_Name: AttackClip m_Name: AttackClip
m_EditorClassIdentifier: m_EditorClassIdentifier:
template: template:
flowSpeed: {x: 2, y: 1, z: 0} flowSpeed: {x: 10, y: 5, z: 0}
flowTime: 0 flowTime: 0
isFlow: 0 isFlow: 0
damageRate: 1 damageRate: 1
stunRate: 1 stunRate: 1
staggerLevel: 2 staggerLevel: 2
pauseTime: 20 pauseTime: 5
hitId: 0 hitId: 0
hitType: 0 hitType: 0
hitDirType: 3 hitDirType: 3
@ -727,7 +727,7 @@ MonoBehaviour:
Height: 2 Height: 2
SizeX: 2 SizeX: 2
SizeY: 2 SizeY: 2
Radius: 50 Radius: 2.5
Angle: 180 Angle: 180
--- !u!114 &5178577764301111608 --- !u!114 &5178577764301111608
MonoBehaviour: MonoBehaviour:

Loading…
Cancel
Save