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