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;
}
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.PausePreFrame = 1;
if (isTarget) entity.pause.PausePreFrame = 1;
EntityStopMove(entity.ID());
}
}

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

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

@ -18,30 +18,26 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
foreach (var entity in _entities)
{
SettleDebugDraw(entity);
SettleSkill(entity.skill);
SettleSkill(entity);
}
}
private static void SettleDebugDraw(GameEntity entity)
{
if (!entity.hasHp)
{
return;
}
Util.DrawShape(entity.hp.HitBoxShape, entity.Pos(), Vector3.right, new Color(0, 1, 0, 0.4f));
}
private static void SettleSkill(SkillComponent skill)
{
while (skill.HitInfo.Count > 0)
{
if (SettleHit(skill.HitInfo.Dequeue()))
private static void SettleSkill(GameEntity entity)
{
if (Util.IsPause(entity))
return;
while (entity.skill.HitInfo.Count > 0)
if (SettleHit(entity.skill.HitInfo.Dequeue()))
break;
}
}
}
private static bool SettleHit(SkillHitInfo hitInfo)
{
@ -327,7 +323,12 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
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);
return pauseTime;
}

@ -14,6 +14,8 @@ namespace Game
public float StunkRate;
public string SkillId; //是否技能造成的伤害
public bool IsBreak;
public int hitIndex;
public int hitCount;
}
public class ClipAttack : TimelineClipBase
@ -55,8 +57,10 @@ namespace Game
var rRank = GetRank(param.hitDirType, r, castPos, castDir);
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 skillHitInfo = new SkillHitInfo
{
@ -68,6 +72,8 @@ namespace Game
HitDir = castDir,
SkillId = skill.SkillId.Value,
IsBreak = true,
hitIndex = i,
hitCount = hitNum
};
if (!string.IsNullOrEmpty(skillHitInfo.SkillId))
{

@ -4889,6 +4889,11 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 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,
type: 3}
propertyPath: m_Name

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

Loading…
Cancel
Save