接入新逻辑
# Conflicts: # Assets/Scenes/RopeTest.unity # Assets/Scripts/Fishing/New/View/Player/Tackle/FLine.cs # Assets/Scripts/Fishing/Rope/Rope.cs # Assets/Scripts/Fishing/Rope/Rope.cs.meta
This commit is contained in:
138
Assets/Scripts/Fishing/New/View/FishingLine/FLineLogicNode.cs
Normal file
138
Assets/Scripts/Fishing/New/View/FishingLine/FLineLogicNode.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public enum FLineLogicNodeType
|
||||
{
|
||||
Start,
|
||||
Bobber,
|
||||
End
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 硬线节点组件 - 可选,用于更方便的管理
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class FLineLogicNode : MonoBehaviour
|
||||
{
|
||||
[Header("节点设置")] public FLineLogicNodeType NodeType = FLineLogicNodeType.Bobber;
|
||||
[SerializeField] private bool isKinematic = false;
|
||||
[SerializeField] private float mass = 1f;
|
||||
|
||||
[Header("到下一个节点的段配置")] [SerializeField, Min(0.01f)]
|
||||
private float nextSegmentMaxLength = 1f;
|
||||
|
||||
[SerializeField, Min(0f)] private float nextSegmentMinLength = 0f;
|
||||
|
||||
private Rigidbody rb;
|
||||
private FLine parentCable;
|
||||
|
||||
public Rigidbody Rigidbody
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!rb)
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
return rb;
|
||||
}
|
||||
}
|
||||
|
||||
public float NextSegmentMaxLength
|
||||
{
|
||||
get => nextSegmentMaxLength;
|
||||
set => nextSegmentMaxLength = Mathf.Max(0.01f, value);
|
||||
}
|
||||
|
||||
public float NextSegmentMinLength
|
||||
{
|
||||
get => nextSegmentMinLength;
|
||||
set => nextSegmentMinLength = Mathf.Max(0f, value);
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
rb = Rigidbody;
|
||||
InitializeNode();
|
||||
}
|
||||
|
||||
void OnValidate()
|
||||
{
|
||||
mass = Mathf.Max(0.0001f, mass);
|
||||
nextSegmentMaxLength = Mathf.Max(0.01f, nextSegmentMaxLength);
|
||||
nextSegmentMinLength = Mathf.Max(0f, nextSegmentMinLength);
|
||||
}
|
||||
|
||||
private void InitializeNode()
|
||||
{
|
||||
if (Rigidbody)
|
||||
{
|
||||
Rigidbody.isKinematic = isKinematic;
|
||||
Rigidbody.mass = Mathf.Max(0.0001f, mass);
|
||||
Rigidbody.useGravity = !isKinematic;
|
||||
}
|
||||
}
|
||||
|
||||
public void AttachToCable(FLine cable)
|
||||
{
|
||||
parentCable = cable;
|
||||
|
||||
// // 计算到前一个节点的距离
|
||||
// var bodies = parentCable.GetConnectedBodies();
|
||||
// int myIndex = bodies.IndexOf(rb);
|
||||
//
|
||||
// if (myIndex > 0 && bodies[myIndex - 1] != null)
|
||||
// {
|
||||
// float distanceToPrevious = Vector3.Distance(
|
||||
// transform.position,
|
||||
// bodies[myIndex - 1].position
|
||||
// );
|
||||
// parentCable.SetSegmentLength(myIndex - 1, distanceToPrevious);
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 固定/释放此节点
|
||||
/// </summary>
|
||||
public void SetFixed(bool fixed_)
|
||||
{
|
||||
if (Rigidbody)
|
||||
{
|
||||
isKinematic = fixed_;
|
||||
Rigidbody.isKinematic = fixed_;
|
||||
Rigidbody.useGravity = !fixed_;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 施加力到此节点(会影响相邻节点)
|
||||
/// </summary>
|
||||
public void ApplyForce(Vector3 force, ForceMode mode = ForceMode.Force)
|
||||
{
|
||||
if (parentCable)
|
||||
{
|
||||
parentCable.ApplyForceAtBody(Rigidbody, force, mode);
|
||||
}
|
||||
else if (Rigidbody)
|
||||
{
|
||||
Rigidbody.AddForce(force, mode);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSegmentLengths(float maxLength, float minLength)
|
||||
{
|
||||
NextSegmentMaxLength = maxLength;
|
||||
NextSegmentMinLength = minLength;
|
||||
}
|
||||
|
||||
public bool TryGetAdjacentBodies(out Rigidbody previousBody, out Rigidbody nextBody)
|
||||
{
|
||||
previousBody = null;
|
||||
nextBody = null;
|
||||
|
||||
return parentCable && parentCable.TryGetAdjacentBodies(this, out previousBody, out nextBody);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 324bd710e0c5460ea880c6314ae95058
|
||||
timeCreated: 1776948853
|
||||
1006
Assets/Scripts/Fishing/New/View/FishingLine/FLineRenderer.cs
Normal file
1006
Assets/Scripts/Fishing/New/View/FishingLine/FLineRenderer.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e43f5ab12b64bb9a47c0c674a3177f2
|
||||
timeCreated: 1776960000
|
||||
349
Assets/Scripts/Fishing/New/View/FishingLine/FLineTest.cs
Normal file
349
Assets/Scripts/Fishing/New/View/FishingLine/FLineTest.cs
Normal file
@@ -0,0 +1,349 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 硬线系统测试脚本,直接读取 FLine 已配置的节点。
|
||||
/// </summary>
|
||||
public class FLineTest : MonoBehaviour
|
||||
{
|
||||
[Header("测试控制")] [SerializeField] private KeyCode fixMiddleKey = KeyCode.M;
|
||||
[SerializeField] private KeyCode applyForceKey = KeyCode.F;
|
||||
[SerializeField] private Vector3 testForce = new Vector3(0f, 10f, 0f);
|
||||
|
||||
[Header("动态间距控制")]
|
||||
// [SerializeField] private KeyCode extendKey = KeyCode.UpArrow;
|
||||
// [SerializeField] private KeyCode contractKey = KeyCode.DownArrow;
|
||||
[SerializeField]
|
||||
private KeyCode resetKey = KeyCode.Alpha0;
|
||||
|
||||
[SerializeField] private KeyCode pullFirstKey = KeyCode.UpArrow;
|
||||
[SerializeField] private KeyCode relaxFirstKey = KeyCode.DownArrow;
|
||||
[SerializeField, Min(0.01f)] private float extendAmount = 0.5f;
|
||||
[SerializeField, Min(0.01f)] private float holdAdjustSpeed = 1f;
|
||||
[SerializeField, Min(0.01f)] private float transitionSpeed = 2f;
|
||||
[SerializeField] private bool smoothTransition = true;
|
||||
|
||||
[SerializeField] private FLine line;
|
||||
private float[] initialLengths;
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
extendAmount = Mathf.Max(0.01f, extendAmount);
|
||||
holdAdjustSpeed = Mathf.Max(0.01f, holdAdjustSpeed);
|
||||
transitionSpeed = Mathf.Max(0.01f, transitionSpeed);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
RefreshInitialLengths(true);
|
||||
line.OnLineBreakRequested += OnLineBreakRequested;
|
||||
}
|
||||
|
||||
private void OnLineBreakRequested(FLine lineSolver)
|
||||
{
|
||||
Debug.LogError($"当前拉力达到极限,切线,极限时间={lineSolver.LimitStateTime}");
|
||||
|
||||
var nodes = line.GetLineNodes();
|
||||
nodes[^1].Rigidbody.isKinematic = false;
|
||||
// line.Body.isKinematic = false;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!EnsureCable())
|
||||
return;
|
||||
|
||||
RefreshInitialLengths();
|
||||
HandleInput();
|
||||
|
||||
if (line.CurrentBreakStretchPercent > 10f)
|
||||
{
|
||||
Debug.LogError(
|
||||
$"当前极限情况,CurrentBreakStretchPercent={line.CurrentBreakStretchPercent} CurrentStretchLength={line.CurrentStretchLength} TotalLength={line.TotalLength} LimitStateTime={line.LimitStateTime}");
|
||||
}
|
||||
}
|
||||
|
||||
private bool EnsureCable()
|
||||
{
|
||||
if (line)
|
||||
return true;
|
||||
|
||||
line = GetComponent<FLine>();
|
||||
return line != null;
|
||||
}
|
||||
|
||||
private List<FLineLogicNode> GetNodes()
|
||||
{
|
||||
return line != null ? line.GetLineNodes() : null;
|
||||
}
|
||||
|
||||
private void RefreshInitialLengths(bool force = false)
|
||||
{
|
||||
List<FLineLogicNode> nodes = GetNodes();
|
||||
int segmentCount = nodes != null ? Mathf.Max(0, nodes.Count - 1) : 0;
|
||||
|
||||
if (!force && initialLengths != null && initialLengths.Length == segmentCount)
|
||||
return;
|
||||
|
||||
initialLengths = new float[segmentCount];
|
||||
for (int i = 0; i < segmentCount; i++)
|
||||
{
|
||||
float configuredLength = line.GetSegmentMaxLength(i);
|
||||
if (configuredLength <= 0f)
|
||||
configuredLength = Mathf.Max(0.01f, line.GetCurrentSegmentLength(i));
|
||||
|
||||
initialLengths[i] = Mathf.Max(0.01f, configuredLength);
|
||||
}
|
||||
}
|
||||
|
||||
private float GetCurrentMaxLength(int segmentIndex)
|
||||
{
|
||||
float length = line.GetSegmentMaxLength(segmentIndex);
|
||||
return Mathf.Max(0.01f, length);
|
||||
}
|
||||
|
||||
private float GetTargetMaxLength(int segmentIndex)
|
||||
{
|
||||
float length = line.GetTargetMaxLength(segmentIndex);
|
||||
if (length <= 0f)
|
||||
length = line.GetSegmentMaxLength(segmentIndex);
|
||||
|
||||
return Mathf.Max(0.01f, length);
|
||||
}
|
||||
|
||||
private int GetSegmentCount()
|
||||
{
|
||||
return initialLengths != null ? initialLengths.Length : 0;
|
||||
}
|
||||
|
||||
private void HandleInput()
|
||||
{
|
||||
HandleOriginalControls();
|
||||
HandleDynamicDistanceControls();
|
||||
}
|
||||
|
||||
private void HandleOriginalControls()
|
||||
{
|
||||
List<FLineLogicNode> nodes = GetNodes();
|
||||
if (nodes == null)
|
||||
return;
|
||||
|
||||
if (Input.GetKeyDown(fixMiddleKey) && nodes.Count >= 3)
|
||||
{
|
||||
int middleIndex = nodes.Count / 2;
|
||||
FLineLogicNode middleNode = nodes[middleIndex];
|
||||
Rigidbody middleRb = middleNode ? middleNode.Rigidbody : null;
|
||||
|
||||
if (middleNode && middleRb)
|
||||
{
|
||||
bool newState = !middleRb.isKinematic;
|
||||
middleNode.SetFixed(newState);
|
||||
Debug.Log($"中间节点({middleIndex}) {(newState ? "固定" : "释放")} - 观察其他节点变化");
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(applyForceKey) && nodes.Count > 2)
|
||||
{
|
||||
int randomIndex = Random.Range(1, nodes.Count - 1);
|
||||
FLineLogicNode targetNode = nodes[randomIndex];
|
||||
Rigidbody targetRb = targetNode ? targetNode.Rigidbody : null;
|
||||
|
||||
if (targetNode && targetRb && !targetRb.isKinematic)
|
||||
{
|
||||
targetNode.ApplyForce(testForce, ForceMode.Impulse);
|
||||
Debug.Log($"对节点{randomIndex}施加力: {testForce} - 观察传递效果");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleDynamicDistanceControls()
|
||||
{
|
||||
if (line == null || initialLengths == null || initialLengths.Length == 0)
|
||||
return;
|
||||
|
||||
// HandleLengthAdjustInput();
|
||||
|
||||
if (Input.GetKeyDown(resetKey))
|
||||
ResetAllSegments();
|
||||
|
||||
if (Input.GetKeyDown(pullFirstKey))
|
||||
PullFirstSegment(extendAmount * 0.5f);
|
||||
|
||||
if (Input.GetKeyDown(relaxFirstKey))
|
||||
RelaxFirstSegment(extendAmount * 0.5f);
|
||||
|
||||
if (Input.mouseScrollDelta.y != 0f && Input.GetKey(KeyCode.LeftShift))
|
||||
AdjustNearestSegment(Input.mouseScrollDelta.y * 0.1f);
|
||||
}
|
||||
|
||||
|
||||
private void ApplySegmentTargetLength(int segmentIndex, float targetLength)
|
||||
{
|
||||
line.SetSegmentMaxLength(segmentIndex, targetLength, transitionSpeed);
|
||||
}
|
||||
|
||||
private void ResetAllSegments()
|
||||
{
|
||||
for (int i = 0; i < GetSegmentCount(); i++)
|
||||
{
|
||||
ApplySegmentTargetLength(i, initialLengths[i]);
|
||||
}
|
||||
|
||||
Debug.Log("重置绳索到 FLine 初始节点配置");
|
||||
}
|
||||
|
||||
private void PullFirstSegment(float amount)
|
||||
{
|
||||
if (GetSegmentCount() <= 0)
|
||||
return;
|
||||
|
||||
float targetLength = Mathf.Max(0.1f, GetTargetMaxLength(0) - amount);
|
||||
ApplySegmentTargetLength(0, targetLength);
|
||||
Debug.Log($"拉紧第一段到 {targetLength:F2}");
|
||||
}
|
||||
|
||||
private void RelaxFirstSegment(float amount)
|
||||
{
|
||||
if (GetSegmentCount() <= 0)
|
||||
return;
|
||||
|
||||
float targetLength = GetTargetMaxLength(0) + amount;
|
||||
ApplySegmentTargetLength(0, targetLength);
|
||||
Debug.Log($"放松第一段到 {targetLength:F2}");
|
||||
}
|
||||
|
||||
private void AdjustNearestSegment(float amount)
|
||||
{
|
||||
int nearestSegment = FindNearestSegmentToCamera();
|
||||
if (nearestSegment < 0 || nearestSegment >= GetSegmentCount())
|
||||
return;
|
||||
|
||||
float targetLength = Mathf.Max(0.1f, GetTargetMaxLength(nearestSegment) + amount);
|
||||
ApplySegmentTargetLength(nearestSegment, targetLength);
|
||||
Debug.Log($"调整段{nearestSegment}到 {targetLength:F2}");
|
||||
}
|
||||
|
||||
private int FindNearestSegmentToCamera()
|
||||
{
|
||||
Camera cam = Camera.main;
|
||||
List<FLineLogicNode> nodes = GetNodes();
|
||||
if (cam == null || nodes == null || nodes.Count < 2)
|
||||
return -1;
|
||||
|
||||
int nearestSegment = -1;
|
||||
float nearestDistance = float.MaxValue;
|
||||
|
||||
for (int i = 0; i < nodes.Count - 1; i++)
|
||||
{
|
||||
Rigidbody bodyA = nodes[i] ? nodes[i].Rigidbody : null;
|
||||
Rigidbody bodyB = nodes[i + 1] ? nodes[i + 1].Rigidbody : null;
|
||||
if (!bodyA || !bodyB)
|
||||
continue;
|
||||
|
||||
Vector3 midPoint = (bodyA.position + bodyB.position) * 0.5f;
|
||||
Vector3 screenPoint = cam.WorldToScreenPoint(midPoint);
|
||||
Vector3 mousePos = Input.mousePosition;
|
||||
|
||||
float distance = Vector2.Distance(
|
||||
new Vector2(screenPoint.x, screenPoint.y),
|
||||
new Vector2(mousePos.x, mousePos.y)
|
||||
);
|
||||
|
||||
if (distance < nearestDistance)
|
||||
{
|
||||
nearestDistance = distance;
|
||||
nearestSegment = i;
|
||||
}
|
||||
}
|
||||
|
||||
return nearestSegment;
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (!EnsureCable())
|
||||
return;
|
||||
|
||||
RefreshInitialLengths();
|
||||
|
||||
List<FLineLogicNode> nodes = GetNodes();
|
||||
int nodeCount = nodes != null ? nodes.Count : 0;
|
||||
|
||||
GUILayout.BeginArea(new Rect(10f, 10f, 360f, 260f));
|
||||
GUILayout.Label("=== 硬线系统测试控制 ===");
|
||||
GUILayout.Label("原始控制:");
|
||||
GUILayout.Label($" {fixMiddleKey} - 固定/释放中间节点");
|
||||
GUILayout.Label($" {applyForceKey} - 随机施加力");
|
||||
GUILayout.Space(10f);
|
||||
GUILayout.Label("动态间距控制:");
|
||||
GUILayout.Label($" {resetKey} - 重置到初始节点配置");
|
||||
GUILayout.Label($" {pullFirstKey} - 拉紧第一段");
|
||||
GUILayout.Label($" {relaxFirstKey} - 放松第一段");
|
||||
GUILayout.Label(" Shift+滚轮 - 调整最近段");
|
||||
GUILayout.Space(10f);
|
||||
GUILayout.Label("设置:");
|
||||
GUILayout.Label($" 节点数: {nodeCount}");
|
||||
GUILayout.Label(" 初始长度来源: FLine 节点配置");
|
||||
GUILayout.Label($" 过渡模式: {(smoothTransition ? "平滑" : "即时")}");
|
||||
if (smoothTransition)
|
||||
GUILayout.Label($" 过渡速度: {transitionSpeed:F1}");
|
||||
|
||||
GUILayout.EndArea();
|
||||
|
||||
GUILayout.BeginArea(new Rect(10f, 280f, 360f, 220f));
|
||||
GUILayout.Label("=== 各段实际长度 ===");
|
||||
|
||||
for (int i = 0; i < Mathf.Min(GetSegmentCount(), 10); i++)
|
||||
{
|
||||
Rigidbody bodyA = nodes[i] ? nodes[i].Rigidbody : null;
|
||||
Rigidbody bodyB = nodes[i + 1] ? nodes[i + 1].Rigidbody : null;
|
||||
if (!bodyA || !bodyB)
|
||||
continue;
|
||||
|
||||
float actualDistance = Vector3.Distance(bodyA.position, bodyB.position);
|
||||
float currentLimit = GetCurrentMaxLength(i);
|
||||
float targetLimit = GetTargetMaxLength(i);
|
||||
|
||||
string segmentInfo = $"段{i}: {actualDistance:F2} (限制: {currentLimit:F2}";
|
||||
if (line.IsSegmentTransitioning(i))
|
||||
segmentInfo += $" -> {targetLimit:F2}";
|
||||
|
||||
segmentInfo += ")";
|
||||
|
||||
if (actualDistance > targetLimit * 1.1f)
|
||||
{
|
||||
GUI.color = Color.red;
|
||||
}
|
||||
else if (line.IsSegmentTransitioning(i))
|
||||
{
|
||||
GUI.color = Color.yellow;
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.color = Color.green;
|
||||
}
|
||||
|
||||
GUILayout.Label(segmentInfo);
|
||||
}
|
||||
|
||||
GUI.color = Color.white;
|
||||
|
||||
bool anyTransitioning = false;
|
||||
for (int i = 0; i < GetSegmentCount(); i++)
|
||||
{
|
||||
if (line.IsSegmentTransitioning(i))
|
||||
{
|
||||
anyTransitioning = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (anyTransitioning)
|
||||
GUILayout.Label("状态: 过渡中...");
|
||||
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2c33030c494448488a01acae5f2ba54
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72431056211140f1bdbf95503df5f198
|
||||
timeCreated: 1777005389
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ff7196c0f1441d4807ea7be8f921eb6
|
||||
timeCreated: 1777011145
|
||||
@@ -0,0 +1,17 @@
|
||||
using NBF;
|
||||
using UnityEngine;
|
||||
|
||||
public class SimpleWaterSurfaceProvider : MonoBehaviour, IWaterSurfaceProvider
|
||||
{
|
||||
public float waterLevel = 0f;
|
||||
|
||||
public float GetWaterHeight(Vector3 worldPos)
|
||||
{
|
||||
return waterLevel;
|
||||
}
|
||||
|
||||
public Vector3 GetWaterNormal(Vector3 worldPos)
|
||||
{
|
||||
return Vector3.up;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93df890e998f472382e1234d4cee6cf5
|
||||
timeCreated: 1774185306
|
||||
@@ -20,7 +20,7 @@ namespace NBF
|
||||
|
||||
|
||||
public bool isPinched { get; private set; }
|
||||
|
||||
|
||||
private bool moveToTargetDone;
|
||||
private float _speed;
|
||||
|
||||
@@ -44,11 +44,6 @@ namespace NBF
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
// SyncPosition();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
SyncPosition();
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace NBF
|
||||
|
||||
public struct ThrowAnimationRequest
|
||||
{
|
||||
public LureController Lure;
|
||||
public FLineLogicNode Lure;
|
||||
public Vector3 ThrowOriginPosition;
|
||||
public Vector3 StartPosition;
|
||||
public Vector3 Forward;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace NBF
|
||||
private float _castElapsedTime;
|
||||
private Vector3 _castStartPos;
|
||||
private Vector3 _castTargetPos;
|
||||
private LureController _castingLure;
|
||||
private FLineLogicNode _castingLure;
|
||||
|
||||
public bool IsPlaying => _castingLure != null;
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace NBF
|
||||
_chargedProgress = Mathf.Clamp01(request.ChargedProgress);
|
||||
_castElapsedTime = 0f;
|
||||
|
||||
var lureBody = request.Lure.RBody;
|
||||
var lureBody = request.Lure.Rigidbody;
|
||||
_castStartPos = request.StartPosition;
|
||||
|
||||
Vector3 forward = GetHorizontalForward(request.Forward);
|
||||
@@ -81,7 +81,7 @@ namespace NBF
|
||||
return;
|
||||
}
|
||||
|
||||
var lureBody = _castingLure.RBody;
|
||||
var lureBody = _castingLure.Rigidbody;
|
||||
if (snapToTarget)
|
||||
{
|
||||
_castingLure.transform.position = _castTargetPos;
|
||||
@@ -150,4 +150,4 @@ namespace NBF
|
||||
return position;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,9 +101,11 @@ namespace NBF
|
||||
var handItemView = Player.HandItem.GetComponent<PlayerItemView>();
|
||||
if (handItemView != null && handItemView.Rod != null)
|
||||
{
|
||||
if (handItemView.Rod.Line.PinchController != null)
|
||||
var endNode = handItemView.Rod.Line.GetNode(FLineLogicNodeType.End);
|
||||
var pinch = endNode.gameObject.GetComponent<JointPinchController>();
|
||||
if (pinch != null)
|
||||
{
|
||||
handItemView.Rod.Line.PinchController.StartPinch(view.Unity.ModelAsset.Pinch);
|
||||
pinch.StartPinch(view.Unity.ModelAsset.Pinch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,9 +120,12 @@ namespace NBF
|
||||
var handItemView = Player.HandItem.GetComponent<PlayerItemView>();
|
||||
if (handItemView != null && handItemView.Rod != null)
|
||||
{
|
||||
if (handItemView.Rod.Line.PinchController != null)
|
||||
var endNode = handItemView.Rod.Line.GetNode(FLineLogicNodeType.End);
|
||||
var pinch = endNode.gameObject.GetComponent<JointPinchController>();
|
||||
if (pinch != null)
|
||||
{
|
||||
handItemView.Rod.Line.PinchController.ReleasePinch();
|
||||
pinch.ReleasePinch();
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,18 +61,19 @@ namespace NBF
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.StartThrow = false;
|
||||
|
||||
var rod = GetRod();
|
||||
if (rod == null || rod.Line == null || rod.Line.Lure == null)
|
||||
if (rod == null || rod.Line == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var endNode = rod.Line.GetNode(FLineLogicNodeType.End);
|
||||
_throwAnimation = CreateThrowAnimation(rod);
|
||||
_throwAnimation.Player = Player;
|
||||
_throwAnimation?.Play(new ThrowAnimationRequest
|
||||
{
|
||||
Lure = rod.Line.Lure,
|
||||
Lure = endNode,
|
||||
ThrowOriginPosition = PlayerView.Unity.transform.position,
|
||||
StartPosition = rod.Line.Lure.RBody.position,
|
||||
StartPosition = endNode.Rigidbody.position,
|
||||
Forward = PlayerView.Unity.transform.forward,
|
||||
ChargedProgress = ChargedProgress
|
||||
});
|
||||
@@ -108,4 +109,4 @@ namespace NBF
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,8 @@ namespace NBF
|
||||
protected override void OnInit()
|
||||
{
|
||||
// transform.position = Rod.lineHandler.LineConnector_1.transform.position;
|
||||
SetParent(Rod.Line.Bobber.transform);
|
||||
var endNode = Rod.Line.GetNode(FLineLogicNodeType.Bobber);
|
||||
SetParent(endNode.transform);
|
||||
transform.localPosition = Vector3.zero;
|
||||
// var buoyancy = GetComponentInParent<CapsuleBuoyancyStable>();
|
||||
// buoyancy.InitBobber();
|
||||
|
||||
@@ -10,18 +10,17 @@ namespace NBF
|
||||
{
|
||||
hookAsset = GetComponent<HookAsset>();
|
||||
}
|
||||
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
// transform.position = Rod.lineHandler.LineConnector_2.transform.position;
|
||||
// transform.rotation = Rod.lineHandler.LineConnector_2.transform.rotation; // 确保旋转也同步
|
||||
// SetParent(Rod.lineHandler.LineConnector_2.transform);
|
||||
|
||||
|
||||
SetParent(Rod.Line.Lure.transform);
|
||||
|
||||
var endNode = Rod.Line.GetNode(FLineLogicNodeType.End);
|
||||
SetParent(endNode.transform);
|
||||
transform.localPosition = Vector3.zero;
|
||||
|
||||
|
||||
// var target = lineHandler.LineConnector_2.GetComponent<Rigidbody>();
|
||||
// var joint = Hook.gameObject.GetComponent<ConfigurableJoint>();
|
||||
// joint.connectedBody = target;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0403ffd74ce46fab8bd4ef057e51432
|
||||
timeCreated: 1766582567
|
||||
guid: c7095cf554c345839173044e4786b0ba
|
||||
timeCreated: 1776948821
|
||||
@@ -13,8 +13,8 @@ namespace NBF
|
||||
// LureHookWaterDisplacement = Lure.GetComponent<FWaterDisplacement>();
|
||||
|
||||
// SetParent(Rod.lineHandler.LineConnector_1.transform);
|
||||
|
||||
SetParent(Rod.Line.Lure.transform);
|
||||
var endNode = Rod.Line.GetNode(FLineLogicNodeType.End);
|
||||
SetParent(endNode.transform);
|
||||
transform.localPosition = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,24 +72,14 @@ namespace NBF
|
||||
if (Line.LineType == LineType.Spinning)
|
||||
{
|
||||
//没有浮漂类型
|
||||
Line.Lure.SetJointDistance(PlayerItem.LineLength);
|
||||
if (PlayerItem.StretchRope)
|
||||
{
|
||||
// Line.SetTargetLength(PlayerItem.Tension > 0f ? 0f : PlayerItem.LineLength);
|
||||
Line.SetTargetLength(PlayerItem.LineLength);
|
||||
}
|
||||
Line.SetLenght(PlayerItem.LineLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
//有浮漂
|
||||
Line.Lure.SetJointDistance(PlayerItem.FloatLength);
|
||||
Line.Bobber.SetJointDistance(PlayerItem.LineLength - PlayerItem.FloatLength);
|
||||
if (PlayerItem.StretchRope)
|
||||
{
|
||||
// Line.SetTargetLength(PlayerItem.Tension > 0f ? 0f : PlayerItem.LineLength - PlayerItem.FloatLength);
|
||||
Line.SetTargetLength(PlayerItem.LineLength - PlayerItem.FloatLength);
|
||||
Line.SetLureLength(PlayerItem.FloatLength);
|
||||
}
|
||||
Line.SetSegmentMaxLength(0, PlayerItem.LineLength - PlayerItem.FloatLength);
|
||||
//浮漂位置
|
||||
Line.SetSegmentMaxLength(1, PlayerItem.FloatLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,12 +328,12 @@ namespace NBF
|
||||
|
||||
var state = PlayerItem.Owner.State;
|
||||
|
||||
|
||||
Vector3 vector = Line.Lure.transform.position;
|
||||
var endNode = Line.GetNode(FLineLogicNodeType.End);
|
||||
Vector3 vector = endNode.transform.position;
|
||||
|
||||
// 当前物体的朝向与指向 Lure 的方向之间的夹角,在 0(完全对齐)到 1(完全相反)之间的一个比例值
|
||||
float headingAlignment = Vector3.Angle(base.transform.forward,
|
||||
(Line.Lure.transform.position - transform.position).normalized) / 180f;
|
||||
(endNode.transform.position - transform.position).normalized) / 180f;
|
||||
// 经过朝向调制后的有效张力
|
||||
var effectiveTension = Mathf.Clamp(CurrentTension01 * headingAlignment, 0f, 1f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user