重新导入obi
This commit is contained in:
12
Assets/Scripts/Fishing/Rope/IRope.cs
Normal file
12
Assets/Scripts/Fishing/Rope/IRope.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 鱼线脚本
|
||||
/// </summary>
|
||||
public interface IRope
|
||||
{
|
||||
void SetLineLength(float length);
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Rope/IRope.cs.meta
Normal file
3
Assets/Scripts/Fishing/Rope/IRope.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e702dc5afb0a467e9e01a920d959a977
|
||||
timeCreated: 1775445873
|
||||
22
Assets/Scripts/Fishing/Rope/RopeBase.cs
Normal file
22
Assets/Scripts/Fishing/Rope/RopeBase.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public abstract class RopeBase : MonoBehaviour, IRope
|
||||
{
|
||||
[Header("Anchors")] [SerializeField] public Rigidbody startAnchor;
|
||||
[SerializeField] public Rigidbody endAnchor;
|
||||
|
||||
public float CurrentLength { get; protected set; }
|
||||
|
||||
public void SetLineLength(float length)
|
||||
{
|
||||
CurrentLength = length;
|
||||
}
|
||||
|
||||
protected virtual void OnSetLineLength(float length)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Rope/RopeBase.cs.meta
Normal file
3
Assets/Scripts/Fishing/Rope/RopeBase.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b39290e64e04f27a02a273fab64d461
|
||||
timeCreated: 1775446264
|
||||
36
Assets/Scripts/Fishing/Rope/RopeByObi.cs
Normal file
36
Assets/Scripts/Fishing/Rope/RopeByObi.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Obi;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 基于obi rope的鱼线控制脚本
|
||||
/// </summary>
|
||||
public class RopeByObi : RopeBase
|
||||
{
|
||||
[SerializeField] private ObiRope rope;
|
||||
|
||||
[SerializeField] private ObiRopeCursor cursor;
|
||||
|
||||
[SerializeField] private float percentageElasticity = 0.2f;
|
||||
|
||||
|
||||
private float _stretchScale;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
rope = GetComponent<ObiRope>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
rope.stretchingScale = _stretchScale;
|
||||
}
|
||||
|
||||
protected override void OnSetLineLength(float length)
|
||||
{
|
||||
cursor = ((cursor == null) ? GetComponent<ObiRopeCursor>() : cursor);
|
||||
_stretchScale = Mathf.Clamp(length - percentageElasticity, 0f, float.PositiveInfinity);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Rope/RopeByObi.cs.meta
Normal file
3
Assets/Scripts/Fishing/Rope/RopeByObi.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b7f9ea147004095b3e8390654d061a9
|
||||
timeCreated: 1775445787
|
||||
Reference in New Issue
Block a user