提交修改
This commit is contained in:
@@ -325,6 +325,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier: Assembly-CSharp::NBF.FLineLogicNode
|
m_EditorClassIdentifier: Assembly-CSharp::NBF.FLineLogicNode
|
||||||
NodeType: 3
|
NodeType: 3
|
||||||
rope: {fileID: 114504105083509877}
|
rope: {fileID: 114504105083509877}
|
||||||
|
preRigidbody: {fileID: 54298866000586118}
|
||||||
--- !u!114 &6377942246174119720
|
--- !u!114 &6377942246174119720
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -394,10 +395,6 @@ MonoBehaviour:
|
|||||||
- {fileID: 3463242999848273700}
|
- {fileID: 3463242999848273700}
|
||||||
- {fileID: 8491405271793597799}
|
- {fileID: 8491405271793597799}
|
||||||
- {fileID: 2305106969988397276}
|
- {fileID: 2305106969988397276}
|
||||||
isLureConnect: 0
|
|
||||||
rodLine: {fileID: 0}
|
|
||||||
fishingRope: {fileID: 114581403422500557}
|
|
||||||
bobberRope: {fileID: 114504105083509877}
|
|
||||||
LinelenghtDiferent: 0
|
LinelenghtDiferent: 0
|
||||||
--- !u!1 &1858052053854210
|
--- !u!1 &1858052053854210
|
||||||
GameObject:
|
GameObject:
|
||||||
@@ -498,6 +495,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier: Assembly-CSharp::NBF.FLineLogicNode
|
m_EditorClassIdentifier: Assembly-CSharp::NBF.FLineLogicNode
|
||||||
NodeType: 1
|
NodeType: 1
|
||||||
rope: {fileID: 114581403422500557}
|
rope: {fileID: 114581403422500557}
|
||||||
|
preRigidbody: {fileID: 5597807613657979793}
|
||||||
--- !u!1 &1933124697579601
|
--- !u!1 &1933124697579601
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -775,6 +773,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier: Assembly-CSharp::NBF.FLineLogicNode
|
m_EditorClassIdentifier: Assembly-CSharp::NBF.FLineLogicNode
|
||||||
NodeType: 1
|
NodeType: 1
|
||||||
rope: {fileID: 0}
|
rope: {fileID: 0}
|
||||||
|
preRigidbody: {fileID: 0}
|
||||||
--- !u!1 &3739175077773299312
|
--- !u!1 &3739175077773299312
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -16,6 +16,15 @@ namespace NBF
|
|||||||
SpinningFloat,
|
SpinningFloat,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 线模式
|
||||||
|
/// </summary>
|
||||||
|
public enum LineMode
|
||||||
|
{
|
||||||
|
Joint,
|
||||||
|
Constraint
|
||||||
|
}
|
||||||
|
|
||||||
public class FLine : FGearBase
|
public class FLine : FGearBase
|
||||||
{
|
{
|
||||||
public LineType LineType;
|
public LineType LineType;
|
||||||
@@ -23,18 +32,21 @@ namespace NBF
|
|||||||
|
|
||||||
[Header("连接点配置")] [SerializeField] private Transform anchorTransform;
|
[Header("连接点配置")] [SerializeField] private Transform anchorTransform;
|
||||||
[SerializeField] private List<FLineLogicNode> lineNodes = new List<FLineLogicNode>();
|
[SerializeField] private List<FLineLogicNode> lineNodes = new List<FLineLogicNode>();
|
||||||
[SerializeField] private bool isLureConnect;
|
|
||||||
[SerializeField] private RodLine rodLine;
|
|
||||||
|
|
||||||
/// <summary>
|
// [SerializeField] private bool isLureConnect;
|
||||||
/// 主线
|
//
|
||||||
/// </summary>
|
// [SerializeField] private RodLine rodLine;
|
||||||
[SerializeField] private Rope fishingRope;
|
//
|
||||||
|
// /// <summary>
|
||||||
|
// /// 主线
|
||||||
|
// /// </summary>
|
||||||
|
// [SerializeField] private Rope fishingRope;
|
||||||
|
//
|
||||||
|
// /// <summary>
|
||||||
|
// /// 浮漂和鱼钩线
|
||||||
|
// /// </summary>
|
||||||
|
// [SerializeField] private Rope bobberRope;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 浮漂和鱼钩线
|
|
||||||
/// </summary>
|
|
||||||
[SerializeField] private Rope bobberRope;
|
|
||||||
|
|
||||||
// public LureController Lure;
|
// public LureController Lure;
|
||||||
// public BobberController Bobber;
|
// public BobberController Bobber;
|
||||||
@@ -51,65 +63,21 @@ namespace NBF
|
|||||||
protected override void OnInit()
|
protected override void OnInit()
|
||||||
{
|
{
|
||||||
var tipRb = Rod.Asset.LineConnectorRigidbody;
|
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)
|
anchorTransform = tipRb.transform;
|
||||||
{
|
// StartCoroutine(LureUseGravity());
|
||||||
i.gameObject.SetActive(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
StartCoroutine(LureUseGravity());
|
|
||||||
if (isLureConnect)
|
|
||||||
{
|
|
||||||
fishingRope.Init(Rod);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fishingRope.Init(Rod);
|
|
||||||
bobberRope.Init(Rod);
|
|
||||||
}
|
|
||||||
|
|
||||||
// rodLine.GenerateLineRendererRope(guides.ToArray(), _LineThickness);
|
// rodLine.GenerateLineRendererRope(guides.ToArray(), _LineThickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator LureUseGravity()
|
// private IEnumerator LureUseGravity()
|
||||||
{
|
// {
|
||||||
yield return 1;
|
// yield return 1;
|
||||||
EndNode.gameObject.SetActive(false);
|
// EndNode.gameObject.SetActive(false);
|
||||||
EndNode.gameObject.SetActive(true);
|
// EndNode.gameObject.SetActive(true);
|
||||||
yield return 1;
|
// yield return 1;
|
||||||
EndNode.Rigidbody.useGravity = true;
|
// EndNode.Rigidbody.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 Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
@@ -178,13 +146,15 @@ namespace NBF
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Tension
|
#region Tension
|
||||||
|
|
||||||
private float GetLineDistance()
|
private float GetLineDistance()
|
||||||
{
|
{
|
||||||
//第一个节点到竿稍的位置-第一段鱼线长度
|
//第一个节点到竿稍的位置-第一段鱼线长度
|
||||||
return Vector3.Distance(StartNode.transform.position, bobberRope.transform.position) -
|
return Vector3.Distance(StartNode.transform.position, BobberNode.transform.position) -
|
||||||
fishingRope.GetCurrentLength();
|
BobberNode.Lenght;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetTension(float weight)
|
public float GetTension(float weight)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace NBF
|
|||||||
{
|
{
|
||||||
[Header("节点设置")] public FLineLogicNodeType NodeType = FLineLogicNodeType.Bobber;
|
[Header("节点设置")] public FLineLogicNodeType NodeType = FLineLogicNodeType.Bobber;
|
||||||
[SerializeField] private Rope rope;
|
[SerializeField] private Rope rope;
|
||||||
|
[SerializeField] private Rigidbody preRigidbody;
|
||||||
|
|
||||||
private Rigidbody _rb;
|
private Rigidbody _rb;
|
||||||
private SpringJoint _joint;
|
private SpringJoint _joint;
|
||||||
@@ -44,6 +45,27 @@ namespace NBF
|
|||||||
{
|
{
|
||||||
_joint.maxDistance = lenght;
|
_joint.maxDistance = lenght;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rope)
|
||||||
|
{
|
||||||
|
rope.SetTargetLength(lenght);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 切换约束模式
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mode"></param>
|
||||||
|
public void ChangeMode(LineMode mode)
|
||||||
|
{
|
||||||
|
if (mode == LineMode.Joint)
|
||||||
|
{
|
||||||
|
if (_joint) _joint.connectedBody = preRigidbody;
|
||||||
|
}
|
||||||
|
else if (mode == LineMode.Constraint)
|
||||||
|
{
|
||||||
|
if (_joint) _joint.connectedBody = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,14 +172,7 @@ public class Rope : MonoBehaviour
|
|||||||
private bool _isCulledByVisibility;
|
private bool _isCulledByVisibility;
|
||||||
private int _tIdleSubdiv = -1;
|
private int _tIdleSubdiv = -1;
|
||||||
private int _tMovingSubdiv = -1;
|
private int _tMovingSubdiv = -1;
|
||||||
|
|
||||||
private FRod _rod;
|
|
||||||
public void Init(FRod rod)
|
|
||||||
{
|
|
||||||
_rod = rod;
|
|
||||||
if (Application.isPlaying)
|
|
||||||
RefreshVisibilityState(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Catmull t caches(只缓存 idle/moving 两档,减少每帧重复乘法)
|
// Catmull t caches(只缓存 idle/moving 两档,减少每帧重复乘法)
|
||||||
private struct TCaches
|
private struct TCaches
|
||||||
@@ -248,8 +241,9 @@ public class Rope : MonoBehaviour
|
|||||||
if (!localOwnerAlwaysSimulate)
|
if (!localOwnerAlwaysSimulate)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var owner = _rod?.PlayerItem?.Owner;
|
// var owner = _rod?.PlayerItem?.Owner;
|
||||||
return owner == null || owner.IsSelf;
|
// return owner == null || owner.IsSelf;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Transform GetActiveCameraTransform()
|
private Transform GetActiveCameraTransform()
|
||||||
|
|||||||
Reference in New Issue
Block a user