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