修改鱼线相关逻辑
This commit is contained in:
@@ -42,7 +42,7 @@ Rigidbody:
|
|||||||
m_GameObject: {fileID: 2696931885206049402}
|
m_GameObject: {fileID: 2696931885206049402}
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
m_Mass: 1
|
m_Mass: 1
|
||||||
m_LinearDamping: 0
|
m_LinearDamping: 1
|
||||||
m_AngularDamping: 0.05
|
m_AngularDamping: 0.05
|
||||||
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
||||||
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
||||||
@@ -238,7 +238,7 @@ Rigidbody:
|
|||||||
m_GameObject: {fileID: 5252216124238432432}
|
m_GameObject: {fileID: 5252216124238432432}
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
m_Mass: 1
|
m_Mass: 1
|
||||||
m_LinearDamping: 0
|
m_LinearDamping: 1
|
||||||
m_AngularDamping: 0.05
|
m_AngularDamping: 0.05
|
||||||
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
||||||
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
||||||
@@ -407,6 +407,8 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: dcd0fd8d96f994444b2d8663af6b915d, type: 3}
|
m_Script: {fileID: 11500000, guid: dcd0fd8d96f994444b2d8663af6b915d, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::NBF.FishingLineSolver
|
m_EditorClassIdentifier: Assembly-CSharp::NBF.FishingLineSolver
|
||||||
|
ConfigId: 0
|
||||||
|
LineType: 0
|
||||||
anchorTransform: {fileID: 0}
|
anchorTransform: {fileID: 0}
|
||||||
logicalNodes:
|
logicalNodes:
|
||||||
- {fileID: 5572865435543895569}
|
- {fileID: 5572865435543895569}
|
||||||
@@ -482,7 +484,7 @@ LineRenderer:
|
|||||||
m_Curve:
|
m_Curve:
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
time: 0
|
time: 0
|
||||||
value: 0.01
|
value: 0.002
|
||||||
inSlope: 0
|
inSlope: 0
|
||||||
outSlope: 0
|
outSlope: 0
|
||||||
tangentMode: 0
|
tangentMode: 0
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
using UnityEditor;
|
// using UnityEditor;
|
||||||
using UnityEngine;
|
// using UnityEngine;
|
||||||
|
//
|
||||||
[CustomEditor(typeof(Rope))]
|
// [CustomEditor(typeof(Rope))]
|
||||||
public class RopeFishLineEditor : Editor
|
// public class RopeFishLineEditor : Editor
|
||||||
{
|
// {
|
||||||
private Rope _target;
|
// private Rope _target;
|
||||||
|
//
|
||||||
void OnEnable()
|
// void OnEnable()
|
||||||
{
|
// {
|
||||||
_target = target as Rope;
|
// _target = target as Rope;
|
||||||
// lookAtPoint = serializedObject.FindProperty("lookAtPoint");
|
// // lookAtPoint = serializedObject.FindProperty("lookAtPoint");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public override void OnInspectorGUI()
|
// public override void OnInspectorGUI()
|
||||||
{
|
// {
|
||||||
base.OnInspectorGUI();
|
// base.OnInspectorGUI();
|
||||||
|
//
|
||||||
|
//
|
||||||
if (GUILayout.Button("打印总长度"))
|
// if (GUILayout.Button("打印总长度"))
|
||||||
{
|
// {
|
||||||
_target.DebugLength();
|
// _target.DebugLength();
|
||||||
// Debug.Log($"总长度={_target.GetCurrentLength()} 目标长度={_target.GetTargetLength()} smoot={_target.GetLengthSmoothVel()} relLen={_target.GetLengthByPoints()} PolylineLength={_target.GetPhysicsPolylineLength()}");
|
// // Debug.Log($"总长度={_target.GetCurrentLength()} 目标长度={_target.GetTargetLength()} smoot={_target.GetLengthSmoothVel()} relLen={_target.GetLengthByPoints()} PolylineLength={_target.GetPhysicsPolylineLength()}");
|
||||||
}
|
// }
|
||||||
// serializedObject.Update();
|
// // serializedObject.Update();
|
||||||
// EditorGUILayout.PropertyField(lookAtPoint);
|
// // EditorGUILayout.PropertyField(lookAtPoint);
|
||||||
// serializedObject.ApplyModifiedProperties();
|
// // serializedObject.ApplyModifiedProperties();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
@@ -1,59 +1,59 @@
|
|||||||
using System;
|
// using System;
|
||||||
using UnityEngine;
|
// using UnityEngine;
|
||||||
|
//
|
||||||
namespace NBF
|
// namespace NBF
|
||||||
{
|
// {
|
||||||
public class LureController : MonoBehaviour
|
// public class LureController : MonoBehaviour
|
||||||
{
|
// {
|
||||||
[SerializeField] private Rigidbody rBody;
|
// [SerializeField] private Rigidbody rBody;
|
||||||
[SerializeField] private ConfigurableJoint joint;
|
// [SerializeField] private ConfigurableJoint joint;
|
||||||
public Rigidbody RBody => rBody;
|
// public Rigidbody RBody => rBody;
|
||||||
|
//
|
||||||
public ConfigurableJoint Joint => joint;
|
// public ConfigurableJoint Joint => joint;
|
||||||
|
//
|
||||||
private void Start()
|
// private void Start()
|
||||||
{
|
// {
|
||||||
RBody.detectCollisions = true;
|
// RBody.detectCollisions = true;
|
||||||
RBody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
|
// RBody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
|
||||||
RBody.interpolation = RigidbodyInterpolation.Interpolate;
|
// RBody.interpolation = RigidbodyInterpolation.Interpolate;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void SetJoint(Rigidbody rb)
|
// public void SetJoint(Rigidbody rb)
|
||||||
{
|
// {
|
||||||
joint.connectedBody = rb;
|
// joint.connectedBody = rb;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
public void EnableCollision(bool enable)
|
// public void EnableCollision(bool enable)
|
||||||
{
|
// {
|
||||||
if (rBody == null)
|
// if (rBody == null)
|
||||||
{
|
// {
|
||||||
rBody = GetComponent<Rigidbody>();
|
// rBody = GetComponent<Rigidbody>();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// rBody.detectCollisions = enable;
|
// // rBody.detectCollisions = enable;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void SetKinematic(bool value)
|
// public void SetKinematic(bool value)
|
||||||
{
|
// {
|
||||||
rBody.isKinematic = value;
|
// rBody.isKinematic = value;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void SetJointDistance(float limit)
|
// public void SetJointDistance(float limit)
|
||||||
{
|
// {
|
||||||
joint.linearLimit = new SoftJointLimit
|
// joint.linearLimit = new SoftJointLimit
|
||||||
{
|
// {
|
||||||
limit = limit
|
// limit = limit
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void OnCollisionEnter(Collision other)
|
// private void OnCollisionEnter(Collision other)
|
||||||
{
|
// {
|
||||||
Debug.Log($"OnCollisionEnter:{other.gameObject.name}");
|
// Debug.Log($"OnCollisionEnter:{other.gameObject.name}");
|
||||||
}
|
// }
|
||||||
private void OnCollisionExit(Collision other)
|
// private void OnCollisionExit(Collision other)
|
||||||
{
|
// {
|
||||||
Debug.Log($"OnCollisionExit:{other.gameObject.name}");
|
// Debug.Log($"OnCollisionExit:{other.gameObject.name}");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
@@ -18,7 +18,7 @@ namespace NBF
|
|||||||
private FishingLineSolver _solver;
|
private FishingLineSolver _solver;
|
||||||
|
|
||||||
[Header("Node")] [SerializeField] private NodeType nodeType = NodeType.Tail;
|
[Header("Node")] [SerializeField] private NodeType nodeType = NodeType.Tail;
|
||||||
[SerializeField] private Rigidbody body;
|
[SerializeField] public Rigidbody body;
|
||||||
[SerializeField] private MonoBehaviour interaction;
|
[SerializeField] private MonoBehaviour interaction;
|
||||||
|
|
||||||
[Header("Segment To Next Logical Node")] [Min(0f)] [SerializeField]
|
[Header("Segment To Next Logical Node")] [Min(0f)] [SerializeField]
|
||||||
|
|||||||
@@ -5,7 +5,15 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace NBF
|
namespace NBF
|
||||||
{
|
{
|
||||||
public class FishingLineSolver : MonoBehaviour
|
public enum LineType
|
||||||
|
{
|
||||||
|
Hand,
|
||||||
|
HandDouble,
|
||||||
|
Spinning,
|
||||||
|
SpinningFloat,
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FishingLineSolver : FGearBase
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class ChainPoint
|
public sealed class ChainPoint
|
||||||
@@ -36,6 +44,9 @@ namespace NBF
|
|||||||
public int VirtualNodeCount => Mathf.Max(0, GapLengths.Length - 1);
|
public int VirtualNodeCount => Mathf.Max(0, GapLengths.Length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[SerializeField] public LineType LineType;
|
||||||
|
|
||||||
[Header("References")] [SerializeField]
|
[Header("References")] [SerializeField]
|
||||||
private Transform anchorTransform;
|
private Transform anchorTransform;
|
||||||
|
|
||||||
@@ -202,6 +213,12 @@ namespace NBF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnInit()
|
||||||
|
{
|
||||||
|
var tipRb = Rod.Asset.LineConnectorRigidbody;
|
||||||
|
anchorTransform = tipRb.transform;
|
||||||
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
if (autoBuildOnStart)
|
if (autoBuildOnStart)
|
||||||
@@ -312,28 +329,46 @@ namespace NBF
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取指定顺序索引的逻辑节点。
|
/// 根据类型获取逻辑节点类型
|
||||||
/// 索引基于 logicalNodes 配置顺序;超出范围或节点为空时返回 null。
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FishingLineNode GetLogicalNode(int logicalIndex)
|
/// <param name="nodeType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public FishingLineNode GetLogicalNode(FishingLineNode.NodeType nodeType)
|
||||||
{
|
{
|
||||||
if (logicalNodes == null || logicalIndex < 0 || logicalIndex >= logicalNodes.Length)
|
foreach (var fishingLineNode in logicalNodes)
|
||||||
{
|
{
|
||||||
return null;
|
if (fishingLineNode.Type == nodeType)
|
||||||
|
{
|
||||||
|
return fishingLineNode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return logicalNodes[logicalIndex];
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 尝试获取指定顺序索引的逻辑节点。
|
// /// 获取指定顺序索引的逻辑节点。
|
||||||
/// 获取失败时返回 false,并将 node 置为 null。
|
// /// 索引基于 logicalNodes 配置顺序;超出范围或节点为空时返回 null。
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public bool TryGetLogicalNode(int logicalIndex, out FishingLineNode node)
|
// public FishingLineNode GetLogicalNode(int logicalIndex)
|
||||||
{
|
// {
|
||||||
node = GetLogicalNode(logicalIndex);
|
// if (logicalNodes == null || logicalIndex < 0 || logicalIndex >= logicalNodes.Length)
|
||||||
return node != null;
|
// {
|
||||||
}
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return logicalNodes[logicalIndex];
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /// <summary>
|
||||||
|
// /// 尝试获取指定顺序索引的逻辑节点。
|
||||||
|
// /// 获取失败时返回 false,并将 node 置为 null。
|
||||||
|
// /// </summary>
|
||||||
|
// public bool TryGetLogicalNode(int logicalIndex, out FishingLineNode node)
|
||||||
|
// {
|
||||||
|
// node = GetLogicalNode(logicalIndex);
|
||||||
|
// return node != null;
|
||||||
|
// }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取当前起点逻辑节点。
|
/// 获取当前起点逻辑节点。
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ namespace NBF
|
|||||||
|
|
||||||
public struct ThrowAnimationRequest
|
public struct ThrowAnimationRequest
|
||||||
{
|
{
|
||||||
public LureController Lure;
|
// public LureController Lure;
|
||||||
|
public FishingLineNode EndNode;
|
||||||
public Vector3 ThrowOriginPosition;
|
public Vector3 ThrowOriginPosition;
|
||||||
public Vector3 StartPosition;
|
public Vector3 StartPosition;
|
||||||
public Vector3 Forward;
|
public Vector3 Forward;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace NBF
|
|||||||
private float _castElapsedTime;
|
private float _castElapsedTime;
|
||||||
private Vector3 _castStartPos;
|
private Vector3 _castStartPos;
|
||||||
private Vector3 _castTargetPos;
|
private Vector3 _castTargetPos;
|
||||||
private LureController _castingLure;
|
private FishingLineNode _castingLure;
|
||||||
|
|
||||||
public bool IsPlaying => _castingLure != null;
|
public bool IsPlaying => _castingLure != null;
|
||||||
|
|
||||||
@@ -40,18 +40,18 @@ namespace NBF
|
|||||||
|
|
||||||
public void Play(ThrowAnimationRequest request)
|
public void Play(ThrowAnimationRequest request)
|
||||||
{
|
{
|
||||||
if (request.Lure == null)
|
if (request.EndNode == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stop(snapToTarget: false);
|
Stop(snapToTarget: false);
|
||||||
|
|
||||||
_castingLure = request.Lure;
|
_castingLure = request.EndNode;
|
||||||
_chargedProgress = Mathf.Clamp01(request.ChargedProgress);
|
_chargedProgress = Mathf.Clamp01(request.ChargedProgress);
|
||||||
_castElapsedTime = 0f;
|
_castElapsedTime = 0f;
|
||||||
|
|
||||||
var lureBody = request.Lure.RBody;
|
var lureBody = request.EndNode.body;
|
||||||
_castStartPos = request.StartPosition;
|
_castStartPos = request.StartPosition;
|
||||||
|
|
||||||
Vector3 forward = GetHorizontalForward(request.Forward);
|
Vector3 forward = GetHorizontalForward(request.Forward);
|
||||||
@@ -81,7 +81,7 @@ namespace NBF
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lureBody = _castingLure.RBody;
|
var lureBody = _castingLure.body;
|
||||||
if (snapToTarget)
|
if (snapToTarget)
|
||||||
{
|
{
|
||||||
_castingLure.transform.position = _castTargetPos;
|
_castingLure.transform.position = _castTargetPos;
|
||||||
|
|||||||
@@ -101,10 +101,10 @@ namespace NBF
|
|||||||
var handItemView = Player.HandItem.GetComponent<PlayerItemView>();
|
var handItemView = Player.HandItem.GetComponent<PlayerItemView>();
|
||||||
if (handItemView != null && handItemView.Rod != null)
|
if (handItemView != null && handItemView.Rod != null)
|
||||||
{
|
{
|
||||||
if (handItemView.Rod.Line.PinchController != null)
|
// if (handItemView.Rod.Line.PinchController != null)
|
||||||
{
|
// {
|
||||||
handItemView.Rod.Line.PinchController.StartPinch(view.Unity.ModelAsset.Pinch);
|
// handItemView.Rod.Line.PinchController.StartPinch(view.Unity.ModelAsset.Pinch);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,10 +118,10 @@ namespace NBF
|
|||||||
var handItemView = Player.HandItem.GetComponent<PlayerItemView>();
|
var handItemView = Player.HandItem.GetComponent<PlayerItemView>();
|
||||||
if (handItemView != null && handItemView.Rod != null)
|
if (handItemView != null && handItemView.Rod != null)
|
||||||
{
|
{
|
||||||
if (handItemView.Rod.Line.PinchController != null)
|
// if (handItemView.Rod.Line.PinchController != null)
|
||||||
{
|
// {
|
||||||
handItemView.Rod.Line.PinchController.ReleasePinch();
|
// handItemView.Rod.Line.PinchController.ReleasePinch();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,12 @@ namespace NBF
|
|||||||
PlayerView.Unity.ModelAsset.PlayerAnimator.StartThrow = false;
|
PlayerView.Unity.ModelAsset.PlayerAnimator.StartThrow = false;
|
||||||
|
|
||||||
var rod = GetRod();
|
var rod = GetRod();
|
||||||
if (rod == null || rod.Line == null || rod.Line.Lure == null)
|
if (rod == null || rod.Line == null )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var endNode = rod.Line.GetEndNode();
|
||||||
|
if (endNode == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -70,9 +75,9 @@ namespace NBF
|
|||||||
_throwAnimation.Player = Player;
|
_throwAnimation.Player = Player;
|
||||||
_throwAnimation?.Play(new ThrowAnimationRequest
|
_throwAnimation?.Play(new ThrowAnimationRequest
|
||||||
{
|
{
|
||||||
Lure = rod.Line.Lure,
|
EndNode = endNode,
|
||||||
ThrowOriginPosition = PlayerView.Unity.transform.position,
|
ThrowOriginPosition = PlayerView.Unity.transform.position,
|
||||||
StartPosition = rod.Line.Lure.RBody.position,
|
StartPosition = endNode.body.position,
|
||||||
Forward = PlayerView.Unity.transform.forward,
|
Forward = PlayerView.Unity.transform.forward,
|
||||||
ChargedProgress = ChargedProgress
|
ChargedProgress = ChargedProgress
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ namespace NBF
|
|||||||
protected override void OnInit()
|
protected override void OnInit()
|
||||||
{
|
{
|
||||||
// transform.position = Rod.lineHandler.LineConnector_1.transform.position;
|
// transform.position = Rod.lineHandler.LineConnector_1.transform.position;
|
||||||
SetParent(Rod.Line.Bobber.transform);
|
|
||||||
|
var node = Rod.Line.GetLogicalNode(FishingLineNode.NodeType.Float);
|
||||||
|
SetParent(node.transform);
|
||||||
transform.localPosition = Vector3.zero;
|
transform.localPosition = Vector3.zero;
|
||||||
// var buoyancy = GetComponentInParent<CapsuleBuoyancyStable>();
|
// var buoyancy = GetComponentInParent<CapsuleBuoyancyStable>();
|
||||||
// buoyancy.InitBobber();
|
// buoyancy.InitBobber();
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ namespace NBF
|
|||||||
// transform.rotation = Rod.lineHandler.LineConnector_2.transform.rotation; // 确保旋转也同步
|
// transform.rotation = Rod.lineHandler.LineConnector_2.transform.rotation; // 确保旋转也同步
|
||||||
// SetParent(Rod.lineHandler.LineConnector_2.transform);
|
// SetParent(Rod.lineHandler.LineConnector_2.transform);
|
||||||
|
|
||||||
|
var node = Rod.Line.GetLogicalNode(FishingLineNode.NodeType.Tail);
|
||||||
|
SetParent(node.transform);
|
||||||
|
|
||||||
SetParent(Rod.Line.Lure.transform);
|
// SetParent(Rod.Line.Lure.transform);
|
||||||
transform.localPosition = Vector3.zero;
|
transform.localPosition = Vector3.zero;
|
||||||
|
|
||||||
// var target = lineHandler.LineConnector_2.GetComponent<Rigidbody>();
|
// var target = lineHandler.LineConnector_2.GetComponent<Rigidbody>();
|
||||||
|
|||||||
@@ -1,173 +1,173 @@
|
|||||||
using System;
|
// using System;
|
||||||
using System.Collections;
|
// using System.Collections;
|
||||||
using System.Collections.Generic;
|
// using System.Collections.Generic;
|
||||||
using System.Linq;
|
// using System.Linq;
|
||||||
using NBC;
|
// using NBC;
|
||||||
// using Obi;
|
// // using Obi;
|
||||||
using UnityEngine;
|
// using UnityEngine;
|
||||||
|
//
|
||||||
namespace NBF
|
// namespace NBF
|
||||||
{
|
// {
|
||||||
public enum LineType
|
// public enum LineType
|
||||||
{
|
// {
|
||||||
Hand,
|
// Hand,
|
||||||
HandDouble,
|
// HandDouble,
|
||||||
Spinning,
|
// Spinning,
|
||||||
SpinningFloat,
|
// SpinningFloat,
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public class FLine : FGearBase
|
// public class FLine : FGearBase
|
||||||
{
|
// {
|
||||||
public LineType LineType;
|
// public LineType LineType;
|
||||||
|
//
|
||||||
[SerializeField] private bool isLureConnect;
|
// [SerializeField] private bool isLureConnect;
|
||||||
[SerializeField] private RodLine rodLine;
|
// [SerializeField] private RodLine rodLine;
|
||||||
|
//
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 主线
|
// /// 主线
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
[SerializeField] private Rope fishingRope;
|
// [SerializeField] private Rope fishingRope;
|
||||||
|
//
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 浮漂和鱼钩线
|
// /// 浮漂和鱼钩线
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
[SerializeField] private Rope bobberRope;
|
// [SerializeField] private Rope bobberRope;
|
||||||
|
//
|
||||||
public LureController Lure;
|
// public LureController Lure;
|
||||||
public BobberController Bobber;
|
// public BobberController Bobber;
|
||||||
|
//
|
||||||
public JointPinchController PinchController;
|
// public JointPinchController PinchController;
|
||||||
|
//
|
||||||
|
//
|
||||||
public float LinelenghtDiferent;
|
// public float LinelenghtDiferent;
|
||||||
|
//
|
||||||
protected override void OnInit()
|
// protected override void OnInit()
|
||||||
{
|
// {
|
||||||
var tipRb = Rod.Asset.LineConnectorRigidbody;
|
// var tipRb = Rod.Asset.LineConnectorRigidbody;
|
||||||
if (isLureConnect)
|
// if (isLureConnect)
|
||||||
{
|
// {
|
||||||
Lure.SetJoint(tipRb);
|
// Lure.SetJoint(tipRb);
|
||||||
Lure.EnableCollision(false);
|
// Lure.EnableCollision(false);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
fishingRope.startAnchor = tipRb;
|
// fishingRope.startAnchor = tipRb;
|
||||||
Bobber.SetJoint(tipRb);
|
// Bobber.SetJoint(tipRb);
|
||||||
Lure.SetJoint(Bobber.rbody);
|
// Lure.SetJoint(Bobber.rbody);
|
||||||
Lure.gameObject.SetActive(true);
|
// Lure.gameObject.SetActive(true);
|
||||||
Lure.EnableCollision(false);
|
// Lure.EnableCollision(false);
|
||||||
Lure.SetKinematic(false);
|
// Lure.SetKinematic(false);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
GetComponentsInChildren<Transform>(includeInactive: true).ToList().ForEach(delegate(Transform i)
|
// GetComponentsInChildren<Transform>(includeInactive: true).ToList().ForEach(delegate(Transform i)
|
||||||
{
|
// {
|
||||||
i.gameObject.SetActive(true);
|
// i.gameObject.SetActive(true);
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
StartCoroutine(LureUseGravity());
|
// StartCoroutine(LureUseGravity());
|
||||||
if (isLureConnect)
|
// if (isLureConnect)
|
||||||
{
|
// {
|
||||||
fishingRope.Init(Rod);
|
// fishingRope.Init(Rod);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
fishingRope.Init(Rod);
|
// fishingRope.Init(Rod);
|
||||||
bobberRope.Init(Rod);
|
// bobberRope.Init(Rod);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// rodLine.GenerateLineRendererRope(guides.ToArray(), _LineThickness);
|
// // rodLine.GenerateLineRendererRope(guides.ToArray(), _LineThickness);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void InitTest(Rigidbody tipRb)
|
// public void InitTest(Rigidbody tipRb)
|
||||||
{
|
// {
|
||||||
if (isLureConnect)
|
// if (isLureConnect)
|
||||||
{
|
// {
|
||||||
Lure.SetJoint(tipRb);
|
// Lure.SetJoint(tipRb);
|
||||||
Lure.EnableCollision(false);
|
// Lure.EnableCollision(false);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
fishingRope.startAnchor = tipRb;
|
// fishingRope.startAnchor = tipRb;
|
||||||
Bobber.SetJoint(tipRb);
|
// Bobber.SetJoint(tipRb);
|
||||||
Lure.SetJoint(Bobber.rbody);
|
// Lure.SetJoint(Bobber.rbody);
|
||||||
Lure.gameObject.SetActive(true);
|
// Lure.gameObject.SetActive(true);
|
||||||
Lure.EnableCollision(false);
|
// Lure.EnableCollision(false);
|
||||||
Lure.SetKinematic(false);
|
// Lure.SetKinematic(false);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
GetComponentsInChildren<Transform>(includeInactive: true).ToList().ForEach(delegate(Transform i)
|
// GetComponentsInChildren<Transform>(includeInactive: true).ToList().ForEach(delegate(Transform i)
|
||||||
{
|
// {
|
||||||
i.gameObject.SetActive(true);
|
// i.gameObject.SetActive(true);
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
StartCoroutine(LureUseGravity());
|
// StartCoroutine(LureUseGravity());
|
||||||
if (isLureConnect)
|
// if (isLureConnect)
|
||||||
{
|
// {
|
||||||
fishingRope.Init(Rod);
|
// fishingRope.Init(Rod);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
fishingRope.Init(Rod);
|
// fishingRope.Init(Rod);
|
||||||
bobberRope.Init(Rod);
|
// bobberRope.Init(Rod);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private IEnumerator LureUseGravity()
|
// private IEnumerator LureUseGravity()
|
||||||
{
|
// {
|
||||||
yield return 1;
|
// yield return 1;
|
||||||
Lure.gameObject.SetActive(false);
|
// Lure.gameObject.SetActive(false);
|
||||||
Lure.gameObject.SetActive(true);
|
// Lure.gameObject.SetActive(true);
|
||||||
yield return 1;
|
// yield return 1;
|
||||||
Lure.RBody.useGravity = true;
|
// Lure.RBody.useGravity = true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void SetTargetLength(float value)
|
// public void SetTargetLength(float value)
|
||||||
{
|
// {
|
||||||
Log.Error($"SetObiRopeStretch={value}");
|
// Log.Error($"SetObiRopeStretch={value}");
|
||||||
if (value > 3)
|
// if (value > 3)
|
||||||
{
|
// {
|
||||||
// value -= 0.2f;
|
// // value -= 0.2f;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
fishingRope.SetTargetLength(value);
|
// fishingRope.SetTargetLength(value);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void SetLureLength(float value)
|
// public void SetLureLength(float value)
|
||||||
{
|
// {
|
||||||
Log.Error($"SetObiRopeStretch={value}");
|
// Log.Error($"SetObiRopeStretch={value}");
|
||||||
bobberRope.SetTargetLength(value);
|
// bobberRope.SetTargetLength(value);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
private void Update()
|
// private void Update()
|
||||||
{
|
// {
|
||||||
LinelenghtDiferent = GetLineDistance();
|
// LinelenghtDiferent = GetLineDistance();
|
||||||
|
//
|
||||||
//非钓鱼状态
|
// //非钓鱼状态
|
||||||
Rod.PlayerItem.Tension = Mathf.Clamp(LinelenghtDiferent, 0f, 0.05f);
|
// Rod.PlayerItem.Tension = Mathf.Clamp(LinelenghtDiferent, 0f, 0.05f);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
#region Tension
|
// #region Tension
|
||||||
|
//
|
||||||
private float GetLineDistance()
|
// private float GetLineDistance()
|
||||||
{
|
// {
|
||||||
if (!Bobber.JointRb)
|
// if (!Bobber.JointRb)
|
||||||
{
|
// {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// return 0;
|
// // return 0;
|
||||||
|
//
|
||||||
//第一个节点到竿稍的位置-第一段鱼线长度
|
// //第一个节点到竿稍的位置-第一段鱼线长度
|
||||||
return Vector3.Distance(Bobber.transform.position, Bobber.JointRb.transform.position) -
|
// return Vector3.Distance(Bobber.transform.position, Bobber.JointRb.transform.position) -
|
||||||
fishingRope.GetCurrentLength();
|
// fishingRope.GetCurrentLength();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public float GetTension(float weight)
|
// public float GetTension(float weight)
|
||||||
{
|
// {
|
||||||
return weight * GetLineDistance();
|
// return weight * GetLineDistance();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
#endregion
|
// #endregion
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
@@ -14,7 +14,10 @@ namespace NBF
|
|||||||
|
|
||||||
// SetParent(Rod.lineHandler.LineConnector_1.transform);
|
// SetParent(Rod.lineHandler.LineConnector_1.transform);
|
||||||
|
|
||||||
SetParent(Rod.Line.Lure.transform);
|
var node = Rod.Line.GetLogicalNode(FishingLineNode.NodeType.Float);
|
||||||
|
SetParent(node.transform);
|
||||||
|
|
||||||
|
// SetParent(Rod.Line.Lure.transform);
|
||||||
transform.localPosition = Vector3.zero;
|
transform.localPosition = Vector3.zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace NBF
|
|||||||
public FBait Bait;
|
public FBait Bait;
|
||||||
public FLure Lure;
|
public FLure Lure;
|
||||||
public FWeight Weight;
|
public FWeight Weight;
|
||||||
public FLine Line;
|
public FishingLineSolver Line;
|
||||||
|
|
||||||
|
|
||||||
public Transform GearRoot;
|
public Transform GearRoot;
|
||||||
@@ -72,24 +72,29 @@ namespace NBF
|
|||||||
if (Line.LineType == LineType.Spinning)
|
if (Line.LineType == LineType.Spinning)
|
||||||
{
|
{
|
||||||
//没有浮漂类型
|
//没有浮漂类型
|
||||||
Line.Lure.SetJointDistance(PlayerItem.LineLength);
|
// Line.Lure.SetJointDistance(PlayerItem.LineLength);
|
||||||
if (PlayerItem.StretchRope)
|
// if (PlayerItem.StretchRope)
|
||||||
{
|
// {
|
||||||
// Line.SetTargetLength(PlayerItem.Tension > 0f ? 0f : PlayerItem.LineLength);
|
// // Line.SetTargetLength(PlayerItem.Tension > 0f ? 0f : PlayerItem.LineLength);
|
||||||
Line.SetTargetLength(PlayerItem.LineLength);
|
// Line.SetTargetLength(PlayerItem.LineLength);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
Line.SetLenght(PlayerItem.LineLength);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//有浮漂
|
//有浮漂
|
||||||
Line.Lure.SetJointDistance(PlayerItem.FloatLength);
|
// Line.Lure.SetJointDistance(PlayerItem.FloatLength);
|
||||||
Line.Bobber.SetJointDistance(PlayerItem.LineLength - PlayerItem.FloatLength);
|
// Line.Bobber.SetJointDistance(PlayerItem.LineLength - PlayerItem.FloatLength);
|
||||||
if (PlayerItem.StretchRope)
|
// if (PlayerItem.StretchRope)
|
||||||
{
|
// {
|
||||||
// Line.SetTargetLength(PlayerItem.Tension > 0f ? 0f : PlayerItem.LineLength - PlayerItem.FloatLength);
|
// // Line.SetTargetLength(PlayerItem.Tension > 0f ? 0f : PlayerItem.LineLength - PlayerItem.FloatLength);
|
||||||
Line.SetTargetLength(PlayerItem.LineLength - PlayerItem.FloatLength);
|
// Line.SetTargetLength(PlayerItem.LineLength - PlayerItem.FloatLength);
|
||||||
Line.SetLureLength(PlayerItem.FloatLength);
|
// Line.SetLureLength(PlayerItem.FloatLength);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
Line.SetLenght(PlayerItem.LineLength - PlayerItem.FloatLength);
|
||||||
|
Line.SetLenght(PlayerItem.FloatLength, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +256,7 @@ namespace NBF
|
|||||||
var solver = Instantiate(lineSolverPrefab, GearRoot);
|
var solver = Instantiate(lineSolverPrefab, GearRoot);
|
||||||
solver.transform.position = Asset.lineConnector.position;
|
solver.transform.position = Asset.lineConnector.position;
|
||||||
solver.transform.rotation = Asset.lineConnector.rotation;
|
solver.transform.rotation = Asset.lineConnector.rotation;
|
||||||
var indexNames = new[] { "fishing line float set", "fishing line spinning" };
|
var indexNames = new[] { "FishingLine1", "FishingLine1" };
|
||||||
var path =
|
var path =
|
||||||
$"Assets/ResRaw/Prefabs/Line/{indexNames[currentLineTypeIndex]}.prefab";
|
$"Assets/ResRaw/Prefabs/Line/{indexNames[currentLineTypeIndex]}.prefab";
|
||||||
var prefab = Assets.Load<GameObject>(path);
|
var prefab = Assets.Load<GameObject>(path);
|
||||||
@@ -261,7 +266,7 @@ namespace NBF
|
|||||||
obj.transform.localScale = Vector3.one;
|
obj.transform.localScale = Vector3.one;
|
||||||
obj.transform.rotation = Quaternion.identity;
|
obj.transform.rotation = Quaternion.identity;
|
||||||
|
|
||||||
Line = obj.GetComponent<FLine>();
|
Line = obj.GetComponent<FishingLineSolver>();
|
||||||
Line.transform.position = Asset.lineConnector.position;
|
Line.transform.position = Asset.lineConnector.position;
|
||||||
Line.Init(this);
|
Line.Init(this);
|
||||||
}
|
}
|
||||||
@@ -339,11 +344,13 @@ namespace NBF
|
|||||||
var state = PlayerItem.Owner.State;
|
var state = PlayerItem.Owner.State;
|
||||||
|
|
||||||
|
|
||||||
Vector3 vector = Line.Lure.transform.position;
|
var endNode = Line.GetEndNode();
|
||||||
|
|
||||||
|
Vector3 vector = endNode.transform.position;
|
||||||
|
|
||||||
// 当前物体的朝向与指向 Lure 的方向之间的夹角,在 0(完全对齐)到 1(完全相反)之间的一个比例值
|
// 当前物体的朝向与指向 Lure 的方向之间的夹角,在 0(完全对齐)到 1(完全相反)之间的一个比例值
|
||||||
float headingAlignment = Vector3.Angle(base.transform.forward,
|
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);
|
var effectiveTension = Mathf.Clamp(CurrentTension01 * headingAlignment, 0f, 1f);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user