大修改调整
This commit is contained in:
3
Assets/Scripts/Fishing/New/View/Handle.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Handle.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 958b50133e064daf9764313f24b892da
|
||||
timeCreated: 1773069791
|
||||
@@ -0,0 +1,13 @@
|
||||
using Fantasy.Event;
|
||||
|
||||
namespace NBF.Handle
|
||||
{
|
||||
public class OnPlayerStateChangeEvent : EventSystem<PlayerStateChangeEvent>
|
||||
{
|
||||
protected override void Handler(PlayerStateChangeEvent self)
|
||||
{
|
||||
var view = self.Player.GetOrAddComponent<PlayerItemViewComponent>();
|
||||
view.ShowItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5897acb7a6e40fcb3123362df1669f3
|
||||
timeCreated: 1773069799
|
||||
@@ -1,8 +1,9 @@
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy;
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Entitas.Interface;
|
||||
using NBC;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using Log = NBC.Log;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
@@ -89,8 +90,15 @@ namespace NBF
|
||||
var item = RoleModel.Instance.GetSlotItem(index - 1);
|
||||
if (item != null)
|
||||
{
|
||||
Player.UseItem(item);
|
||||
// Game.Instance.StartCoroutine(UseItem(item));
|
||||
var itemBindInfo = ItemBindInfo.Create();
|
||||
itemBindInfo.Item = item.ConfigId;
|
||||
var binds = RoleModel.Instance.GetBindItems(item.Id);
|
||||
foreach (var itemInfo in binds)
|
||||
{
|
||||
itemBindInfo.BindItems.Add(itemInfo.ConfigId);
|
||||
}
|
||||
|
||||
Player.UseItem(itemBindInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,7 +129,7 @@ namespace NBF
|
||||
|
||||
#region Move
|
||||
|
||||
private Quaternion lastRotation;
|
||||
private Quaternion _lastRotation;
|
||||
|
||||
private void UpdateMove()
|
||||
{
|
||||
@@ -155,7 +163,7 @@ namespace NBF
|
||||
Quaternion rotation = View.Unity.FirstPerson.transform.rotation;
|
||||
|
||||
// 计算当前帧与上一帧的旋转差异
|
||||
Quaternion rotationDelta = rotation * Quaternion.Inverse(lastRotation);
|
||||
Quaternion rotationDelta = rotation * Quaternion.Inverse(_lastRotation);
|
||||
|
||||
// 将四元数转换为角度轴表示
|
||||
rotationDelta.ToAngleAxis(out float angle, out Vector3 axis);
|
||||
@@ -179,7 +187,7 @@ namespace NBF
|
||||
|
||||
Player.RotationSpeed = turnValue;
|
||||
|
||||
lastRotation = rotation;
|
||||
_lastRotation = rotation;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
67
Assets/Scripts/Fishing/New/View/PlayerItemViewComponent.cs
Normal file
67
Assets/Scripts/Fishing/New/View/PlayerItemViewComponent.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Collections;
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerItemViewComponent : Entity
|
||||
{
|
||||
public void ShowItem()
|
||||
{
|
||||
// Game.Instance.StartCoroutine()
|
||||
}
|
||||
|
||||
#region 使用物品
|
||||
|
||||
// public IEnumerator UseItem(ItemInfo item)
|
||||
// {
|
||||
// if (Data.ChangeItem) yield break;
|
||||
// Data.ChangeItem = true;
|
||||
// var itemType = item?.ConfigId.GetItemType();
|
||||
// if (itemType == ItemType.Rod)
|
||||
// {
|
||||
// //判断旧的是否要收回
|
||||
// yield return UnUseItemConfirm();
|
||||
//
|
||||
// Data.IsLureRod = true;
|
||||
// var rodType = (ItemSubType)item.Config.Type;
|
||||
// if (rodType == ItemSubType.RodTele)
|
||||
// {
|
||||
// Data.IsLureRod = false;
|
||||
// }
|
||||
//
|
||||
// Rod =
|
||||
// item.Config.InstantiateAndComponent<FRod>(SceneSettings.Instance.GearNode, Vector3.zero,
|
||||
// Quaternion.identity);
|
||||
// yield return Rod.InitRod(this, item);
|
||||
// Tackles.Add(Rod);
|
||||
// OnFishingSetEquiped?.Invoke(Rod);
|
||||
// }
|
||||
//
|
||||
// Data.ChangeItem = false;
|
||||
// }
|
||||
//
|
||||
// public IEnumerator UnUseItem()
|
||||
// {
|
||||
// if (Data.ChangeItem) yield break;
|
||||
// Data.ChangeItem = true;
|
||||
// yield return UnUseItemConfirm();
|
||||
// Data.ChangeItem = false;
|
||||
// }
|
||||
//
|
||||
// private IEnumerator UnUseItemConfirm()
|
||||
// {
|
||||
// if (Rod != null)
|
||||
// {
|
||||
// OnFishingSetUnequip?.Invoke();
|
||||
// yield return Rod.Destroy();
|
||||
// yield return new WaitForSeconds(0.35f);
|
||||
// Destroy(Rod.gameObject);
|
||||
// Tackles.Remove(Rod);
|
||||
// Rod = null;
|
||||
// yield return new WaitForSeconds(0.15f);
|
||||
// }
|
||||
// }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf5f405feb8f431ea52d8f33b3cb2e29
|
||||
timeCreated: 1773069665
|
||||
77
Assets/Scripts/Fishing/New/View/PlayerStateViewComponent.cs
Normal file
77
Assets/Scripts/Fishing/New/View/PlayerStateViewComponent.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System.Collections.Generic;
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Entitas.Interface;
|
||||
using Fantasy.Event;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 状态显示层组件
|
||||
/// </summary>
|
||||
public class PlayerStateViewComponent : Entity
|
||||
{
|
||||
private readonly Dictionary<PlayerState, PlayerStageViewBase> _stageViews =
|
||||
new Dictionary<PlayerState, PlayerStageViewBase>();
|
||||
|
||||
private PlayerStageViewBase _currentStateView;
|
||||
private Player _player;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
_player = GetParent<Player>();
|
||||
_stageViews.Add(PlayerState.Idle, new PlayerStageViewIdle());
|
||||
_stageViews.Add(PlayerState.Prepare, new PlayerStageViewPrepare());
|
||||
_stageViews.Add(PlayerState.Throw, new PlayerStageViewThrow());
|
||||
_stageViews.Add(PlayerState.Fishing, new PlayerStageViewFishing());
|
||||
_stageViews.Add(PlayerState.Fight, new PlayerStageViewFight());
|
||||
foreach (var playerStageView in _stageViews.Values)
|
||||
{
|
||||
playerStageView.Init(_player);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
_currentStateView?.Update();
|
||||
}
|
||||
|
||||
public void OnStageChange()
|
||||
{
|
||||
if (_currentStateView != null)
|
||||
{
|
||||
_currentStateView.Exit();
|
||||
}
|
||||
|
||||
_currentStateView = _stageViews.GetValueOrDefault(_player.State);
|
||||
_currentStateView.Enter(_player.StateParams, _player.PreviousState);
|
||||
}
|
||||
}
|
||||
|
||||
public class PlayerStateViewComponentAwakeSystem : AwakeSystem<PlayerStateViewComponent>
|
||||
{
|
||||
protected override void Awake(PlayerStateViewComponent self)
|
||||
{
|
||||
self.Awake();
|
||||
}
|
||||
}
|
||||
|
||||
public class PlayerStateViewComponentUpdateSystem : UpdateSystem<PlayerStateViewComponent>
|
||||
{
|
||||
protected override void Update(PlayerStateViewComponent self)
|
||||
{
|
||||
self.Update();
|
||||
}
|
||||
}
|
||||
|
||||
public class OnPlayerStageChange : EventSystem<PlayerStateChangeEvent>
|
||||
{
|
||||
protected override void Handler(PlayerStateChangeEvent self)
|
||||
{
|
||||
var stateView = self.Player.GetComponent<PlayerStateViewComponent>();
|
||||
if (stateView != null)
|
||||
{
|
||||
stateView.OnStageChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f48ea2ea6a0e4b38aa97a3fd07f3a6cc
|
||||
timeCreated: 1773060520
|
||||
@@ -24,6 +24,7 @@ namespace NBF
|
||||
{
|
||||
CameraManager.Instance.SetFppLook(Unity);
|
||||
}
|
||||
|
||||
Unity.transform.localPosition = new Vector3(484, 1, 422);
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ namespace NBF
|
||||
private void CreatePlayerModel()
|
||||
{
|
||||
var modelObject = PrefabsHelper.CreatePlayer(Unity.Root, "Human_Male");
|
||||
modelObject.transform.localPosition = Vector3.zero;
|
||||
modelObject.transform.localPosition = new Vector3(0, 1, 0);
|
||||
Unity.ModelAsset = modelObject.GetComponent<PlayerModelAsset>();
|
||||
Unity.ModelAsset.SetPlayer(Unity.FppLook);
|
||||
}
|
||||
|
||||
3
Assets/Scripts/Fishing/New/View/States.meta
Normal file
3
Assets/Scripts/Fishing/New/View/States.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98b05ca000114232a657f19095fdb49a
|
||||
timeCreated: 1773063071
|
||||
@@ -0,0 +1,61 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public abstract class PlayerStageViewBase
|
||||
{
|
||||
public Player Player { get; private set; }
|
||||
public PlayerViewComponent PlayerView { get; private set; }
|
||||
protected float EnterTime { get; set; }
|
||||
|
||||
protected PlayerState PreviousState { get; private set; }
|
||||
protected StateEnterParams Params;
|
||||
|
||||
public void Init(Player player)
|
||||
{
|
||||
Player = player;
|
||||
PlayerView = player.GetComponent<PlayerViewComponent>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查状态超时
|
||||
/// </summary>
|
||||
public void CheckStateTimeout(float time)
|
||||
{
|
||||
if (Time.time - EnterTime >= time)
|
||||
{
|
||||
Player.ChangeState(PlayerState.Idle);
|
||||
}
|
||||
}
|
||||
|
||||
public void Enter(StateEnterParams par = null, PlayerState prevState = PlayerState.None)
|
||||
{
|
||||
Params = par;
|
||||
PreviousState = prevState;
|
||||
EnterTime = Time.time;
|
||||
OnEnter();
|
||||
}
|
||||
|
||||
protected virtual void OnEnter()
|
||||
{
|
||||
}
|
||||
|
||||
public void Exit()
|
||||
{
|
||||
OnExit();
|
||||
}
|
||||
|
||||
protected virtual void OnExit()
|
||||
{
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
OnUpdate();
|
||||
}
|
||||
|
||||
protected virtual void OnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cce89f03f80b4fb8a0e36e66e9ffb3a9
|
||||
timeCreated: 1773063081
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerStageViewFight : PlayerStageViewBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9445a6593604dc19dea2bb8bb0819bc
|
||||
timeCreated: 1773064542
|
||||
@@ -0,0 +1,99 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerStageViewFishing : PlayerStageViewBase
|
||||
{
|
||||
protected override void OnEnter()
|
||||
{
|
||||
Debug.LogError("enter PlayerStateFishing");
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.BaitThrown = true;
|
||||
}
|
||||
|
||||
protected override void OnExit()
|
||||
{
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.BaitThrown = false;
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
PlayerState ret = PlayerState.None;
|
||||
var isUpRod = false;
|
||||
var isSubLine = false;
|
||||
|
||||
if (InputManager.IsOp1)
|
||||
{
|
||||
if (!Player.IsLureRod)
|
||||
{
|
||||
//抬杆
|
||||
isUpRod = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//收线
|
||||
isSubLine = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (InputManager.IsOp2)
|
||||
{
|
||||
if (Player.IsLureRod)
|
||||
{
|
||||
//抬杆
|
||||
isUpRod = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Player.ModelAsset.PlayerAnimator.FishingUp = 0;
|
||||
|
||||
if (isUpRod || PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp > 0)
|
||||
{
|
||||
var upForce = 1;
|
||||
var addNum = upForce * Time.deltaTime;
|
||||
if (!isUpRod)
|
||||
{
|
||||
addNum *= -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
addNum *= 0.5f;
|
||||
}
|
||||
|
||||
// Debug.Log($"addNum={addNum}");
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp += addNum;
|
||||
// Debug.LogError($"ishingFinal={Player.ModelAsset.PlayerAnimator.FishingUp}");
|
||||
if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp >= 1)
|
||||
{
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 1;
|
||||
}
|
||||
else if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp < 0)
|
||||
{
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 0;
|
||||
}
|
||||
|
||||
if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp >= 0.8f)
|
||||
{
|
||||
ret = CheckTackFish();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 0;
|
||||
}
|
||||
|
||||
if (ret != PlayerState.None)
|
||||
{
|
||||
Player.ChangeState(ret);
|
||||
}
|
||||
}
|
||||
|
||||
#region 检查上鱼或者返回待机
|
||||
|
||||
private PlayerState CheckTackFish()
|
||||
{
|
||||
return PlayerState.Idle;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84665b6bc7c84642b365db024c7759fd
|
||||
timeCreated: 1773064529
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerStageViewIdle : PlayerStageViewBase
|
||||
{
|
||||
protected override void OnEnter()
|
||||
{
|
||||
InputManager.OnOp1Action += OnOp1Action;
|
||||
}
|
||||
|
||||
private void OnOp1Action(bool performed)
|
||||
{
|
||||
if (Player.HandItem == null) return;
|
||||
if (performed)
|
||||
{
|
||||
Player.ChangeState(PlayerState.Prepare);
|
||||
// _nextState = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnExit()
|
||||
{
|
||||
InputManager.OnOp1Action -= OnOp1Action;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fca81636d7246e7a5f84684a8563ca3
|
||||
timeCreated: 1773063824
|
||||
@@ -0,0 +1,73 @@
|
||||
using NBC;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerStageViewPrepare : PlayerStageViewBase
|
||||
{
|
||||
public enum Phase
|
||||
{
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// 蓄力
|
||||
/// </summary>
|
||||
Charged,
|
||||
|
||||
/// <summary>
|
||||
/// 确认蓄力结果
|
||||
/// </summary>
|
||||
Confirm,
|
||||
}
|
||||
|
||||
public Phase Stage = Phase.Charged;
|
||||
public float ChargedProgress;
|
||||
|
||||
protected override void OnEnter()
|
||||
{
|
||||
Log.Info("enter PlayerStatePrepare");
|
||||
Stage = Phase.Charged;
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.PrepareThrow = true;
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 0;
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
if (Stage == Phase.Charged)
|
||||
{
|
||||
ThrowPowerCharged();
|
||||
}
|
||||
else if (Stage == Phase.Confirm)
|
||||
{
|
||||
//确认蓄力结果,
|
||||
Debug.Log($"确认蓄力结果,ChargedProgress={ChargedProgress}");
|
||||
var par = new StateEnterParams();
|
||||
par.SetFloat(StateParamsConst.ChargedProgress, ChargedProgress);
|
||||
Player.ChangeState(PlayerState.Throw);
|
||||
Stage = Phase.None;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 蓄力中
|
||||
|
||||
private void ThrowPowerCharged()
|
||||
{
|
||||
if (ChargedProgress < 1)
|
||||
{
|
||||
ChargedProgress += Time.deltaTime;
|
||||
}
|
||||
else if (ChargedProgress > 1)
|
||||
{
|
||||
ChargedProgress = 1;
|
||||
}
|
||||
|
||||
if (!InputManager.IsOp1)
|
||||
{
|
||||
Stage = Phase.Confirm;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77cce716a7f94e0083789eb2953d5f79
|
||||
timeCreated: 1773064499
|
||||
@@ -0,0 +1,75 @@
|
||||
using NBC;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerStageViewThrow : PlayerStageViewBase
|
||||
{
|
||||
private bool _nextState = false;
|
||||
public float ChargedProgress;
|
||||
|
||||
protected override void OnEnter()
|
||||
{
|
||||
Log.Info("enter PlayerStateThrow");
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.StartThrow = true;
|
||||
|
||||
ChargedProgress = 0;
|
||||
if (Params != null)
|
||||
{
|
||||
ChargedProgress = Params.GetFloat(StateParamsConst.ChargedProgress);
|
||||
}
|
||||
|
||||
Debug.Log($"PlayerThrow ChargedProgress={ChargedProgress}");
|
||||
_nextState = false;
|
||||
// Stage = Phase.Waiting;
|
||||
|
||||
// _owner.Gears.Reel?.Unlock();
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
CheckStateTimeout(10);
|
||||
if (_nextState)
|
||||
{
|
||||
// return (uint)PlayerState.Fishing;
|
||||
_nextState = false;
|
||||
Player.ChangeState(PlayerState.Fishing);
|
||||
}
|
||||
}
|
||||
|
||||
// IEnumerator ThrowCoroutine(float distance)
|
||||
// {
|
||||
// float startLength = 0.5f;
|
||||
// Debug.Log($"REST LENGTH : {rope.restLength}");
|
||||
// do
|
||||
// {
|
||||
// float a = Vector3.Distance(rodTipTarget.position, attachedBody.transform.position);
|
||||
// attachedBody.RBody.AddForce(playerForward.Value, ForceMode.VelocityChange);
|
||||
// startLength = Mathf.Max(a, startLength);
|
||||
// UnwindLine(attachedBody.RBody.linearVelocity.magnitude * Time.deltaTime);
|
||||
// yield return null;
|
||||
// }
|
||||
// while ((bool)isBailOpen);
|
||||
// }
|
||||
|
||||
#region 动画回调
|
||||
|
||||
/// <summary>
|
||||
/// 抛竿动画事件
|
||||
/// </summary>
|
||||
public void OnRodThrowStart()
|
||||
{
|
||||
Debug.LogError("OnRodThrowStart");
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.PrepareThrow = false;
|
||||
PlayerView.Unity.ModelAsset.PlayerAnimator.StartThrow = false;
|
||||
}
|
||||
|
||||
public void OnRodThrownEnd()
|
||||
{
|
||||
Debug.LogError("OnRodThrownEnd");
|
||||
_nextState = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 240bbc6c969a4d2e9759ac1df5e6ccf2
|
||||
timeCreated: 1773064512
|
||||
3
Assets/Scripts/Fishing/New/View/Tackle.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Tackle.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 139e43e2a118492c974b67decf15056d
|
||||
timeCreated: 1766477309
|
||||
14
Assets/Scripts/Fishing/New/View/Tackle/FBait.cs
Normal file
14
Assets/Scripts/Fishing/New/View/Tackle/FBait.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FBait : FGearBase
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
var baitConnector = Rod.Hook.hookAsset.baitConnector;
|
||||
transform.position = baitConnector.position;
|
||||
transform.SetParent(baitConnector);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/View/Tackle/FBait.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Tackle/FBait.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed7126c6f37c427e88ba321c63aeac2f
|
||||
timeCreated: 1766582532
|
||||
16
Assets/Scripts/Fishing/New/View/Tackle/FBobber.cs
Normal file
16
Assets/Scripts/Fishing/New/View/Tackle/FBobber.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FBobber : FGearBase
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
// transform.position = Rod.lineHandler.LineConnector_1.transform.position;
|
||||
SetParent(Rod.Line.Bobber.transform);
|
||||
transform.localPosition = Vector3.zero;
|
||||
var buoyancy = GetComponentInParent<CapsuleBuoyancyStable>();
|
||||
buoyancy.InitBobber();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/View/Tackle/FBobber.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Tackle/FBobber.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89060cfcd521410caf2f00ae7ecfa135
|
||||
timeCreated: 1766477995
|
||||
9
Assets/Scripts/Fishing/New/View/Tackle/FFish.cs
Normal file
9
Assets/Scripts/Fishing/New/View/Tackle/FFish.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FFish : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/View/Tackle/FFish.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Tackle/FFish.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d76aeec1876a4df2a93e8e8dcaee30fa
|
||||
timeCreated: 1766586324
|
||||
35
Assets/Scripts/Fishing/New/View/Tackle/FGearBase.cs
Normal file
35
Assets/Scripts/Fishing/New/View/Tackle/FGearBase.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Fantasy;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public abstract class FGearBase : MonoBehaviour
|
||||
{
|
||||
public FRod Rod { get; protected set; }
|
||||
|
||||
public int ConfigId;
|
||||
|
||||
|
||||
public virtual void Init(FRod rod)
|
||||
{
|
||||
Rod = rod;
|
||||
OnInit();
|
||||
}
|
||||
|
||||
public void SetItemConfigId(int id)
|
||||
{
|
||||
ConfigId = id;
|
||||
}
|
||||
|
||||
|
||||
protected void SetParent(Transform parent)
|
||||
{
|
||||
transform.SetParent(parent);
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.localEulerAngles = Vector3.zero;
|
||||
transform.localScale = Vector3.one;
|
||||
}
|
||||
|
||||
protected abstract void OnInit();
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/View/Tackle/FGearBase.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Tackle/FGearBase.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 708753789f5b41f48b9b18197f54a9df
|
||||
timeCreated: 1766582740
|
||||
9
Assets/Scripts/Fishing/New/View/Tackle/FHandItem.cs
Normal file
9
Assets/Scripts/Fishing/New/View/Tackle/FHandItem.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FHandItem : MonoBehaviour
|
||||
{
|
||||
public int ConfigId;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/View/Tackle/FHandItem.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Tackle/FHandItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5460b0f542fd45e38145b2a4fb12e329
|
||||
timeCreated: 1766583615
|
||||
30
Assets/Scripts/Fishing/New/View/Tackle/FHook.cs
Normal file
30
Assets/Scripts/Fishing/New/View/Tackle/FHook.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FHook : FGearBase
|
||||
{
|
||||
public HookAsset hookAsset;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
hookAsset = GetComponent<HookAsset>();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
SetParent(Rod.Line.Lure.transform);
|
||||
transform.localPosition = Vector3.zero;
|
||||
|
||||
// var target = lineHandler.LineConnector_2.GetComponent<Rigidbody>();
|
||||
// var joint = Hook.gameObject.GetComponent<ConfigurableJoint>();
|
||||
// joint.connectedBody = target;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/View/Tackle/FHook.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Tackle/FHook.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b4736177aeb4b70ba352e385554e5ab
|
||||
timeCreated: 1766477615
|
||||
122
Assets/Scripts/Fishing/New/View/Tackle/FLine.cs
Normal file
122
Assets/Scripts/Fishing/New/View/Tackle/FLine.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NBC;
|
||||
// using Obi;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public enum LineType
|
||||
{
|
||||
Hand,
|
||||
HandDouble,
|
||||
Spinning,
|
||||
SpinningFloat,
|
||||
}
|
||||
|
||||
public class FLine : FGearBase
|
||||
{
|
||||
public LineType LineType;
|
||||
|
||||
[SerializeField] private bool isLureConnect;
|
||||
[SerializeField] private RodLine rodLine;
|
||||
[SerializeField] private Rope fishingRope;
|
||||
[SerializeField] private Rope bobberRope;
|
||||
public LureController Lure;
|
||||
public BobberController Bobber;
|
||||
|
||||
|
||||
|
||||
// public event Action OnLinePulled;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
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)
|
||||
{
|
||||
i.gameObject.SetActive(true);
|
||||
});
|
||||
|
||||
StartCoroutine(LureUseGravity());
|
||||
if (isLureConnect)
|
||||
{
|
||||
fishingRope.Init(Rod);
|
||||
}
|
||||
else
|
||||
{
|
||||
fishingRope.Init(Rod);
|
||||
bobberRope.Init(Rod);
|
||||
}
|
||||
|
||||
// rodLine.GenerateLineRendererRope(guides.ToArray(), _LineThickness);
|
||||
}
|
||||
|
||||
public void InitTest(Rigidbody tipRb)
|
||||
{
|
||||
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)
|
||||
{
|
||||
i.gameObject.SetActive(true);
|
||||
});
|
||||
|
||||
StartCoroutine(LureUseGravity());
|
||||
if (isLureConnect)
|
||||
{
|
||||
fishingRope.Init(Rod);
|
||||
}
|
||||
else
|
||||
{
|
||||
fishingRope.Init(Rod);
|
||||
bobberRope.Init(Rod);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator LureUseGravity()
|
||||
{
|
||||
yield return 1;
|
||||
Lure.gameObject.SetActive(false);
|
||||
Lure.gameObject.SetActive(true);
|
||||
yield return 1;
|
||||
Lure.RBody.useGravity = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SetTargetLength(float value)
|
||||
{
|
||||
Log.Error($"SetObiRopeStretch={value}");
|
||||
fishingRope.SetTargetLength(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/View/Tackle/FLine.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Tackle/FLine.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0403ffd74ce46fab8bd4ef057e51432
|
||||
timeCreated: 1766582567
|
||||
194
Assets/Scripts/Fishing/New/View/Tackle/FLineHandler.cs
Normal file
194
Assets/Scripts/Fishing/New/View/Tackle/FLineHandler.cs
Normal file
@@ -0,0 +1,194 @@
|
||||
// using NBF;
|
||||
// using Obi;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// public class FLineHandler : MonoBehaviour
|
||||
// {
|
||||
// public enum LineType
|
||||
// {
|
||||
// None = 0,
|
||||
// OneSegment = 1,
|
||||
// TwoSegment = 2,
|
||||
// ThereSegment = 3
|
||||
// }
|
||||
//
|
||||
// public LineType lineType = LineType.TwoSegment;
|
||||
//
|
||||
// // public ObiParticleAttachment startParticleAttachment;
|
||||
//
|
||||
// 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 LineRenderer LineRenderer1;
|
||||
// public LineRenderer LineRenderer2;
|
||||
//
|
||||
// // 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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 331fde19f47e431092cf5bd57c7bcfe4
|
||||
timeCreated: 1766586159
|
||||
21
Assets/Scripts/Fishing/New/View/Tackle/FLure.cs
Normal file
21
Assets/Scripts/Fishing/New/View/Tackle/FLure.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FLure : FGearBase
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
// 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.Line.Lure.transform);
|
||||
transform.localPosition = Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/View/Tackle/FLure.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Tackle/FLure.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f91ba5f4ca745d4b29fb2116781e25f
|
||||
timeCreated: 1766478011
|
||||
32
Assets/Scripts/Fishing/New/View/Tackle/FReel.cs
Normal file
32
Assets/Scripts/Fishing/New/View/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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/View/Tackle/FReel.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Tackle/FReel.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b48fc45344c5439c9d19897cb5987abf
|
||||
timeCreated: 1766478030
|
||||
341
Assets/Scripts/Fishing/New/View/Tackle/FRod.cs
Normal file
341
Assets/Scripts/Fishing/New/View/Tackle/FRod.cs
Normal file
@@ -0,0 +1,341 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Fantasy;
|
||||
using NBC.Asset;
|
||||
using NBF.Utils;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FRod : FHandItem
|
||||
{
|
||||
private float _tension;
|
||||
|
||||
/// <summary>
|
||||
/// 可用的
|
||||
/// </summary>
|
||||
public bool Usable { get; private set; }
|
||||
|
||||
public RodAsset Asset;
|
||||
|
||||
public FReel Reel;
|
||||
public FHook Hook;
|
||||
public FBobber Bobber;
|
||||
public FBait Bait;
|
||||
public FLure Lure;
|
||||
public FWeight Weight;
|
||||
public FLine Line;
|
||||
|
||||
|
||||
public Transform GearRoot;
|
||||
|
||||
// public FWaterDisplacement LureHookWaterDisplacement;
|
||||
|
||||
[HideInInspector] public FFish currentFish;
|
||||
public RodRingNode[] rings;
|
||||
|
||||
/// <summary>
|
||||
/// 线长度
|
||||
/// </summary>
|
||||
public float lineLength = 1.5f;
|
||||
|
||||
/// <summary>
|
||||
/// 浮漂线长度
|
||||
/// </summary>
|
||||
public float floatLength = 0.5f;
|
||||
|
||||
public float Tension
|
||||
{
|
||||
get => _tension;
|
||||
private set
|
||||
{
|
||||
if (!Mathf.Approximately(_tension, value))
|
||||
{
|
||||
_tension = value;
|
||||
// OnTensionChanged?.Invoke(_tension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Asset = GetComponent<RodAsset>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Alpha0))
|
||||
{
|
||||
SetLineLength(lineLength);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Plus) || Input.GetKeyDown(KeyCode.Equals))
|
||||
{
|
||||
lineLength += 0.1f;
|
||||
SetLineLength(lineLength);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Minus))
|
||||
{
|
||||
lineLength -= 0.1f;
|
||||
SetLineLength(lineLength);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLineLength(float lineLength, bool stretchRope = true)
|
||||
{
|
||||
if (!Line) return;
|
||||
if (Line.LineType == LineType.Spinning)
|
||||
{
|
||||
//没有浮漂类型
|
||||
Line.Lure.SetJointDistance(lineLength);
|
||||
if (stretchRope)
|
||||
{
|
||||
Line.SetTargetLength(Tension > 0f ? 0f : lineLength);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//有浮漂
|
||||
Line.Lure.SetJointDistance(floatLength);
|
||||
Line.Bobber.SetJointDistance(lineLength - floatLength);
|
||||
if (stretchRope)
|
||||
{
|
||||
Line.SetTargetLength(Tension > 0f ? 0f : lineLength - floatLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
Test();
|
||||
}
|
||||
|
||||
public IEnumerator Destroy()
|
||||
{
|
||||
if (GearRoot != null)
|
||||
{
|
||||
Object.Destroy(GearRoot.gameObject);
|
||||
}
|
||||
|
||||
yield return 1;
|
||||
}
|
||||
|
||||
public IEnumerator InitRod(Player player, ItemBindInfo itemBindInfo)
|
||||
{
|
||||
ConfigId = itemBindInfo.Item;
|
||||
// Player = player;
|
||||
|
||||
var playerView = player.GetComponent<PlayerViewComponent>();
|
||||
|
||||
var playerViewUnity = playerView.Unity;
|
||||
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.localRotation = Quaternion.identity;
|
||||
transform.localScale = Vector3.one;
|
||||
SceneSettings.Instance.GearNode.position = playerViewUnity.transform.position;
|
||||
yield return 1;
|
||||
var obj = new GameObject($"rod_{ConfigId}");
|
||||
obj.transform.SetParent(SceneSettings.Instance.GearNode);
|
||||
// obj.transform.SetParent(player.transform);
|
||||
// obj.transform.localPosition = Vector3.zero;
|
||||
obj.transform.position = playerViewUnity.transform.position;
|
||||
obj.transform.rotation = playerViewUnity.transform.rotation;
|
||||
obj.transform.localScale = Vector3.one;
|
||||
GearRoot = obj.transform;
|
||||
|
||||
var parent = GearRoot;
|
||||
|
||||
// List<ItemInfo> children = RoleModel.Instance.GetBindItems(itemInfo.Id);
|
||||
|
||||
|
||||
CreateFishingHandler();
|
||||
yield return 1; //等待1帧
|
||||
// children.Sort();
|
||||
foreach (var childConfigId in itemBindInfo.BindItems)
|
||||
{
|
||||
var itemType = childConfigId.GetItemType();
|
||||
var config = Game.Tables.TbItem.Get(childConfigId);
|
||||
if (itemType == ItemType.Reel)
|
||||
{
|
||||
Reel = config.InstantiateAndComponent<FReel>(Asset.ReelConnector, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Reel.SetItemConfigId(childConfigId);
|
||||
}
|
||||
else if (itemType == ItemType.Bobber)
|
||||
{
|
||||
Bobber = config.InstantiateAndComponent<FBobber>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Bobber.SetItemConfigId(childConfigId);
|
||||
}
|
||||
else if (itemType == ItemType.Hook)
|
||||
{
|
||||
Hook = config.InstantiateAndComponent<FHook>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Hook.SetItemConfigId(childConfigId);
|
||||
}
|
||||
else if (itemType == ItemType.Bait)
|
||||
{
|
||||
Bait = config.InstantiateAndComponent<FBait>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Bait.SetItemConfigId(childConfigId);
|
||||
}
|
||||
else if (itemType == ItemType.Lure)
|
||||
{
|
||||
Lure = config.InstantiateAndComponent<FLure>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Lure.SetItemConfigId(childConfigId);
|
||||
}
|
||||
else if (itemType == ItemType.Weight)
|
||||
{
|
||||
Weight = config.InstantiateAndComponent<FWeight>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Weight.SetItemConfigId(childConfigId);
|
||||
}
|
||||
else if (itemType == ItemType.Line)
|
||||
{
|
||||
// lineItemInfo = 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(this);
|
||||
}
|
||||
|
||||
if (Bobber)
|
||||
{
|
||||
Bobber.Init(this);
|
||||
}
|
||||
|
||||
if (Hook)
|
||||
{
|
||||
Hook.Init(this);
|
||||
}
|
||||
|
||||
if (Bait)
|
||||
{
|
||||
Bait.Init(this);
|
||||
}
|
||||
|
||||
if (Lure)
|
||||
{
|
||||
Lure.Init(this);
|
||||
}
|
||||
|
||||
if (Weight)
|
||||
{
|
||||
Weight.Init(this);
|
||||
}
|
||||
|
||||
yield return 1; //等待1帧
|
||||
|
||||
transform.SetParent(playerViewUnity.ModelAsset.RodRoot);
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.rotation = playerViewUnity.ModelAsset.RodRoot.rotation;
|
||||
|
||||
Usable = true;
|
||||
}
|
||||
|
||||
|
||||
public void CreateFishingHandler()
|
||||
{
|
||||
if (Line == null)
|
||||
{
|
||||
Debug.LogError("创建钓组=====");
|
||||
var itemConfig = Game.Tables.TbItem.Get(ConfigId);
|
||||
var rodType = (ItemSubType)itemConfig.Type;
|
||||
if (rodType == ItemSubType.RodTele)
|
||||
{
|
||||
CreateObiFishingLine(0);
|
||||
}
|
||||
else if (rodType == ItemSubType.RodSpine || rodType == ItemSubType.RodBolo)
|
||||
{
|
||||
CreateObiFishingLine(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void CreateObiFishingLine(int currentLineTypeIndex)
|
||||
{
|
||||
if (!Line)
|
||||
{
|
||||
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[] { "fishing line float set", "fishing line spinning" };
|
||||
var path =
|
||||
$"Assets/ResRaw/Prefabs/Line/{indexNames[currentLineTypeIndex]}.prefab";
|
||||
var prefab = Assets.Load<GameObject>(path);
|
||||
|
||||
GameObject obj = Instantiate(prefab, solver.transform);
|
||||
obj.transform.localPosition = Vector3.zero;
|
||||
obj.transform.localScale = Vector3.one;
|
||||
obj.transform.rotation = Quaternion.identity;
|
||||
|
||||
Line = obj.GetComponent<FLine>();
|
||||
Line.transform.position = Asset.lineConnector.position;
|
||||
Line.Init(this);
|
||||
|
||||
// var obiSolver = solver.GetComponent<ObiSolver>();
|
||||
// obiSolver.parameters.ambientWind = Vector3.zero;
|
||||
// obiSolver.wind.
|
||||
// obiSolver.simulateWhenInvisible
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
private void Test()
|
||||
{
|
||||
// var root = Player.ModelAsset.RodRoot;
|
||||
// if (!root) return;
|
||||
// transform.SetPositionAndRotation(root.position, root.rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/New/View/Tackle/FRod.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Tackle/FRod.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef4dfd89c0c34916be91b55490eb1c9f
|
||||
timeCreated: 1766477316
|
||||
12
Assets/Scripts/Fishing/New/View/Tackle/FWeight.cs
Normal file
12
Assets/Scripts/Fishing/New/View/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/New/View/Tackle/FWeight.cs.meta
Normal file
3
Assets/Scripts/Fishing/New/View/Tackle/FWeight.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a68c58e07092402dbc37a5f287e70b9b
|
||||
timeCreated: 1766582543
|
||||
Reference in New Issue
Block a user