From 4ac79f01012549d1a2e5581f0aca3a22dcddf40c Mon Sep 17 00:00:00 2001 From: basil <2428390463@qq.com> Date: Sun, 27 Sep 2026 16:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Knife=20=E6=AD=A6=E5=99=A8?= =?UTF-8?q?=E6=94=BB=E5=87=BB=E5=8A=A8=E7=94=BB=E4=BD=8D=E7=BD=AE=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/EntityLogic/Weapon/WeaponBase.cs | 8 ++--- .../Weapon/WeaponKnife/WeaponKnife.cs | 30 +++++++++++++++---- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Assets/GameMain/Scripts/Runtime/EntityLogic/Weapon/WeaponBase.cs b/Assets/GameMain/Scripts/Runtime/EntityLogic/Weapon/WeaponBase.cs index e30184d..0b3b8d9 100644 --- a/Assets/GameMain/Scripts/Runtime/EntityLogic/Weapon/WeaponBase.cs +++ b/Assets/GameMain/Scripts/Runtime/EntityLogic/Weapon/WeaponBase.cs @@ -151,12 +151,8 @@ namespace SepCore.Entity public virtual ImpactData GetImpactData() { - float baseCrit = GameEntry.Luban != null && GameEntry.Luban.IsReady - ? GameEntry.Luban.Global.WeaponBaseCrit - : 0.05f; - float critMult = GameEntry.Luban != null && GameEntry.Luban.IsReady - ? GameEntry.Luban.Global.CritMultiplier - : 1.5f; + float baseCrit = GameEntry.Luban.Global.WeaponBaseCrit; + float critMult = GameEntry.Luban.Global.CritMultiplier; return new ImpactData( WeaponData.OwnerCamp, diff --git a/Assets/GameMain/Scripts/Runtime/EntityLogic/Weapon/WeaponKnife/WeaponKnife.cs b/Assets/GameMain/Scripts/Runtime/EntityLogic/Weapon/WeaponKnife/WeaponKnife.cs index e731926..d47e592 100644 --- a/Assets/GameMain/Scripts/Runtime/EntityLogic/Weapon/WeaponKnife/WeaponKnife.cs +++ b/Assets/GameMain/Scripts/Runtime/EntityLogic/Weapon/WeaponKnife/WeaponKnife.cs @@ -39,15 +39,37 @@ namespace SepCore.Entity _isAttacking = true; Transform parentTransform = CachedTransform.parent; _attackParent = parentTransform; - _attackCenter = _target != null ? _target.CachedTransform.position : CachedTransform.position; + + Vector3 startPos = CachedTransform.position; + Vector3 targetPos; + + if (_target != null && _target.Available) + { + targetPos = _target.CachedTransform.position; + targetPos.y = startPos.y; + + Vector3 delta = targetPos - startPos; + float maxRange = CurrentAttackRange; + if (delta.sqrMagnitude > maxRange * maxRange) + { + targetPos = startPos + delta.normalized * maxRange; + } + } + else + { + targetPos = startPos + CachedTransform.forward * CurrentAttackRange; + } + + _attackCenter = _target != null && _target.Available ? _target.CachedTransform.position : targetPos; CachedTransform.SetParent(null); - Vector3 targetPos = CachedTransform.position + CachedTransform.forward * CurrentAttackRange; _attackSequence = DOTween.Sequence(); _attackSequence.Append(CachedTransform.DOMove(targetPos, _attackDuration).SetEase(Ease.OutQuad)); _attackSequence.AppendCallback(() => { - _attackEffect.Play(this, _attackCenter, null, HitRadius); + Vector3 hitPoint = _target != null && _target.Available ? _target.CachedTransform.position : targetPos; + _attackCenter = hitPoint; + _attackEffect.Play(this, _attackCenter, _target, HitRadius); ApplyGroundAreaDamage(); if (_attackParent != null) { @@ -74,8 +96,6 @@ namespace SepCore.Entity return; } - if (_hitResults == null || _hitResults.Length == 0) return; - int hitCount = Physics.OverlapSphereNonAlloc(_attackCenter, radius, _hitResults, _hitMask, QueryTriggerInteraction.Collide);