From e5a31a89f651ceea5d0807d558c52814c5100dc2 Mon Sep 17 00:00:00 2001 From: cd <-> Date: Sun, 28 May 2023 03:32:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=B9=E5=A2=99=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/Assets/Game/Driver.unity | 101 ++++-------------- .../Scripts/ECS/Component/MoveComponent.cs | 6 ++ .../Game/Scripts/ECS/System/MoveSystem.cs | 40 ++++--- .../Game/Scripts/ECS/System/SettleSystem.cs | 11 +- .../EffectPoolManager/EffectPoolManager.cs | 2 - .../Game/Scripts/Util/Physics/UtilPhysics.cs | 1 + .../skill_hero01_long_air_attack01.playable | 2 +- .../skill_hero01_long_attack01.playable | 2 +- .../skill_hero01_long_skill0301.playable | 2 +- 9 files changed, 66 insertions(+), 101 deletions(-) diff --git a/client/Assets/Game/Driver.unity b/client/Assets/Game/Driver.unity index 17d3958..a5ff01c 100644 --- a/client/Assets/Game/Driver.unity +++ b/client/Assets/Game/Driver.unity @@ -877,63 +877,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &809832855 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 1464602466083886, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} - propertyPath: m_Name - value: effect_cast_ground01 - objectReference: {fileID: 0} - - target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} - propertyPath: m_RootOrder - value: 7 - objectReference: {fileID: 0} - - target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} - propertyPath: m_LocalPosition.z - value: -1 - objectReference: {fileID: 0} - - target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} - propertyPath: m_LocalRotation.y - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4775647569752226, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 2ce414eda8c2fa64bb295d4e323cec19, type: 3} --- !u!1001 &1015172259 PrefabInstance: m_ObjectHideFlags: 0 @@ -1761,72 +1704,72 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &6855760895463423098 +--- !u!1001 &3695570339981591418 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 4239479062022509658, guid: 2f61d8469e470a04b8a91b91557e71e8, + - target: {fileID: 3696463158923097795, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} propertyPath: m_Name - value: effect_hit_ground01 + value: effect_hit_wall01 objectReference: {fileID: 0} - - target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8, + - target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} propertyPath: m_RootOrder - value: 13 + value: 7 objectReference: {fileID: 0} - - target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8, + - target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} propertyPath: m_LocalPosition.x - value: -1.721 + value: 0 objectReference: {fileID: 0} - - target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8, + - target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} propertyPath: m_LocalPosition.y - value: 0.001 + value: 0 objectReference: {fileID: 0} - - target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8, + - target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} propertyPath: m_LocalPosition.z - value: 0 + value: -1 objectReference: {fileID: 0} - - target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8, + - target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - - target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8, + - target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - - target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8, + - target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - - target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8, + - target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - - target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8, + - target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8, + - target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} propertyPath: m_LocalEulerAnglesHint.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 4239479062022509663, guid: 2f61d8469e470a04b8a91b91557e71e8, + - target: {fileID: 3700193944628372047, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 2f61d8469e470a04b8a91b91557e71e8, type: 3} + m_SourcePrefab: {fileID: 100100000, guid: 843d8523135f41b43ab8a83726fdfe42, type: 3} diff --git a/client/Assets/Game/Scripts/ECS/Component/MoveComponent.cs b/client/Assets/Game/Scripts/ECS/Component/MoveComponent.cs index b19ddae..1e10bd2 100644 --- a/client/Assets/Game/Scripts/ECS/Component/MoveComponent.cs +++ b/client/Assets/Game/Scripts/ECS/Component/MoveComponent.cs @@ -136,10 +136,16 @@ namespace Game return Vector3.zero; } + if (e.move.IsFlowing && e.hasHp) + { + return e.hp.LastDamageDir; + } + if (e.hasPause && e.pause.IsPause) { return e.pause.VelocityCache; } + return e.move.Velocity; } diff --git a/client/Assets/Game/Scripts/ECS/System/MoveSystem.cs b/client/Assets/Game/Scripts/ECS/System/MoveSystem.cs index f4217c8..4f63257 100644 --- a/client/Assets/Game/Scripts/ECS/System/MoveSystem.cs +++ b/client/Assets/Game/Scripts/ECS/System/MoveSystem.cs @@ -19,8 +19,8 @@ public class MoveSystem : IExecuteSystem, IInitializeSystem { CheckHit(entity); //打射线 检查角色四周是否有阻挡 是否在地面 TurnUpdate(entity.move); //更新转向 - ReboundUpdate(entity); //更新落地反弹 ReboundWallUpdate(entity); //更新撞墙反弹 + ReboundUpdate(entity); //更新落地反弹 } } @@ -121,6 +121,8 @@ public class MoveSystem : IExecuteSystem, IInitializeSystem Util.CastGroundStaticEffect(GameConst.EffectHitGround1, entity.ID()); //卡帧 Util.EntityPause(entity, 0.05f); + //抖动 + Util.EntityShake(entity, 2); //缩放 Util.EntityScale(entity, Vector3.right * 6); } @@ -149,30 +151,35 @@ public class MoveSystem : IExecuteSystem, IInitializeSystem if (Util.HasSetSpeedBuff(entity.ID())) { //撞墙反弹-大 + Util.RemoveHitDownBuff(entity.ID()); Util.RemoveSetSpeedBuff(entity.ID()); - move.Velocity = new Vector3(-move.Velocity.x, 6, -move.Velocity.z); + //反弹方向xz沿CrashWallNormal,值为当前速度钳制[2,10] + var speed = new Vector3(move.Velocity.x, 0, move.Velocity.z).magnitude; + speed = Mathf.Clamp(speed, 2, 10); + var velocity = move.CrashWallNormal * speed; + move.Velocity = new Vector3(velocity.x, 6, velocity.z); if (entity.hasAnimation) { entity.animation.AirHitMsg = true; } - if (Util.HasHitDownBuff(entity.ID())) - { - Util.RemoveHitDownBuff(entity.ID()); - } - //撞墙反弹特效 Util.CastWallStaticEffect(GameConst.EffectHitWall1, entity.ID(), move.CrashWallPosition, move.CrashWallNormal); //卡帧 Util.EntityPause(entity, 0.05f); + //抖动 + Util.EntityShake(entity, 2); //缩放 Util.EntityScale(entity, Vector3.up * 6); } else { //撞墙反弹-小 - move.Velocity = new Vector3(-move.Velocity.x, move.Velocity.y, -move.Velocity.z); + var speed = new Vector3(move.Velocity.x, 0, move.Velocity.z).magnitude; + speed = Mathf.Clamp(speed, 2, 3); + var velocity = move.CrashWallNormal * speed; + move.Velocity = velocity; //撞墙特效 Util.CastWallStaticEffect(GameConst.EffectHitWall2, entity.ID(), move.CrashWallPosition, move.CrashWallNormal); @@ -185,28 +192,29 @@ public class MoveSystem : IExecuteSystem, IInitializeSystem { var move = entity.move; var view = entity.view; - RaycastHit hitInfo; var bodySize = view.Collider.bounds.size; const float checkOffset = 0.1f; const float checkLength = 0.2f; //检查落地 - move.IsGround = Physics.Raycast(move.Position + Vector3.up * checkOffset, Vector3.down, out hitInfo, - checkLength, UtilPhysics.LayerMaskDefault); + var checkDir = Vector3.down; + var startPos = move.Position + Vector3.up * checkOffset; + move.IsGround = Physics.Raycast(startPos, checkDir, out var hitInfo, checkLength, UtilPhysics.LayerMaskDefault); move.IsGroundLogic = move.IsGround && move.JumpState == EJumpState.OnGround; if (move.IsGround) { move.GroundPosition = hitInfo.point; } - Util.Draw(move.Position + Vector3.up * checkOffset, - move.Position + Vector3.up * checkOffset + Vector3.down * checkLength, Color.green); + Util.Draw(startPos, startPos + checkDir * checkLength, move.IsGround ? Color.red : Color.green); //检查移动贴墙 - var checkDir = move.MoveDir; - var startPos = move.Position + Vector3.up * bodySize.y / 2 + checkDir * (bodySize.x / 2 - checkOffset); + checkDir = move.MoveDir; + startPos = move.Position + Vector3.up * bodySize.y / 2 + checkDir * (bodySize.x / 2 - checkOffset); move.IsAgainstWall = Physics.Raycast(startPos, checkDir, out hitInfo, checkLength, UtilPhysics.LayerMaskWall); + Util.Draw(startPos, startPos + checkDir * checkLength, move.IsAgainstWall ? Color.red : Color.green); + //检查冲撞贴墙 checkDir = move.Velocity.normalized; startPos = move.Position + Vector3.up * bodySize.y / 2 + checkDir * (bodySize.x / 2 - checkOffset); @@ -217,6 +225,6 @@ public class MoveSystem : IExecuteSystem, IInitializeSystem move.CrashWallNormal = hitInfo.normal; } - Util.Draw(startPos, startPos + checkDir * checkLength, move.IsAgainstWall ? Color.red : Color.green); + Util.Draw(startPos, startPos + checkDir * checkLength, move.IsCrashToWall ? Color.red : Color.green); } } \ No newline at end of file diff --git a/client/Assets/Game/Scripts/ECS/System/SettleSystem.cs b/client/Assets/Game/Scripts/ECS/System/SettleSystem.cs index 09938f7..59edcad 100644 --- a/client/Assets/Game/Scripts/ECS/System/SettleSystem.cs +++ b/client/Assets/Game/Scripts/ECS/System/SettleSystem.cs @@ -296,7 +296,16 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem //命中瞬间、在pause之前生效部分位移 var move = target.move; - move.Transform.position += flowSpeed * Time.deltaTime * 2; + var posAdd = flowSpeed * Time.deltaTime * 2; + var targetPos = move.Position + posAdd; + var startPos = move.Position - posAdd.normalized * 0.001f; + RaycastHit raycastHit; + if (Physics.Raycast(startPos, posAdd, out raycastHit, posAdd.magnitude, UtilPhysics.LayerMaskStatic)) + { + targetPos = raycastHit.point; + } + + move.Position = targetPos; return flowSpeed; } diff --git a/client/Assets/Game/Scripts/ObjectPool/PoolManager/EffectPoolManager/EffectPoolManager.cs b/client/Assets/Game/Scripts/ObjectPool/PoolManager/EffectPoolManager/EffectPoolManager.cs index 36b3756..d5f91f9 100644 --- a/client/Assets/Game/Scripts/ObjectPool/PoolManager/EffectPoolManager/EffectPoolManager.cs +++ b/client/Assets/Game/Scripts/ObjectPool/PoolManager/EffectPoolManager/EffectPoolManager.cs @@ -212,8 +212,6 @@ namespace Game // 墙面特效:在实体对应地面播放,跟随实体暂停/销毁 但是不跟随移动 public static void CastWallStaticEffect(string effectId, int targetEntity, Vector3 pos, Vector3 normal) { - // 忽略normal的y轴 保证特效垂直于墙面 - normal.y = 0; var rot = Util.Vec3ToRot(normal); CastEffect(effectId, pos, rot, targetEntity, 0, false); } diff --git a/client/Assets/Game/Scripts/Util/Physics/UtilPhysics.cs b/client/Assets/Game/Scripts/Util/Physics/UtilPhysics.cs index 0ad3252..8505ca4 100644 --- a/client/Assets/Game/Scripts/Util/Physics/UtilPhysics.cs +++ b/client/Assets/Game/Scripts/Util/Physics/UtilPhysics.cs @@ -16,5 +16,6 @@ namespace Game public static readonly int LayerMaskPlayer = 1 << LayerPlayer; public static readonly int LayerMaskMonster = 1 << LayerMonster; public static readonly int LayerMaskCharacter = LayerMaskPlayer | LayerMaskMonster; + public static readonly int LayerMaskStatic = LayerMaskDefault | LayerMaskWall; } } \ No newline at end of file diff --git a/client/Assets/Resources/Timeline/skill_hero01_long_air_attack01.playable b/client/Assets/Resources/Timeline/skill_hero01_long_air_attack01.playable index f2cbdfa..846a8c4 100644 --- a/client/Assets/Resources/Timeline/skill_hero01_long_air_attack01.playable +++ b/client/Assets/Resources/Timeline/skill_hero01_long_air_attack01.playable @@ -648,7 +648,7 @@ MonoBehaviour: isRaycast: 0 center: {x: 1, y: 1, z: 0} halfExtents: {x: 1.5, y: 1, z: 0.5} - flowSpeed: {x: 1, y: 2, z: 0} + flowSpeed: {x: 1, y: 1, z: 0} flowTime: 0 isFlow: 0 damageRate: 0.5 diff --git a/client/Assets/Resources/Timeline/skill_hero01_long_attack01.playable b/client/Assets/Resources/Timeline/skill_hero01_long_attack01.playable index 0e7c3b7..b723b2e 100644 --- a/client/Assets/Resources/Timeline/skill_hero01_long_attack01.playable +++ b/client/Assets/Resources/Timeline/skill_hero01_long_attack01.playable @@ -692,7 +692,7 @@ MonoBehaviour: isRaycast: 0 center: {x: 1, y: 1, z: 0} halfExtents: {x: 1.5, y: 1, z: 0.5} - flowSpeed: {x: 3, y: 1, z: 0} + flowSpeed: {x: 2, y: 1, z: 0} flowTime: 0 isFlow: 0 damageRate: 1 diff --git a/client/Assets/Resources/Timeline/skill_hero01_long_skill0301.playable b/client/Assets/Resources/Timeline/skill_hero01_long_skill0301.playable index 464fa24..a3c83cf 100644 --- a/client/Assets/Resources/Timeline/skill_hero01_long_skill0301.playable +++ b/client/Assets/Resources/Timeline/skill_hero01_long_skill0301.playable @@ -585,7 +585,7 @@ MonoBehaviour: isRaycast: 0 center: {x: 1, y: 1, z: 0} halfExtents: {x: 1.5, y: 1, z: 0.5} - flowSpeed: {x: 2, y: 0, z: 0} + flowSpeed: {x: 3, y: 1, z: 0} flowTime: 0 isFlow: 0 damageRate: 0.5