新增脚本
This commit is contained in:
@@ -35,6 +35,9 @@ namespace NBF
|
||||
public LookAtIK LookIk;
|
||||
|
||||
|
||||
public Transform RodRoot;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
LookIk = GetComponent<LookAtIK>();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using RootMotion.FinalIK;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
@@ -50,12 +51,22 @@ namespace NBF
|
||||
/// </summary>
|
||||
public Transform lineConnector;
|
||||
|
||||
private void Start()
|
||||
public CCDIK CCDIK;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
CCDIK = GetComponent<CCDIK>();
|
||||
CCDIK.enabled = false;
|
||||
if (!lineConnector && joints.Length > 0)
|
||||
{
|
||||
lineConnector = joints[^1];
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using NBC;
|
||||
using NBC.Asset;
|
||||
using NBF.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
@@ -17,7 +19,44 @@ namespace NBF
|
||||
|
||||
public static string GetModelPath(this ItemConfig config)
|
||||
{
|
||||
return "gfx/" + config.Model;
|
||||
return $"Assets/ResRaw/gfx/{config.Model}.prefab";
|
||||
}
|
||||
|
||||
public static GameObject GetModelPrefab(this ItemConfig config)
|
||||
{
|
||||
return Assets.Load<GameObject>(config.GetModelPath());
|
||||
}
|
||||
|
||||
public static GameObject Instantiate(this ItemConfig config, Transform parent, Vector3 position,
|
||||
Quaternion rotation)
|
||||
{
|
||||
return Object.Instantiate(config.GetModelPrefab(), position, rotation, parent);
|
||||
}
|
||||
|
||||
|
||||
public static T InstantiateAndComponent<T>(this ItemConfig config, Transform parent, Vector3 position,
|
||||
Quaternion rotation) where T : MonoBehaviour
|
||||
{
|
||||
var obj = config.Instantiate(parent, position, rotation);
|
||||
var com = obj.GetComponent<T>();
|
||||
if (com == null)
|
||||
{
|
||||
com = obj.AddComponent<T>();
|
||||
}
|
||||
|
||||
return com;
|
||||
}
|
||||
|
||||
public static T InstantiateAndComponent<T>(this ItemConfig config) where T : MonoBehaviour
|
||||
{
|
||||
var obj = Object.Instantiate(config.GetModelPrefab());
|
||||
var com = obj.GetComponent<T>();
|
||||
if (com == null)
|
||||
{
|
||||
com = obj.AddComponent<T>();
|
||||
}
|
||||
|
||||
return com;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,8 @@ namespace NBF
|
||||
|
||||
|
||||
_bindConfigs.Add(rodTele.SubType, rodTele);
|
||||
_bindConfigs.Add(rodBolo.SubType, rodBolo);
|
||||
_bindConfigs.Add(rodSpine.SubType, rodSpine);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace NBF.Utils
|
||||
{
|
||||
public static string GetFullModelPath(this ItemConfig config)
|
||||
{
|
||||
return Path.Combine("gfx", config.Model);
|
||||
//Assets/ResRaw/gfx/hooks/alliance/c_hook_20789_20794/c_hook_20789.prefab
|
||||
return $"Assets/ResRaw/gfx/{config.Model}.prefab"; //Path.Combine("Assets/ResRaw/gfx", config.Model);
|
||||
}
|
||||
|
||||
public static ItemType GetItemType(this uint id)
|
||||
|
||||
3
Assets/Scripts/Fishing/Animator.meta
Normal file
3
Assets/Scripts/Fishing/Animator.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcae353a013f4bd8bd4818abbcbe6959
|
||||
timeCreated: 1766743259
|
||||
55
Assets/Scripts/Fishing/Animator/ReelAnimator.cs
Normal file
55
Assets/Scripts/Fishing/Animator/ReelAnimator.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class ReelAnimator : MonoBehaviour
|
||||
{
|
||||
public FReel Reel;
|
||||
|
||||
private Animator _animator;
|
||||
|
||||
#region 参数定义
|
||||
|
||||
private static readonly int ReelingHash = Animator.StringToHash("Reeling");
|
||||
private static readonly int LineOutHash = Animator.StringToHash("LineOut");
|
||||
private static readonly int UnlockHash = Animator.StringToHash("Unlock");
|
||||
private static readonly int LineOutUnlockHash = Animator.StringToHash("LineOutUnlock");
|
||||
|
||||
public float Reeling
|
||||
{
|
||||
get => _animator.GetFloat(ReelingHash);
|
||||
set => _animator.SetFloat(ReelingHash, value);
|
||||
}
|
||||
|
||||
public float Reeling2
|
||||
{
|
||||
get => _animator.GetFloat(ReelingHash);
|
||||
set => _animator.SetFloat(ReelingHash, value);
|
||||
}
|
||||
|
||||
public float LineOut
|
||||
{
|
||||
get => _animator.GetFloat(LineOutHash);
|
||||
set => _animator.SetFloat(LineOutHash, value);
|
||||
}
|
||||
|
||||
public bool Unlock
|
||||
{
|
||||
get => _animator.GetBool(UnlockHash);
|
||||
set => _animator.SetBool(UnlockHash, value);
|
||||
}
|
||||
|
||||
public bool LineOutUnlock
|
||||
{
|
||||
get => _animator.GetBool(LineOutUnlockHash);
|
||||
set => _animator.SetBool(LineOutUnlockHash, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_animator = GetComponent<Animator>();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Animator/ReelAnimator.cs.meta
Normal file
3
Assets/Scripts/Fishing/Animator/ReelAnimator.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dad5b24d68464595b58a0d8fea28a10b
|
||||
timeCreated: 1766743262
|
||||
@@ -31,8 +31,6 @@ namespace NBF
|
||||
mapId = 99;
|
||||
}
|
||||
|
||||
// var root = Game.Main;
|
||||
|
||||
var response = (G2C_EnterMapResponse)await Net.Call(new C2G_EnterMapRequest()
|
||||
{
|
||||
MapId = mapId,
|
||||
|
||||
33
Assets/Scripts/Fishing/FixedLine.cs
Normal file
33
Assets/Scripts/Fishing/FixedLine.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FixedLine : MonoBehaviour
|
||||
{
|
||||
public Transform target;
|
||||
private Rigidbody _rigidbody;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_rigidbody = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
// FixLine();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
FixLine();
|
||||
}
|
||||
|
||||
|
||||
private void FixLine()
|
||||
{
|
||||
if (!target) return;
|
||||
_rigidbody.MovePosition(target.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/FixedLine.cs.meta
Normal file
3
Assets/Scripts/Fishing/FixedLine.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec22ad0246c24123a6511e60e753ee38
|
||||
timeCreated: 1766586205
|
||||
@@ -1,9 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FLure : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FReel : MonoBehaviour
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FRod : MonoBehaviour
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,223 +0,0 @@
|
||||
using System.Collections;
|
||||
using Fantasy;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 钓组
|
||||
/// </summary>
|
||||
public class FTackle : MonoBehaviour
|
||||
{
|
||||
private ItemInfo _itemInfo;
|
||||
|
||||
public static FTackle Create(ItemInfo itemInfo)
|
||||
{
|
||||
var root = SceneSettings.Instance.GearNode;
|
||||
var obj = new GameObject($"Rod_{itemInfo.ConfigId}").AddComponent<FTackle>();
|
||||
obj.transform.SetParent(root.transform);
|
||||
obj.transform.localPosition = Vector3.zero;
|
||||
obj.transform.localRotation = Quaternion.identity;
|
||||
obj.transform.localScale = Vector3.one;
|
||||
return obj;
|
||||
}
|
||||
|
||||
public IEnumerator Show(ItemInfo itemInfo)
|
||||
{
|
||||
_itemInfo = itemInfo;
|
||||
yield return 1;
|
||||
|
||||
// var parent = GearParent;
|
||||
// parent.position = Player.transform.position;
|
||||
//
|
||||
// var data = Player.Data.currentGear;
|
||||
// var rodConfig = data.rod.Config;
|
||||
// var cloneObj = rodConfig.Instantiate(parent, Vector3.zero, Player.MainArm.RodContainer.rotation);
|
||||
// if (cloneObj == null)
|
||||
// {
|
||||
// yield break;
|
||||
// }
|
||||
//
|
||||
// Rod = cloneObj.GetComponent<FRod>();
|
||||
// if (Rod == null)
|
||||
// {
|
||||
// Rod = cloneObj.AddComponent<FRod>();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (Rod)
|
||||
// {
|
||||
// Rod.transform.localPosition = Vector3.zero;
|
||||
// Rod.transform.rotation = Player.MainArm.RodContainer.rotation;
|
||||
//
|
||||
// if (rodConfig.ring > 0)
|
||||
// {
|
||||
// var ringConfig = GameRings.Get(rodConfig.ring);
|
||||
// var ringObject = ringConfig.Instantiate(Rod.transform);
|
||||
// ringObject.SetActive(false);
|
||||
// Rod.SetRing(ringObject.GetComponent<RodRingAsset>());
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// yield break;
|
||||
// }
|
||||
//
|
||||
// if (data.line != null)
|
||||
// {
|
||||
// var linePrefab = data.line.Config.Instantiate(parent);
|
||||
// Line = linePrefab.GetComponent<FLine>();
|
||||
// }
|
||||
//
|
||||
// if (data.reel != null)
|
||||
// {
|
||||
// var reelPrefab = data.reel.Config.Create(parent);
|
||||
// Reel = reelPrefab.GetComponent<FReel>();
|
||||
// }
|
||||
//
|
||||
// if (data.bobber != null)
|
||||
// {
|
||||
// var bobberPrefab = data.bobber.Config.Create(parent);
|
||||
// Bobber = bobberPrefab.GetComponent<FFloat>();
|
||||
// }
|
||||
//
|
||||
// if (data.hook != null)
|
||||
// {
|
||||
// var hookPrefab = data.hook.Config.Create(parent);
|
||||
// Hook = hookPrefab.GetComponent<FHook>();
|
||||
// }
|
||||
//
|
||||
// if (data.bait != null)
|
||||
// {
|
||||
// var baitPrefab = data.bait.Config.Create(parent);
|
||||
//
|
||||
// if (baitPrefab.TryGetComponent<FBait>(out var bait))
|
||||
// {
|
||||
// Bait = bait;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (data.lure != null)
|
||||
// {
|
||||
// var baitPrefab = data.lure.Config.Create(parent);
|
||||
// if (baitPrefab.TryGetComponent<FLure>(out var lure))
|
||||
// {
|
||||
// Lure = lure;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (data.weight != null)
|
||||
// {
|
||||
// var weightPrefab = data.weight.Config.Instantiate(parent);
|
||||
// Weight = weightPrefab.GetComponent<FWeight>();
|
||||
// }
|
||||
//
|
||||
// Debug.LogError("CreateOrHideGear");
|
||||
// yield return 1;
|
||||
// Rod.Initialize(Player, data.rod);
|
||||
// Rod.CreateFishingHandler();
|
||||
//
|
||||
// if (Line)
|
||||
// {
|
||||
// Line.Initialize(Player, data.line);
|
||||
//
|
||||
//
|
||||
// if ((bool)Rod.lineHandler.obiRopeSegment_1)
|
||||
// {
|
||||
// Rod.lineHandler.obiRopeSegment_1.GetComponent<MeshRenderer>().material =
|
||||
// Line.lineMat;
|
||||
// }
|
||||
//
|
||||
// if ((bool)Rod.lineHandler.obiRopeSegment_2)
|
||||
// {
|
||||
// Rod.lineHandler.obiRopeSegment_2.GetComponent<MeshRenderer>().material =
|
||||
// Line.lineMat;
|
||||
// }
|
||||
//
|
||||
// if ((bool)Rod.lineHandler.obiRopeSegment_3)
|
||||
// {
|
||||
// Rod.lineHandler.obiRopeSegment_3.GetComponent<MeshRenderer>().material =
|
||||
// Line.lineMat;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (Reel)
|
||||
// {
|
||||
// // Reel.maxReelStrength = data.reel.Config.strength;
|
||||
// // Reel.reelingSpeed = 0.5f; //slotsEquip.reel.currentSpeed;
|
||||
// Reel.reelingDrag = 0.699f; //slotsEquip.reel.currentDrag;
|
||||
// Reel.transform.SetParent(Rod.rodAsset.ReelConnector);
|
||||
// Reel.transform.localPosition = Vector3.zero;
|
||||
// Reel.transform.localEulerAngles = Vector3.zero;
|
||||
// // Reel.reelAsset.szpulaObject.GetComponent<MeshRenderer>().material = Line.szpulaMat;
|
||||
// Reel.Initialize(Player, data.reel);
|
||||
// }
|
||||
//
|
||||
// if (Bobber)
|
||||
// {
|
||||
// Bobber.floatDisplacement = data.bobber.Config.displacement;
|
||||
// // if ((double)slotsEquip.ffloat.lastSetGroundValue > 0.2)
|
||||
// // {
|
||||
// // Bobber.newDeepth = slotsEquip.ffloat.lastSetGroundValue;
|
||||
// // }
|
||||
//
|
||||
// Bobber.newDeepth = 0.5f;
|
||||
//
|
||||
// Bobber.Initialize(Player, data.bobber);
|
||||
// Bobber.transform.position = Rod.lineHandler.LineConnector_1.transform.position;
|
||||
// Bobber.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
|
||||
// Rod.lineHandler.LineConnector_1.GetComponent<Rigidbody>();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (Hook)
|
||||
// {
|
||||
// Hook.Initialize(Player, data.hook);
|
||||
//
|
||||
// Hook.transform.position = Rod.lineHandler.LineConnector_2.transform.position;
|
||||
// Hook.transform.rotation = Rod.lineHandler.LineConnector_2.transform.rotation; // 确保旋转也同步
|
||||
// var target = Rod.lineHandler.LineConnector_2.GetComponent<Rigidbody>();
|
||||
// var joint = Hook.gameObject.GetComponent<ConfigurableJoint>();
|
||||
// // // 关键设置:关闭自动锚点计算,手动设置锚点
|
||||
// // joint.autoConfigureConnectedAnchor = false;
|
||||
// // joint.anchor = Vector3.zero; // 以 Hook 自身中心为锚点
|
||||
// // joint.connectedAnchor = Vector3.zero; // 以目标物体的中心为锚点
|
||||
// joint.connectedBody = target;
|
||||
// // // 强制物理引擎立即更新变换(避免1帧延迟)
|
||||
// // Physics.SyncTransforms();
|
||||
// // joint.autoConfigureConnectedAnchor = false;
|
||||
// // joint.anchor = Vector3.zero;
|
||||
// // joint.connectedAnchor = Vector3.zero;
|
||||
// Rod.LureHookWaterDisplacement = Hook.GetComponent<FWaterDisplacement>();
|
||||
// }
|
||||
//
|
||||
// if (Bait)
|
||||
// {
|
||||
// Bait.Initialize(Player, data.bait);
|
||||
// Bait.transform.position = Hook.hookAsset.baitConnector.position;
|
||||
// Bait.transform.SetParent(Hook.hookAsset.baitConnector);
|
||||
// }
|
||||
//
|
||||
// if (Lure)
|
||||
// {
|
||||
// Lure.Initialize(Player, data.bait);
|
||||
// Lure.transform.position = Rod.lineHandler.LineConnector_1.transform.position;
|
||||
// Lure.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
|
||||
// Rod.lineHandler.LineConnector_1.GetComponent<Rigidbody>();
|
||||
// Rod.LureHookWaterDisplacement = Lure.GetComponent<FWaterDisplacement>();
|
||||
// }
|
||||
//
|
||||
// if (Weight)
|
||||
// {
|
||||
// Weight.weight = data.weight.Config.weight;
|
||||
// Weight.Initialize(Player, data.weight);
|
||||
// }
|
||||
}
|
||||
|
||||
public IEnumerator Remove()
|
||||
{
|
||||
yield return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,10 @@ namespace NBF.Fishing2
|
||||
public static GameObject LoadPrefab(string path, Transform parent = null)
|
||||
{
|
||||
var prefab = Assets.Load<GameObject>(path);
|
||||
if (prefab == null)
|
||||
{
|
||||
|
||||
}
|
||||
return parent == null ? Object.Instantiate(prefab) : Object.Instantiate(prefab, parent);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace NBF
|
||||
|
||||
public FPlayerData Data { get; private set; }
|
||||
|
||||
public readonly List<FTackle> Tackles = new List<FTackle>();
|
||||
public FTackle HandTackle { get; private set; }
|
||||
public readonly List<FRod> Tackles = new List<FRod>();
|
||||
public FRod HandTackle { get; private set; }
|
||||
|
||||
protected override void OnAwake()
|
||||
{
|
||||
@@ -75,18 +75,18 @@ namespace NBF
|
||||
var itemType = item?.ConfigId.GetItemType();
|
||||
if (itemType == ItemType.Rod)
|
||||
{
|
||||
if (HandTackle)
|
||||
//判断旧的是否要收回
|
||||
if (HandTackle != null)
|
||||
{
|
||||
yield return HandTackle.Remove();
|
||||
yield return HandTackle.Destroy();
|
||||
Tackles.Remove(HandTackle);
|
||||
HandTackle = null;
|
||||
}
|
||||
|
||||
//判断旧的是否要收回
|
||||
var tackle = FTackle.Create(item);
|
||||
HandTackle = tackle;
|
||||
yield return tackle.Show(item);
|
||||
Tackles.Add(tackle);
|
||||
HandTackle =
|
||||
item.Config.InstantiateAndComponent<FRod>(SceneSettings.Instance.GearNode, Vector3.zero, Quaternion.identity);
|
||||
yield return HandTackle.InitRod(this, item);
|
||||
Tackles.Add(HandTackle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
Assets/Scripts/Fishing/Tackle/FBait.cs
Normal file
12
Assets/Scripts/Fishing/Tackle/FBait.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FBait : FGearBase
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Tackle/FBait.cs.meta
Normal file
3
Assets/Scripts/Fishing/Tackle/FBait.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed7126c6f37c427e88ba321c63aeac2f
|
||||
timeCreated: 1766582532
|
||||
12
Assets/Scripts/Fishing/Tackle/FBobber.cs
Normal file
12
Assets/Scripts/Fishing/Tackle/FBobber.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FBobber : FGearBase
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FHook : MonoBehaviour
|
||||
public class FFish : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Tackle/FFish.cs.meta
Normal file
3
Assets/Scripts/Fishing/Tackle/FFish.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d76aeec1876a4df2a93e8e8dcaee30fa
|
||||
timeCreated: 1766586324
|
||||
33
Assets/Scripts/Fishing/Tackle/FGearBase.cs
Normal file
33
Assets/Scripts/Fishing/Tackle/FGearBase.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Fantasy;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public abstract class FGearBase : MonoBehaviour
|
||||
{
|
||||
public FPlayer Player { get; protected set; }
|
||||
public FRod Rod { get; protected set; }
|
||||
public ItemInfo ItemInfo;
|
||||
|
||||
public HookAsset hookAsset;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
hookAsset = GetComponent<HookAsset>();
|
||||
}
|
||||
|
||||
public virtual void Init(FPlayer player, FRod rod)
|
||||
{
|
||||
Player = player;
|
||||
Rod = rod;
|
||||
OnInit();
|
||||
}
|
||||
|
||||
public void SetItemInfo(ItemInfo itemInfo)
|
||||
{
|
||||
ItemInfo = itemInfo;
|
||||
}
|
||||
|
||||
protected abstract void OnInit();
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Tackle/FGearBase.cs.meta
Normal file
3
Assets/Scripts/Fishing/Tackle/FGearBase.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 708753789f5b41f48b9b18197f54a9df
|
||||
timeCreated: 1766582740
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FBobber : MonoBehaviour
|
||||
public class FHandItem : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Tackle/FHandItem.cs.meta
Normal file
3
Assets/Scripts/Fishing/Tackle/FHandItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5460b0f542fd45e38145b2a4fb12e329
|
||||
timeCreated: 1766583615
|
||||
12
Assets/Scripts/Fishing/Tackle/FHook.cs
Normal file
12
Assets/Scripts/Fishing/Tackle/FHook.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FHook : FGearBase
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Scripts/Fishing/Tackle/FLine.cs
Normal file
12
Assets/Scripts/Fishing/Tackle/FLine.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FLine : FGearBase
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Tackle/FLine.cs.meta
Normal file
3
Assets/Scripts/Fishing/Tackle/FLine.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0403ffd74ce46fab8bd4ef057e51432
|
||||
timeCreated: 1766582567
|
||||
190
Assets/Scripts/Fishing/Tackle/FLineHandler.cs
Normal file
190
Assets/Scripts/Fishing/Tackle/FLineHandler.cs
Normal file
@@ -0,0 +1,190 @@
|
||||
using System;
|
||||
using NBF;
|
||||
using Obi;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class FLineHandler : MonoBehaviour
|
||||
{
|
||||
public enum LineType
|
||||
{
|
||||
None = 0,
|
||||
OneSegment = 1,
|
||||
TwoSegment = 2,
|
||||
ThereSegment = 3
|
||||
}
|
||||
|
||||
public LineType lineType = LineType.TwoSegment;
|
||||
|
||||
public ObiRope obiRopeSegment_1;
|
||||
|
||||
public ObiRope obiRopeSegment_2;
|
||||
|
||||
public ObiRope obiRopeSegment_3;
|
||||
|
||||
public FixedLine LineConnector_0;
|
||||
|
||||
public SpringJoint LineConnector_1;
|
||||
|
||||
public SpringJoint LineConnector_2;
|
||||
|
||||
public SpringJoint LineConnector_3;
|
||||
|
||||
// [HideInInspector] public FFishingLine currentRodFishingLineComponent;
|
||||
|
||||
// public ObiParticleAttachment toRodConnector;
|
||||
|
||||
// public float PhisicsLineOut { get; set; }
|
||||
|
||||
public float ObiLineOut;
|
||||
|
||||
[HideInInspector] public Rigidbody EndLineRigidbody_0;
|
||||
|
||||
[HideInInspector] public Rigidbody EndLineRigidbody_1;
|
||||
|
||||
[HideInInspector] public Rigidbody EndLineRigidbody_2;
|
||||
|
||||
[HideInInspector] public Rigidbody EndLineRigidbody_3;
|
||||
|
||||
// public JointPinchController pinchController;
|
||||
|
||||
public FRod Rod;
|
||||
|
||||
private Transform waterPlane;
|
||||
|
||||
|
||||
// public float ropeToHookDistance;
|
||||
|
||||
void Start()
|
||||
{
|
||||
ObiLineOut = obiRopeSegment_1.stretchingScale;
|
||||
if ((bool)LineConnector_0)
|
||||
{
|
||||
EndLineRigidbody_0 = LineConnector_0.GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
if ((bool)LineConnector_1)
|
||||
{
|
||||
EndLineRigidbody_1 = LineConnector_1.GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
if ((bool)LineConnector_2)
|
||||
{
|
||||
EndLineRigidbody_2 = LineConnector_2.GetComponent<Rigidbody>();
|
||||
// var fixedJoint = LineConnector_2.GetComponent<FixedJoint>();
|
||||
// pinchController = LineConnector_2.gameObject.AddComponent<JointPinchController>();
|
||||
}
|
||||
|
||||
if ((bool)LineConnector_3)
|
||||
{
|
||||
EndLineRigidbody_3 = LineConnector_3.GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
waterPlane = GameObject.FindGameObjectWithTag("Water").transform;
|
||||
|
||||
Debug.LogError($"rope.restLength={obiRopeSegment_1.restLength} LineConnector_1={LineConnector_1.maxDistance}");
|
||||
}
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!Rod) return;
|
||||
|
||||
|
||||
// ropeToHookDistance = Vector3.Distance(toRodConnector.transform.position, LineConnector_1.transform.position);
|
||||
|
||||
ObiLineOut = 0.1f + Rod.lineLength;
|
||||
float target = (0f - Mathf.Clamp(Rod.linelenghtDiferent, -1f, 0f)) * 0.1f;
|
||||
if (Rod.linelenghtDiferent >= 0f)
|
||||
{
|
||||
obiRopeSegment_1.stretchCompliance = Mathf.MoveTowards(obiRopeSegment_1.stretchCompliance, target,
|
||||
Time.smoothDeltaTime * (1f * Rod.linelenghtDiferent));
|
||||
}
|
||||
else
|
||||
{
|
||||
obiRopeSegment_1.stretchCompliance = Mathf.MoveTowards(obiRopeSegment_1.stretchCompliance, target,
|
||||
Time.smoothDeltaTime * 0.1f);
|
||||
}
|
||||
|
||||
if (Rod.lineLength == 0f)
|
||||
{
|
||||
obiRopeSegment_1.stretchCompliance = 0f;
|
||||
}
|
||||
|
||||
if ((bool)obiRopeSegment_2)
|
||||
{
|
||||
if (!Rod.currentFish)
|
||||
{
|
||||
obiRopeSegment_2.stretchCompliance = obiRopeSegment_2.stretchingScale * 0.004f;
|
||||
}
|
||||
else
|
||||
{
|
||||
obiRopeSegment_2.stretchCompliance = 0f;
|
||||
}
|
||||
|
||||
//TODO:TEST
|
||||
obiRopeSegment_2.stretchingScale = 0.13F;
|
||||
}
|
||||
|
||||
obiRopeSegment_1.stretchingScale = ObiLineOut;
|
||||
obiRopeSegment_1.stretchingScale = 1;
|
||||
LineConnector_1.maxDistance = 0.1f + Rod.lineLength;
|
||||
if (Input.GetKey(KeyCode.E))
|
||||
{
|
||||
// var speed = 1;
|
||||
// obiRopeCursor_1.ChangeLength(LineConnector_1.maxDistance);
|
||||
// Debug.Log(obiRopeSegment_1.restLength);
|
||||
}
|
||||
|
||||
// var addLength = LineConnector_1.maxDistance - obiRopeSegment_1.restLength;
|
||||
// if (Mathf.Abs(addLength) > 0.001f)
|
||||
// {
|
||||
// obiRopeCursor_1.ChangeLength(LineConnector_1.maxDistance);
|
||||
// }
|
||||
|
||||
// if (!Mathf.Approximately(LineConnector_1.maxDistance, obiRopeSegment_1.restLength))
|
||||
// {
|
||||
// obiRopeCursor_1.ChangeLength(LineConnector_1.maxDistance);
|
||||
// }
|
||||
|
||||
// obiRopeCursor_1.pos
|
||||
|
||||
|
||||
// LineConnector_1.minDistance = LineConnector_1.maxDistance;
|
||||
}
|
||||
|
||||
public void SetSegmentTwoLenght(float lenght)
|
||||
{
|
||||
LineConnector_2.maxDistance = lenght;
|
||||
// obiRopeCursor_2.ChangeLength(lenght);
|
||||
// LineConnector_2.minDistance = LineConnector_2.maxDistance;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
// BindRod();
|
||||
LineWaterDisplacement();
|
||||
}
|
||||
|
||||
private void BindRod()
|
||||
{
|
||||
if (!Rod || !Rod.Asset) return;
|
||||
LineConnector_0.transform.position = Rod.Asset.lineConnector.position;
|
||||
}
|
||||
|
||||
private void LineWaterDisplacement()
|
||||
{
|
||||
if (!waterPlane)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < obiRopeSegment_1.activeParticleCount; i++)
|
||||
{
|
||||
if (obiRopeSegment_1.GetParticlePosition(i).y < waterPlane.position.y)
|
||||
{
|
||||
// obiRopeSegment_1.AddForceParticle(i, Vector3.up * 10f, ForceMode.Acceleration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Tackle/FLineHandler.cs.meta
Normal file
3
Assets/Scripts/Fishing/Tackle/FLineHandler.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 331fde19f47e431092cf5bd57c7bcfe4
|
||||
timeCreated: 1766586159
|
||||
12
Assets/Scripts/Fishing/Tackle/FLure.cs
Normal file
12
Assets/Scripts/Fishing/Tackle/FLure.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FLure : FGearBase
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Assets/Scripts/Fishing/Tackle/FReel.cs
Normal file
32
Assets/Scripts/Fishing/Tackle/FReel.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using Fantasy;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FReel : FGearBase
|
||||
{
|
||||
public bool isBlockLineByFinger { get; set; }
|
||||
|
||||
|
||||
[SerializeField] public float reelingDrag = 1f;
|
||||
|
||||
public ReelAsset Asset;
|
||||
public ReelAnimator AnimatorCtrl;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Asset = GetComponent<ReelAsset>();
|
||||
AnimatorCtrl = Asset.animator.gameObject.GetComponent<ReelAnimator>();
|
||||
if (AnimatorCtrl == null)
|
||||
{
|
||||
AnimatorCtrl = Asset.animator.gameObject.AddComponent<ReelAnimator>();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
317
Assets/Scripts/Fishing/Tackle/FRod.cs
Normal file
317
Assets/Scripts/Fishing/Tackle/FRod.cs
Normal file
@@ -0,0 +1,317 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Fantasy;
|
||||
using NBC.Asset;
|
||||
using NBF.Utils;
|
||||
using Obi;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FRod : FHandItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 可用的
|
||||
/// </summary>
|
||||
public bool Usable { get; private set; }
|
||||
|
||||
public RodAsset Asset;
|
||||
|
||||
public FPlayer Player { get; protected set; }
|
||||
public ItemInfo ItemInfo;
|
||||
|
||||
public FReel Reel;
|
||||
public FHook Hook;
|
||||
public FBobber Bobber;
|
||||
public FBait Bait;
|
||||
public FLure Lure;
|
||||
public FWeight Weight;
|
||||
public FLine Line;
|
||||
|
||||
/// <summary>
|
||||
/// 鱼线处理器
|
||||
/// </summary>
|
||||
public FLineHandler lineHandler;
|
||||
|
||||
public Transform GearRoot;
|
||||
|
||||
// public FWaterDisplacement LureHookWaterDisplacement;
|
||||
|
||||
[HideInInspector] public FFish currentFish;
|
||||
public RodRingNode[] rings;
|
||||
|
||||
/// <summary>
|
||||
/// 线长度
|
||||
/// </summary>
|
||||
public float lineLength;
|
||||
|
||||
public float currentLineTension;
|
||||
public float linelenghtDiferent;
|
||||
public float currentLineStrenght;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Asset = GetComponent<RodAsset>();
|
||||
}
|
||||
|
||||
public IEnumerator Destroy()
|
||||
{
|
||||
yield return 1;
|
||||
}
|
||||
|
||||
public IEnumerator InitRod(FPlayer player, ItemInfo itemInfo)
|
||||
{
|
||||
ItemInfo = itemInfo;
|
||||
Player = player;
|
||||
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.localRotation = Quaternion.identity;
|
||||
transform.localScale = Vector3.one;
|
||||
yield return 1;
|
||||
var obj = new GameObject($"rod_{itemInfo.Id}_{itemInfo.ConfigId}");
|
||||
obj.transform.SetParent(SceneSettings.Instance.GearNode);
|
||||
// obj.transform.localPosition = Vector3.zero;
|
||||
obj.transform.position = player.transform.position;
|
||||
obj.transform.rotation = player.transform.rotation;
|
||||
obj.transform.localScale = Vector3.one;
|
||||
GearRoot = obj.transform;
|
||||
|
||||
var parent = GearRoot;
|
||||
|
||||
CreateFishingHandler();
|
||||
|
||||
List<ItemInfo> children = RoleModel.Instance.GetBindItems(itemInfo.Id);
|
||||
// children.Sort();
|
||||
foreach (var child in children)
|
||||
{
|
||||
var itemType = child.ConfigId.GetItemType();
|
||||
if (itemType == ItemType.Reel)
|
||||
{
|
||||
Reel = child.Config.InstantiateAndComponent<FReel>(Asset.ReelConnector, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Reel.SetItemInfo(child);
|
||||
}
|
||||
else if (itemType == ItemType.Bobber)
|
||||
{
|
||||
Bobber = child.Config.InstantiateAndComponent<FBobber>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Bobber.SetItemInfo(child);
|
||||
}
|
||||
else if (itemType == ItemType.Hook)
|
||||
{
|
||||
Hook = child.Config.InstantiateAndComponent<FHook>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Hook.SetItemInfo(child);
|
||||
}
|
||||
else if (itemType == ItemType.Bait)
|
||||
{
|
||||
Bait = child.Config.InstantiateAndComponent<FBait>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Bait.SetItemInfo(child);
|
||||
}
|
||||
else if (itemType == ItemType.Lure)
|
||||
{
|
||||
Lure = child.Config.InstantiateAndComponent<FLure>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Lure.SetItemInfo(child);
|
||||
}
|
||||
else if (itemType == ItemType.Weight)
|
||||
{
|
||||
Weight = child.Config.InstantiateAndComponent<FWeight>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Weight.SetItemInfo(child);
|
||||
}
|
||||
}
|
||||
|
||||
yield return 1;
|
||||
if (Reel)
|
||||
{
|
||||
Reel.reelingDrag = 0.699f;
|
||||
Reel.transform.SetParent(Asset.ReelConnector);
|
||||
Reel.transform.localPosition = Vector3.zero;
|
||||
Reel.transform.localEulerAngles = Vector3.zero;
|
||||
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 (Weight)
|
||||
{
|
||||
Weight.Init(Player, this);
|
||||
}
|
||||
|
||||
yield return 1; //等待1帧
|
||||
transform.SetParent(Player.ModelAsset.RodRoot);
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.rotation = Player.ModelAsset.RodRoot.rotation;
|
||||
|
||||
Usable = true;
|
||||
}
|
||||
|
||||
|
||||
public void SetRing(RodRingAsset ringAsset)
|
||||
{
|
||||
if (Asset.rings == null || Asset.rings.Length < 1) return;
|
||||
|
||||
var trans = ringAsset.rings;
|
||||
RodRingNode lastRingNode = null;
|
||||
List<RodRingNode> list = new List<RodRingNode>();
|
||||
for (int i = 0; i < Asset.rings.Length; i++)
|
||||
{
|
||||
var ring = Asset.rings[i];
|
||||
if (ring == null)
|
||||
{
|
||||
Log.Error($"ring is null,index={i}");
|
||||
continue;
|
||||
}
|
||||
|
||||
var lastName = ring.name.GetLastString();
|
||||
foreach (var tran in trans)
|
||||
{
|
||||
var ringNode = tran.ring;
|
||||
var lastName2 = ringNode.name.GetLastString();
|
||||
if (lastName != lastName2) continue;
|
||||
list.Add(tran);
|
||||
ringNode.SetParent(ring);
|
||||
ringNode.localPosition = Vector3.zero;
|
||||
ringNode.localRotation = Quaternion.identity;
|
||||
lastRingNode = tran;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastRingNode != null)
|
||||
{
|
||||
Asset.lineConnector = lastRingNode.point;
|
||||
}
|
||||
|
||||
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++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
233
Assets/Scripts/Fishing/Tackle/FVirtualTackle.cs
Normal file
233
Assets/Scripts/Fishing/Tackle/FVirtualTackle.cs
Normal file
@@ -0,0 +1,233 @@
|
||||
// using System.Collections;
|
||||
// using Fantasy;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace NBF
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 虚拟钓组
|
||||
// /// </summary>
|
||||
// public class FVirtualTackle
|
||||
// {
|
||||
// private ItemInfo _itemInfo;
|
||||
// private FPlayer _player;
|
||||
//
|
||||
//
|
||||
// public FRod Rod;
|
||||
//
|
||||
//
|
||||
// public FVirtualTackle(ItemInfo itemInfo, FPlayer player)
|
||||
// {
|
||||
// _itemInfo = itemInfo;
|
||||
// _player = player;
|
||||
// }
|
||||
//
|
||||
// public IEnumerator Create()
|
||||
// {
|
||||
// var parent = _player.transform;
|
||||
// // parent.position = _player.transform.position;
|
||||
//
|
||||
//
|
||||
// Rod = _itemInfo.Config.InstantiateAndComponent<FRod>(parent, Vector3.zero, Quaternion.identity);
|
||||
//
|
||||
//
|
||||
// // var rodObject = _itemInfo.Config.Instantiate(parent, Vector3.zero, Quaternion.identity);
|
||||
// // Rod = rodObject.GetComponent<FRod>();
|
||||
// // if (Rod == null)
|
||||
// // {
|
||||
// // Rod = rodObject.AddComponent<FRod>();
|
||||
// // }
|
||||
// // var rodConfig = RodConfig.Get(itemInfo.ConfigId);
|
||||
// // itemInfo.Config
|
||||
//
|
||||
// // var data = Player.Data.currentGear;
|
||||
// // var rodConfig = data.rod.Config;
|
||||
// // var cloneObj = rodConfig.Instantiate(parent, Vector3.zero, Player.MainArm.RodContainer.rotation);
|
||||
// // if (cloneObj == null)
|
||||
// // {
|
||||
// // yield break;
|
||||
// // }
|
||||
// //
|
||||
// // Rod = cloneObj.GetComponent<FRod>();
|
||||
// // if (Rod == null)
|
||||
// // {
|
||||
// // Rod = cloneObj.AddComponent<FRod>();
|
||||
// // }
|
||||
// //
|
||||
// //
|
||||
// // if (Rod)
|
||||
// // {
|
||||
// // Rod.transform.localPosition = Vector3.zero;
|
||||
// // Rod.transform.rotation = Player.MainArm.RodContainer.rotation;
|
||||
// //
|
||||
// // if (rodConfig.ring > 0)
|
||||
// // {
|
||||
// // var ringConfig = GameRings.Get(rodConfig.ring);
|
||||
// // var ringObject = ringConfig.Instantiate(Rod.transform);
|
||||
// // ringObject.SetActive(false);
|
||||
// // Rod.SetRing(ringObject.GetComponent<RodRingAsset>());
|
||||
// // }
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // yield break;
|
||||
// // }
|
||||
// //
|
||||
// // if (data.line != null)
|
||||
// // {
|
||||
// // var linePrefab = data.line.Config.Instantiate(parent);
|
||||
// // Line = linePrefab.GetComponent<FLine>();
|
||||
// // }
|
||||
// //
|
||||
// // if (data.reel != null)
|
||||
// // {
|
||||
// // var reelPrefab = data.reel.Config.Create(parent);
|
||||
// // Reel = reelPrefab.GetComponent<FReel>();
|
||||
// // }
|
||||
// //
|
||||
// // if (data.bobber != null)
|
||||
// // {
|
||||
// // var bobberPrefab = data.bobber.Config.Create(parent);
|
||||
// // Bobber = bobberPrefab.GetComponent<FFloat>();
|
||||
// // }
|
||||
// //
|
||||
// // if (data.hook != null)
|
||||
// // {
|
||||
// // var hookPrefab = data.hook.Config.Create(parent);
|
||||
// // Hook = hookPrefab.GetComponent<FHook>();
|
||||
// // }
|
||||
// //
|
||||
// // if (data.bait != null)
|
||||
// // {
|
||||
// // var baitPrefab = data.bait.Config.Create(parent);
|
||||
// //
|
||||
// // if (baitPrefab.TryGetComponent<FBait>(out var bait))
|
||||
// // {
|
||||
// // Bait = bait;
|
||||
// // }
|
||||
// // }
|
||||
// //
|
||||
// // if (data.lure != null)
|
||||
// // {
|
||||
// // var baitPrefab = data.lure.Config.Create(parent);
|
||||
// // if (baitPrefab.TryGetComponent<FLure>(out var lure))
|
||||
// // {
|
||||
// // Lure = lure;
|
||||
// // }
|
||||
// // }
|
||||
// //
|
||||
// //
|
||||
// // if (data.weight != null)
|
||||
// // {
|
||||
// // var weightPrefab = data.weight.Config.Instantiate(parent);
|
||||
// // Weight = weightPrefab.GetComponent<FWeight>();
|
||||
// // }
|
||||
// //
|
||||
// // Debug.LogError("CreateOrHideGear");
|
||||
// // yield return 1;
|
||||
// // Rod.Initialize(Player, data.rod);
|
||||
// // Rod.CreateFishingHandler();
|
||||
// //
|
||||
// // if (Line)
|
||||
// // {
|
||||
// // Line.Initialize(Player, data.line);
|
||||
// //
|
||||
// //
|
||||
// // if ((bool)Rod.lineHandler.obiRopeSegment_1)
|
||||
// // {
|
||||
// // Rod.lineHandler.obiRopeSegment_1.GetComponent<MeshRenderer>().material =
|
||||
// // Line.lineMat;
|
||||
// // }
|
||||
// //
|
||||
// // if ((bool)Rod.lineHandler.obiRopeSegment_2)
|
||||
// // {
|
||||
// // Rod.lineHandler.obiRopeSegment_2.GetComponent<MeshRenderer>().material =
|
||||
// // Line.lineMat;
|
||||
// // }
|
||||
// //
|
||||
// // if ((bool)Rod.lineHandler.obiRopeSegment_3)
|
||||
// // {
|
||||
// // Rod.lineHandler.obiRopeSegment_3.GetComponent<MeshRenderer>().material =
|
||||
// // Line.lineMat;
|
||||
// // }
|
||||
// // }
|
||||
// //
|
||||
// // if (Reel)
|
||||
// // {
|
||||
// // // Reel.maxReelStrength = data.reel.Config.strength;
|
||||
// // // Reel.reelingSpeed = 0.5f; //slotsEquip.reel.currentSpeed;
|
||||
// // Reel.reelingDrag = 0.699f; //slotsEquip.reel.currentDrag;
|
||||
// // Reel.transform.SetParent(Rod.rodAsset.ReelConnector);
|
||||
// // Reel.transform.localPosition = Vector3.zero;
|
||||
// // Reel.transform.localEulerAngles = Vector3.zero;
|
||||
// // // Reel.reelAsset.szpulaObject.GetComponent<MeshRenderer>().material = Line.szpulaMat;
|
||||
// // Reel.Initialize(Player, data.reel);
|
||||
// // }
|
||||
// //
|
||||
// // if (Bobber)
|
||||
// // {
|
||||
// // Bobber.floatDisplacement = data.bobber.Config.displacement;
|
||||
// // // if ((double)slotsEquip.ffloat.lastSetGroundValue > 0.2)
|
||||
// // // {
|
||||
// // // Bobber.newDeepth = slotsEquip.ffloat.lastSetGroundValue;
|
||||
// // // }
|
||||
// //
|
||||
// // Bobber.newDeepth = 0.5f;
|
||||
// //
|
||||
// // Bobber.Initialize(Player, data.bobber);
|
||||
// // Bobber.transform.position = Rod.lineHandler.LineConnector_1.transform.position;
|
||||
// // Bobber.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
|
||||
// // Rod.lineHandler.LineConnector_1.GetComponent<Rigidbody>();
|
||||
// // }
|
||||
// //
|
||||
// //
|
||||
// // if (Hook)
|
||||
// // {
|
||||
// // Hook.Initialize(Player, data.hook);
|
||||
// //
|
||||
// // Hook.transform.position = Rod.lineHandler.LineConnector_2.transform.position;
|
||||
// // Hook.transform.rotation = Rod.lineHandler.LineConnector_2.transform.rotation; // 确保旋转也同步
|
||||
// // var target = Rod.lineHandler.LineConnector_2.GetComponent<Rigidbody>();
|
||||
// // var joint = Hook.gameObject.GetComponent<ConfigurableJoint>();
|
||||
// // // // 关键设置:关闭自动锚点计算,手动设置锚点
|
||||
// // // joint.autoConfigureConnectedAnchor = false;
|
||||
// // // joint.anchor = Vector3.zero; // 以 Hook 自身中心为锚点
|
||||
// // // joint.connectedAnchor = Vector3.zero; // 以目标物体的中心为锚点
|
||||
// // joint.connectedBody = target;
|
||||
// // // // 强制物理引擎立即更新变换(避免1帧延迟)
|
||||
// // // Physics.SyncTransforms();
|
||||
// // // joint.autoConfigureConnectedAnchor = false;
|
||||
// // // joint.anchor = Vector3.zero;
|
||||
// // // joint.connectedAnchor = Vector3.zero;
|
||||
// // Rod.LureHookWaterDisplacement = Hook.GetComponent<FWaterDisplacement>();
|
||||
// // }
|
||||
// //
|
||||
// // if (Bait)
|
||||
// // {
|
||||
// // Bait.Initialize(Player, data.bait);
|
||||
// // Bait.transform.position = Hook.hookAsset.baitConnector.position;
|
||||
// // Bait.transform.SetParent(Hook.hookAsset.baitConnector);
|
||||
// // }
|
||||
// //
|
||||
// // if (Lure)
|
||||
// // {
|
||||
// // Lure.Initialize(Player, data.bait);
|
||||
// // Lure.transform.position = Rod.lineHandler.LineConnector_1.transform.position;
|
||||
// // Lure.gameObject.GetComponent<ConfigurableJoint>().connectedBody =
|
||||
// // Rod.lineHandler.LineConnector_1.GetComponent<Rigidbody>();
|
||||
// // Rod.LureHookWaterDisplacement = Lure.GetComponent<FWaterDisplacement>();
|
||||
// // }
|
||||
// //
|
||||
// // if (Weight)
|
||||
// // {
|
||||
// // Weight.weight = data.weight.Config.weight;
|
||||
// // Weight.Initialize(Player, data.weight);
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// public IEnumerator Destroy()
|
||||
// {
|
||||
// yield return 1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
12
Assets/Scripts/Fishing/Tackle/FWeight.cs
Normal file
12
Assets/Scripts/Fishing/Tackle/FWeight.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FWeight : FGearBase
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Tackle/FWeight.cs.meta
Normal file
3
Assets/Scripts/Fishing/Tackle/FWeight.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a68c58e07092402dbc37a5f287e70b9b
|
||||
timeCreated: 1766582543
|
||||
@@ -35,8 +35,8 @@ namespace Fantasy
|
||||
public const uint C2G_LoginRequest = 268445460;
|
||||
public const uint G2C_LoginResponse = 402663188;
|
||||
public const uint G2C_RepeatLogin = 134227729;
|
||||
public const uint C2Game_GetRoleInfoRequest = 2281711387;
|
||||
public const uint Game2C_GetRoleInfoResponse = 2415929115;
|
||||
public const uint C2Game_GetRoleInfoRequest = 2281711386;
|
||||
public const uint Game2C_GetRoleInfoResponse = 2415929114;
|
||||
public const uint Map2C_RoleEnterRoomNotify = 2147493653;
|
||||
public const uint Map2C_RoleExitRoomNotify = 2147493654;
|
||||
public const uint C2Map_TakeItemRequest = 2281711388;
|
||||
|
||||
@@ -95,8 +95,8 @@ namespace NBF
|
||||
// var role = Game.Main.GetComponent<Role>();
|
||||
// var roleBag = role.GetComponent<RoleBag>();
|
||||
|
||||
// List<object> items = roleBag.GetItemListData();
|
||||
// List.SetListData(items);
|
||||
List<object> items = RoleModel.Instance.GetItemListData(_itemTypes.ToArray());
|
||||
List.SetListData(items);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,8 @@ namespace NBF
|
||||
if (context.data is BagSlotItem bagSlotItem)
|
||||
{
|
||||
_lastSelectedItem = bagSlotItem.Index;
|
||||
BagSelectPanel.Show(SelectCallback, ItemType.Rod, ItemType.Bobber, ItemType.Reel);
|
||||
BagSelectPanel.Show(SelectCallback, ItemType.Rod, ItemType.Bobber, ItemType.Reel, ItemType.Bait,
|
||||
ItemType.Hook, ItemType.Line, ItemType.Lure);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,9 @@ namespace NBF
|
||||
public void SetInfo(ItemInfo itemInfo)
|
||||
{
|
||||
_usedItems.Clear();
|
||||
// var role = Game.Main.GetComponent<Role>();
|
||||
// _bag = role.GetComponent<RoleBag>();
|
||||
|
||||
Info = itemInfo;
|
||||
// _bindItems = _bag.GetBindItems(Info.Id);
|
||||
_bindItems = RoleModel.Instance.GetBindItems(Info.Id);
|
||||
var types = itemInfo.GetBindConfig();
|
||||
List.RemoveChildrenToPool();
|
||||
if (types != null)
|
||||
@@ -87,12 +85,12 @@ namespace NBF
|
||||
{
|
||||
if (_lastSelectedItem == null) return;
|
||||
Log.Info($"选中id={selectId}");
|
||||
// _bag.AddRig(Info.Id, selectId, _lastSelectedItem.RigId).OnCompleted(ChangeInfo);
|
||||
RoleModel.Instance.AddRig(Info.Id, selectId, _lastSelectedItem.RigId).OnCompleted(ChangeInfo);
|
||||
}
|
||||
|
||||
private void CloseCallback(long id, long removeId)
|
||||
{
|
||||
// _bag.RemoveRig(Info.Id, removeId).OnCompleted(ChangeInfo);
|
||||
RoleModel.Instance.RemoveRig(Info.Id, removeId).OnCompleted(ChangeInfo);
|
||||
}
|
||||
|
||||
private void ChangeInfo()
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace NBF
|
||||
bool _cacheTexture;
|
||||
// Vector3 _rotating;
|
||||
|
||||
const int RENDER_LAYER = 0;
|
||||
const int RENDER_LAYER = 22;
|
||||
const int HIDDEN_LAYER = 10;
|
||||
|
||||
public ModelViewRenderImage(GGraph holder)
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace NBF
|
||||
|
||||
// BagPanel.Show();
|
||||
// BagSlotPanel.Show();
|
||||
|
||||
// FishingShopPanel.Show();
|
||||
|
||||
Del();
|
||||
|
||||
Reference in New Issue
Block a user