新增脚本
This commit is contained in:
@@ -30,10 +30,6 @@ namespace NBF
|
||||
public FWeight Weight;
|
||||
public FLine Line;
|
||||
|
||||
/// <summary>
|
||||
/// 鱼线处理器
|
||||
/// </summary>
|
||||
public FLineHandler lineHandler;
|
||||
|
||||
public Transform GearRoot;
|
||||
|
||||
@@ -81,9 +77,12 @@ namespace NBF
|
||||
|
||||
var parent = GearRoot;
|
||||
|
||||
CreateFishingHandler();
|
||||
|
||||
List<ItemInfo> children = RoleModel.Instance.GetBindItems(itemInfo.Id);
|
||||
|
||||
ItemInfo lineItemInfo = null;
|
||||
|
||||
// CreateFishingHandler();
|
||||
|
||||
// children.Sort();
|
||||
foreach (var child in children)
|
||||
{
|
||||
@@ -124,7 +123,13 @@ namespace NBF
|
||||
Quaternion.identity);
|
||||
Weight.SetItemInfo(child);
|
||||
}
|
||||
else if (itemType == ItemType.Line)
|
||||
{
|
||||
lineItemInfo = child;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
yield return 1;
|
||||
if (Reel)
|
||||
@@ -136,40 +141,40 @@ namespace NBF
|
||||
Reel.Init(player, this);
|
||||
}
|
||||
|
||||
if (Bobber)
|
||||
{
|
||||
Bobber.Init(Player, this);
|
||||
Bobber.transform.position = lineHandler.LineConnector_1.transform.position;
|
||||
Bobber.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
|
||||
lineHandler.LineConnector_1.GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
if (Hook)
|
||||
{
|
||||
Hook.Init(Player, this);
|
||||
Hook.transform.position = lineHandler.LineConnector_2.transform.position;
|
||||
Hook.transform.rotation = lineHandler.LineConnector_2.transform.rotation; // 确保旋转也同步
|
||||
var target = lineHandler.LineConnector_2.GetComponent<Rigidbody>();
|
||||
var joint = Hook.gameObject.GetComponent<ConfigurableJoint>();
|
||||
joint.connectedBody = target;
|
||||
// LureHookWaterDisplacement = Hook.GetComponent<FWaterDisplacement>();
|
||||
}
|
||||
|
||||
if (Bait)
|
||||
{
|
||||
Bait.Init(Player, this);
|
||||
Bait.transform.position = Hook.hookAsset.baitConnector.position;
|
||||
Bait.transform.SetParent(Hook.hookAsset.baitConnector);
|
||||
}
|
||||
|
||||
if (Lure)
|
||||
{
|
||||
Lure.Init(Player, this);
|
||||
Lure.transform.position = lineHandler.LineConnector_1.transform.position;
|
||||
Lure.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
|
||||
lineHandler.LineConnector_1.GetComponent<Rigidbody>();
|
||||
// LureHookWaterDisplacement = Lure.GetComponent<FWaterDisplacement>();
|
||||
}
|
||||
// if (Bobber)
|
||||
// {
|
||||
// Bobber.Init(Player, this);
|
||||
// Bobber.transform.position = lineHandler.LineConnector_1.transform.position;
|
||||
// Bobber.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
|
||||
// lineHandler.LineConnector_1.GetComponent<Rigidbody>();
|
||||
// }
|
||||
//
|
||||
// if (Hook)
|
||||
// {
|
||||
// Hook.Init(Player, this);
|
||||
// Hook.transform.position = lineHandler.LineConnector_2.transform.position;
|
||||
// Hook.transform.rotation = lineHandler.LineConnector_2.transform.rotation; // 确保旋转也同步
|
||||
// var target = lineHandler.LineConnector_2.GetComponent<Rigidbody>();
|
||||
// var joint = Hook.gameObject.GetComponent<ConfigurableJoint>();
|
||||
// joint.connectedBody = target;
|
||||
// // LureHookWaterDisplacement = Hook.GetComponent<FWaterDisplacement>();
|
||||
// }
|
||||
//
|
||||
// if (Bait)
|
||||
// {
|
||||
// Bait.Init(Player, this);
|
||||
// Bait.transform.position = Hook.hookAsset.baitConnector.position;
|
||||
// Bait.transform.SetParent(Hook.hookAsset.baitConnector);
|
||||
// }
|
||||
//
|
||||
// if (Lure)
|
||||
// {
|
||||
// Lure.Init(Player, this);
|
||||
// Lure.transform.position = lineHandler.LineConnector_1.transform.position;
|
||||
// Lure.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
|
||||
// lineHandler.LineConnector_1.GetComponent<Rigidbody>();
|
||||
// // LureHookWaterDisplacement = Lure.GetComponent<FWaterDisplacement>();
|
||||
// }
|
||||
|
||||
if (Weight)
|
||||
{
|
||||
@@ -223,95 +228,5 @@ namespace NBF
|
||||
|
||||
rings = list.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public void CreateFishingHandler()
|
||||
{
|
||||
if (lineHandler == null)
|
||||
{
|
||||
Debug.LogError("创建钓组=====");
|
||||
var rodType = (ItemSubType)ItemInfo.Config.Type;
|
||||
if (rodType == ItemSubType.RodTele)
|
||||
{
|
||||
CreateObiFishingLine(0);
|
||||
}
|
||||
else if (rodType == ItemSubType.RodSpine || rodType == ItemSubType.RodBolo)
|
||||
{
|
||||
CreateObiFishingLine(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateObiFishingLine(int currentLineTypeIndex)
|
||||
{
|
||||
// if ((bool)Owner.Gears.Reel && !currentLineHandler)
|
||||
if (!lineHandler)
|
||||
{
|
||||
var indexNames = new[] { "FFishingLine_0", "FFishingLine_1" };
|
||||
var path =
|
||||
$"Assets/ResRaw/Prefabs/{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);
|
||||
|
||||
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;
|
||||
// var obiSolver = lineHandler.GetComponent<ObiSolver>();
|
||||
// SceneSettings.Instance.obiFixedUpdater.solvers.Add(obiSolver);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void RenderLine()
|
||||
{
|
||||
if (!lineHandler)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Reel) return;
|
||||
if (!Asset.lineRenderer) return;
|
||||
|
||||
// var reel = Reel;
|
||||
// int num = 0;
|
||||
// bool isBlockLineByFinger = reel.isBlockLineByFinger;
|
||||
// if (reel.AnimatorCtrl.Unlock && isBlockLineByFinger && reel.reelAsset.type == ReelAsset.Type.Normal)
|
||||
// {
|
||||
// Asset.lineRenderer.positionCount = rings.Length + 3;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Asset.lineRenderer.positionCount = rings.Length + 2;
|
||||
// }
|
||||
//
|
||||
// Asset.lineRenderer.SetPosition(num, reel.reelAsset.lineIntersectHelper.position);
|
||||
// num++;
|
||||
// if (reel.AnimatorCtrl.Unlock && reel.reelAsset.type == ReelAsset.Type.Normal)
|
||||
// {
|
||||
// Asset.lineRenderer.SetPosition(num, reel.reelAsset.lineIntersect.position);
|
||||
// num++;
|
||||
// if (isBlockLineByFinger)
|
||||
// {
|
||||
// // Asset.lineRenderer.SetPosition(num, reel.reelAsset.lineFingerPoint.position);
|
||||
// // num++;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Asset.lineRenderer.SetPosition(num, reel.reelAsset.lineConnector.position);
|
||||
// num++;
|
||||
// }
|
||||
//
|
||||
// for (int num2 = 0; num2 < rings.Length; num2++)
|
||||
// {
|
||||
// Asset.lineRenderer.SetPosition(num, rings[num2].point.position);
|
||||
// num++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user