升级obi
This commit is contained in:
@@ -18,7 +18,7 @@ public class SceneSettings : MonoBehaviour
|
||||
|
||||
public KWS_Ocean Water;
|
||||
|
||||
public ObiUpdater obiFixedUpdater;
|
||||
// public ObiUpdater obiFixedUpdater;
|
||||
|
||||
public LineRenderer LineRenderer;
|
||||
|
||||
|
||||
19
Assets/Scripts/Fishing/BobberController.cs
Normal file
19
Assets/Scripts/Fishing/BobberController.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class BobberController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Rigidbody _rbody;
|
||||
|
||||
[SerializeField] private ConfigurableJoint joint;
|
||||
|
||||
public Rigidbody rbody => _rbody;
|
||||
|
||||
public void SetJoint(Rigidbody rb)
|
||||
{
|
||||
joint = joint == null ? GetComponent<ConfigurableJoint>() : joint;
|
||||
joint.connectedBody = rb;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/BobberController.cs.meta
Normal file
3
Assets/Scripts/Fishing/BobberController.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e9411b5edc6466a8014c59e3821bbaa
|
||||
timeCreated: 1768918059
|
||||
33
Assets/Scripts/Fishing/LureController.cs
Normal file
33
Assets/Scripts/Fishing/LureController.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class LureController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Rigidbody rBody;
|
||||
[SerializeField] private ConfigurableJoint joint;
|
||||
public Rigidbody RBody => rBody;
|
||||
|
||||
public ConfigurableJoint Joint => joint;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/LureController.cs.meta
Normal file
3
Assets/Scripts/Fishing/LureController.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed5bbbc032ec4ca1bb56991d9141e311
|
||||
timeCreated: 1768918224
|
||||
@@ -15,7 +15,7 @@ namespace NBF
|
||||
private void FixArmAngle()
|
||||
{
|
||||
var angle = FPlayerData.Instance.EyeAngle;
|
||||
|
||||
|
||||
if (angle > MaxFixEyeAngle) angle = MaxFixEyeAngle;
|
||||
else if (angle < MinFixEyeAngle) angle = MinFixEyeAngle;
|
||||
var val = transform.localEulerAngles;
|
||||
|
||||
@@ -43,14 +43,13 @@ public class RodLine : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < points.Length; i++)
|
||||
for (var i = 0; i < points.Length; i++)
|
||||
{
|
||||
Transform transform = points[i];
|
||||
if ((bool)transform)
|
||||
var point = points[i];
|
||||
if (point)
|
||||
{
|
||||
lineRenderer.SetPosition(i, transform.position);
|
||||
lineRenderer.SetPosition(i, point.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using UnityEngine;
|
||||
public class Rope : MonoBehaviour
|
||||
{
|
||||
private FRod _rod;
|
||||
public bool isFloatRope;
|
||||
[SerializeField] private ObiRope rope;
|
||||
|
||||
[SerializeField] private ObiRopeCursor cursor;
|
||||
@@ -16,9 +17,21 @@ public class Rope : MonoBehaviour
|
||||
private void Awake()
|
||||
{
|
||||
rope = GetComponent<ObiRope>();
|
||||
}
|
||||
|
||||
public void Init(FRod rod)
|
||||
{
|
||||
_rod = rod;
|
||||
if (_rod)
|
||||
{
|
||||
LineLength_OnValueChanged(_rod.lineLength);
|
||||
if (isFloatRope)
|
||||
{
|
||||
LineLength_OnValueChanged(_rod.floatLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
LineLength_OnValueChanged(_rod.lineLength - _rod.floatLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,13 @@
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FBobber : FGearBase
|
||||
public class FBobber : FGearBase
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
transform.position = Rod.lineHandler.LineConnector_1.transform.position;
|
||||
// Bobber.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
|
||||
// lineHandler.LineConnector_1.GetComponent<Rigidbody>();
|
||||
|
||||
SetParent(Rod.lineHandler.LineConnector_1.transform);
|
||||
// transform.position = Rod.lineHandler.LineConnector_1.transform.position;
|
||||
SetParent(Rod.Line.Bobber.transform);
|
||||
transform.localPosition = Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,13 @@ namespace NBF
|
||||
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);
|
||||
// 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);
|
||||
transform.localPosition = Vector3.zero;
|
||||
|
||||
// var target = lineHandler.LineConnector_2.GetComponent<Rigidbody>();
|
||||
// var joint = Hook.gameObject.GetComponent<ConfigurableJoint>();
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
using Obi;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Obi;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
@@ -11,39 +15,110 @@ namespace NBF
|
||||
[SerializeField] private RodLine rodLine;
|
||||
[SerializeField] private Rope fishingRope;
|
||||
[SerializeField] private Rope bobberRope;
|
||||
public Transform LureRoot;
|
||||
public Transform BobberRoot;
|
||||
public LureController Lure;
|
||||
public BobberController Bobber;
|
||||
|
||||
public float LineLength = 0.5f;
|
||||
// public float LineLength = 0.5f;
|
||||
|
||||
private float _groundSetting = 0.5f;
|
||||
|
||||
private float _LineOnSpool = 100f;
|
||||
|
||||
private float _LineThickness = 0.0007f;
|
||||
// public event Action OnLinePulled;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
var rodTip = Rod.Asset.lineConnector;
|
||||
startParticleAttachment.target = rodTip;
|
||||
Solver = transform.parent.GetComponent<ObiSolver>();
|
||||
rodLine.gameObject.SetActive(false);
|
||||
var rodType = (ItemSubType)Rod.ItemInfo.Config.Type;
|
||||
if (rodType == ItemSubType.RodSpine || rodType == ItemSubType.RodBolo)
|
||||
var tipRb = Rod.Asset.LineConnectorRigidbody;
|
||||
startParticleAttachment.target = tipRb.transform;
|
||||
// transform.position = Rod.transform.position;
|
||||
if (isLureConnect)
|
||||
{
|
||||
rodLine.gameObject.SetActive(true);
|
||||
Lure.SetJoint(tipRb);
|
||||
Lure.EnableCollision(false);
|
||||
// isFloatingMethodUsed.Value = false;
|
||||
}
|
||||
else if (rodType == ItemSubType.RodTele)
|
||||
else
|
||||
{
|
||||
bobberRope.gameObject.SetActive(true);
|
||||
BobberRoot.gameObject.SetActive(true);
|
||||
var bobberConfigurableJoint = BobberRoot.GetComponent<ConfigurableJoint>();
|
||||
bobberConfigurableJoint.connectedBody = Rod.Asset.LineConnectorRigidbody;;
|
||||
Bobber.SetJoint(tipRb);
|
||||
Lure.SetJoint(Bobber.rbody);
|
||||
Lure.gameObject.SetActive(true);
|
||||
Lure.EnableCollision(false);
|
||||
Lure.SetKinematic(false);
|
||||
// isFloatingMethodUsed.Value = true;
|
||||
// GetComponentInChildren<Buoyancy>().targetSurface =
|
||||
// MonoBehaviourSingleton<GameWater>.Instance.WaterSurface;
|
||||
}
|
||||
|
||||
LureRoot.gameObject.SetActive(true);
|
||||
fishingRope.gameObject.SetActive(true);
|
||||
// SceneSettings.Instance.obiFixedUpdater.solvers.Add(Solver);
|
||||
// onLureInit.Raise(lure.gameObject);
|
||||
GetComponentsInChildren<Transform>(includeInactive: true).ToList().ForEach(delegate(Transform i)
|
||||
{
|
||||
i.gameObject.SetActive(true);
|
||||
});
|
||||
|
||||
StartCoroutine(test());
|
||||
fishingRope.Init(Rod);
|
||||
bobberRope.Init(Rod);
|
||||
// rodLine.GenerateLineRendererRope(guides.ToArray(), _LineThickness);
|
||||
}
|
||||
|
||||
private IEnumerator test()
|
||||
{
|
||||
yield return 1;
|
||||
Lure.gameObject.SetActive(false);
|
||||
Lure.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
// public void SetUnrolledLineValue(float lentgth)
|
||||
// {
|
||||
// LineLength = lentgth;
|
||||
// LineLength = Mathf.Clamp(LineLength, _groundSetting, _LineOnSpool);
|
||||
// if (LineLength == _groundSetting)
|
||||
// {
|
||||
// this.OnLinePulled?.Invoke();
|
||||
// }
|
||||
// }
|
||||
|
||||
public void EnableLineRenderers()
|
||||
{
|
||||
foreach (ObiRopeExtrudedRenderer item in GetComponentsInChildren<ObiRopeExtrudedRenderer>().ToList())
|
||||
{
|
||||
item.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetObiRopeStretch(float value)
|
||||
{
|
||||
fishingRope.LineLength_OnValueChanged(value);
|
||||
}
|
||||
|
||||
// public void Initialize(Transform rodTarget, Rigidbody tipRb, List<Transform> guides)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
|
||||
// protected override void OnInit()
|
||||
// {
|
||||
// var rodTip = Rod.Asset.lineConnector;
|
||||
// startParticleAttachment.target = rodTip;
|
||||
// Solver = transform.parent.GetComponent<ObiSolver>();
|
||||
// rodLine.gameObject.SetActive(false);
|
||||
// var rodType = (ItemSubType)Rod.ItemInfo.Config.Type;
|
||||
// if (rodType == ItemSubType.RodSpine || rodType == ItemSubType.RodBolo)
|
||||
// {
|
||||
// rodLine.gameObject.SetActive(true);
|
||||
// }
|
||||
// else if (rodType == ItemSubType.RodTele)
|
||||
// {
|
||||
// bobberRope.gameObject.SetActive(true);
|
||||
// BobberRoot.gameObject.SetActive(true);
|
||||
// var bobberConfigurableJoint = BobberRoot.GetComponent<ConfigurableJoint>();
|
||||
// bobberConfigurableJoint.connectedBody = Rod.Asset.LineConnectorRigidbody;;
|
||||
// }
|
||||
//
|
||||
// LureRoot.gameObject.SetActive(true);
|
||||
// fishingRope.gameObject.SetActive(true);
|
||||
// // SceneSettings.Instance.obiFixedUpdater.solvers.Add(Solver);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,16 @@ namespace NBF
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
transform.position = Rod.lineHandler.LineConnector_1.transform.position;
|
||||
// transform.position = Rod.lineHandler.LineConnector_1.transform.position;
|
||||
|
||||
// Lure.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
|
||||
// lineHandler.LineConnector_1.GetComponent<Rigidbody>();
|
||||
// LureHookWaterDisplacement = Lure.GetComponent<FWaterDisplacement>();
|
||||
|
||||
SetParent(Rod.lineHandler.LineConnector_1.transform);
|
||||
// SetParent(Rod.lineHandler.LineConnector_1.transform);
|
||||
|
||||
SetParent(Rod.Line.Lure.transform);
|
||||
transform.localPosition = Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,13 +28,13 @@ namespace NBF
|
||||
public FBait Bait;
|
||||
public FLure Lure;
|
||||
public FWeight Weight;
|
||||
// public FLine Line;
|
||||
public FLine Line;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 鱼线处理器
|
||||
/// </summary>
|
||||
public FLineHandler lineHandler;
|
||||
// /// <summary>
|
||||
// /// 鱼线处理器
|
||||
// /// </summary>
|
||||
// public FLineHandler lineHandler;
|
||||
|
||||
public Transform GearRoot;
|
||||
|
||||
@@ -46,7 +46,12 @@ namespace NBF
|
||||
/// <summary>
|
||||
/// 线长度
|
||||
/// </summary>
|
||||
public float lineLength;
|
||||
public float lineLength = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 浮漂线长度
|
||||
/// </summary>
|
||||
public float floatLength = 0.5f;
|
||||
|
||||
public float currentLineTension;
|
||||
public float linelenghtDiferent;
|
||||
@@ -58,6 +63,11 @@ namespace NBF
|
||||
Asset = GetComponent<RodAsset>();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
Test();
|
||||
}
|
||||
|
||||
public IEnumerator Destroy()
|
||||
{
|
||||
if (GearRoot != null)
|
||||
@@ -92,7 +102,6 @@ namespace NBF
|
||||
|
||||
ItemInfo lineItemInfo = null;
|
||||
|
||||
CreateFishingHandler();
|
||||
|
||||
// children.Sort();
|
||||
foreach (var child in children)
|
||||
@@ -140,7 +149,8 @@ namespace NBF
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
yield return 1;
|
||||
CreateFishingHandler();
|
||||
yield return 1;
|
||||
if (Reel)
|
||||
{
|
||||
@@ -177,8 +187,8 @@ namespace NBF
|
||||
Weight.Init(Player, this);
|
||||
}
|
||||
|
||||
yield return 2; //等待1帧
|
||||
|
||||
yield return 1; //等待1帧
|
||||
|
||||
transform.SetParent(Player.ModelAsset.RodRoot);
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.rotation = Player.ModelAsset.RodRoot.rotation;
|
||||
@@ -189,7 +199,7 @@ namespace NBF
|
||||
|
||||
public void CreateFishingHandler()
|
||||
{
|
||||
if (lineHandler == null)
|
||||
if (Line == null)
|
||||
{
|
||||
Debug.LogError("创建钓组=====");
|
||||
var rodType = (ItemSubType)ItemInfo.Config.Type;
|
||||
@@ -208,25 +218,37 @@ namespace NBF
|
||||
public void CreateObiFishingLine(int currentLineTypeIndex)
|
||||
{
|
||||
// if ((bool)Owner.Gears.Reel && !currentLineHandler)
|
||||
if (!lineHandler)
|
||||
if (!Line)
|
||||
{
|
||||
var indexNames = new[] { "FFishingLine_0", "FFishingLine_1" };
|
||||
//Assets/ResRaw/Prefabs/Line/LineSolver.prefab
|
||||
var lineSolverPrefab = Assets.Load<GameObject>("Assets/ResRaw/Prefabs/Line/LineSolver.prefab");
|
||||
var solver = Instantiate(lineSolverPrefab, GearRoot);
|
||||
solver.transform.position = Asset.lineConnector.position;
|
||||
solver.transform.rotation = Asset.lineConnector.rotation;
|
||||
// var indexNames = new[] { "FFishingLine_0", "FFishingLine_1" };
|
||||
var indexNames = new[] { "fishing line float set", "fishing line spinning" };
|
||||
var path =
|
||||
$"Assets/ResRaw/Prefabs/{indexNames[currentLineTypeIndex]}.prefab"; //$"GameItemsPrefabs/Lines/{indexNames[currentLineTypeIndex]}";
|
||||
$"Assets/ResRaw/Prefabs/Line/{indexNames[currentLineTypeIndex]}.prefab"; //$"GameItemsPrefabs/Lines/{indexNames[currentLineTypeIndex]}";
|
||||
var prefab = Assets.Load<GameObject>(path);
|
||||
|
||||
// var toRodConnector = rodAsset.lineConnector.GetComponent<Rigidbody>();
|
||||
GameObject obj = Instantiate(prefab, GearRoot.position, Quaternion.identity, GearRoot);
|
||||
GameObject obj = Instantiate(prefab, solver.transform);
|
||||
obj.transform.localPosition = Vector3.zero;
|
||||
obj.transform.localScale = Vector3.one;
|
||||
obj.transform.rotation = Quaternion.identity;
|
||||
|
||||
lineHandler = obj.GetComponent<FLineHandler>();
|
||||
// lineHandler.transform.SetParent(toRodConnector.transform);
|
||||
lineHandler.transform.position = Asset.lineConnector.position;
|
||||
lineHandler.LineConnector_0.target = Asset.lineConnector; //.GetComponent<Rigidbody>();
|
||||
// lineHandler.toRodConnector.target = rodAsset.lineConnector;
|
||||
lineHandler.Rod = this;
|
||||
// lineHandler.startParticleAttachment.target = Asset.lineConnector;
|
||||
var obiSolver = lineHandler.GetComponent<ObiSolver>();
|
||||
SceneSettings.Instance.obiFixedUpdater.solvers.Add(obiSolver);
|
||||
Line = obj.GetComponent<FLine>();
|
||||
Line.transform.position = Asset.lineConnector.position;
|
||||
Line.Init(this.Player, this);
|
||||
|
||||
// lineHandler = obj.GetComponent<FLineHandler>();
|
||||
// // lineHandler.transform.SetParent(toRodConnector.transform);
|
||||
// lineHandler.transform.position = Asset.lineConnector.position;
|
||||
// lineHandler.LineConnector_0.target = Asset.lineConnector; //.GetComponent<Rigidbody>();
|
||||
// lineHandler.Rod = this;
|
||||
// // lineHandler.startParticleAttachment.target = Asset.lineConnector;
|
||||
var obiSolver = solver.GetComponent<ObiSolver>();
|
||||
// SceneSettings.Instance.obiFixedUpdater.solvers.Add(obiSolver);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,5 +290,12 @@ namespace NBF
|
||||
|
||||
rings = list.ToArray();
|
||||
}
|
||||
|
||||
private void Test()
|
||||
{
|
||||
// var root = Player.ModelAsset.RodRoot;
|
||||
// if (!root) return;
|
||||
// transform.SetPositionAndRotation(root.position, root.rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user