This commit is contained in:
Bob.Song
2026-03-10 16:03:38 +08:00
parent 228de2445d
commit cf2e374998
86 changed files with 478 additions and 383 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 958b50133e064daf9764313f24b892da
timeCreated: 1773069791

View File

@@ -0,0 +1,13 @@
using Fantasy.Event;
namespace NBF.Handle
{
public class OnPlayerStateChangeEvent : EventSystem<PlayerItemChangeEvent>
{
protected override void Handler(PlayerItemChangeEvent self)
{
var view = self.Player.GetOrAddComponent<PlayerView>();
view.ChangeItem(self).Coroutine();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b5897acb7a6e40fcb3123362df1669f3
timeCreated: 1773069799

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1f9c361f2958454abb43724693a2157a
timeCreated: 1773116527

View File

@@ -0,0 +1,20 @@
using Fantasy.Async;
using UnityEngine;
namespace NBF
{
public class PlayerItemRodView : PlayerItemView
{
public RodAsset RodAsset;
public override async FTask InitShow(PlayerItem item)
{
Item = item;
var itemConfig = Game.Tables.TbItem.Get(Item.ConfigID);
RodAsset = itemConfig.InstantiateAndComponent<RodAsset>(SceneSettings.Instance.GearNode, Vector3.zero,
Quaternion.identity);
// await Rod.InitRod(Item);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 77390e0ed53847f3b190ffc0d9f1319a
timeCreated: 1773124629

View File

@@ -0,0 +1,27 @@
using Fantasy.Async;
using Fantasy.Entitas;
using UnityEngine;
namespace NBF
{
/// <summary>
/// 玩家物品视图组件
/// </summary>
public abstract class PlayerItemView : Entity
{
public PlayerItem Item { get; protected set; }
public abstract FTask InitShow(PlayerItem item);
// public async FTask InitShow()
// {
// // Item = GetParent<PlayerItem>();
// var itemConfig = Game.Tables.TbItem.Get(Item.ConfigID);
// // Rod = itemConfig.InstantiateAndComponent<FRod>(SceneSettings.Instance.GearNode, Vector3.zero,
// // Quaternion.identity);
//
// // await Rod.InitRod(Item);
// }
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 98838cf2cf934b8aaaf97f4d58544055
timeCreated: 1773116536

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c38d17daa1164359ad9f9466be692b7c
timeCreated: 1773038185

View File

@@ -0,0 +1,174 @@
using System;
using KINEMATION.MagicBlend.Runtime;
using NBC;
using NBF.Utils;
using UnityEngine;
namespace NBF
{
public class PlayerAnimator : PlayerMonoBehaviour
{
public Animator _Animator;
private bool _isRodLayerEnabled;
private bool _isInit;
private PlayerIK _IK;
private MagicBlending _magicBlending;
private bool _IsInVehicle;
#region
// public static readonly int IsSwiming = Animator.StringToHash("Swim");
//
// public static readonly int ThrowFar = Animator.StringToHash("ThrowFar");
//
// public static readonly int BoatDriving = Animator.StringToHash("BoatDriving");
//
// public static readonly int BaitInWater = Animator.StringToHash("BaitInWater");
//
// public static readonly int HeldRod = Animator.StringToHash("HeldRod");
//
// public static readonly int RodArming = Animator.StringToHash("RodArming");
public static readonly int Forward = Animator.StringToHash("Forward");
public static readonly int Turn = Animator.StringToHash("Turn");
public static readonly int OnGroundHash = Animator.StringToHash("OnGround");
public static readonly int PrepareThrowHash = Animator.StringToHash("PrepareThrow");
public static readonly int StartThrowHash = Animator.StringToHash("StartThrow");
public static readonly int BaitThrownHash = Animator.StringToHash("BaitThrown");
private static readonly int FishingUpHash = Animator.StringToHash("FishingUp");
public static readonly string LureRodLayer = "LureRod";
public static readonly string HandRodLayer = "HandRod";
public float FishingUp
{
get => _Animator.GetFloat(FishingUpHash);
set => _Animator.SetFloat(FishingUpHash, value);
}
public bool OnGround
{
get => _Animator.GetBool(OnGroundHash);
set => _Animator.SetBool(OnGroundHash, value);
}
public bool StartThrow
{
get => _Animator.GetBool(StartThrowHash);
set => _Animator.SetBool(StartThrowHash, value);
}
public bool BaitThrown
{
get => _Animator.GetBool(BaitThrownHash);
set => _Animator.SetBool(BaitThrownHash, value);
}
public bool PrepareThrow
{
get => _Animator.GetBool(PrepareThrowHash);
set => _Animator.SetBool(PrepareThrowHash, value);
}
#endregion
protected override void OnAwake()
{
_magicBlending = GetComponent<MagicBlending>();
_Animator = GetComponent<Animator>();
_Animator.keepAnimatorStateOnDisable = true;
_IK = GetComponent<PlayerIK>();
_isInit = true;
}
public void OnUnUseItem()
{
_isRodLayerEnabled = false;
}
public void OnUseItem(PlayerItemView item)
{
var itemType = item.Item.ConfigID.GetItemType();
if (itemType == ItemType.Rod)
{
_isRodLayerEnabled = true;
// _IK.SetBipedLeftHandIK(enabled: false, reel.FingersIKAnchor);
}
}
public void SetLayerWeight(string layer, float weight)
{
_Animator.SetLayerWeight(_Animator.GetLayerIndex(layer), weight);
}
private void LateUpdate()
{
{
float value3 = Mathf.Lerp(_Animator.GetFloat(Forward), Player.Speed / 5f,
Time.deltaTime * 20f);
float value4 = Mathf.Lerp(_Animator.GetFloat(Turn), Player.RotationSpeed,
Time.deltaTime * 15f);
_Animator.SetFloat(Forward, Mathf.Clamp01(value3));
_Animator.SetFloat(Turn, Mathf.Clamp(value4, -1f, 1f));
}
_Animator.SetBool(OnGroundHash, _IsInVehicle || Player.IsGrounded);
var isHandRodLayerEnabled = _isRodLayerEnabled && !Player.IsLureRod ? 1 : 0;
float handRodLayerWeight = _Animator.GetLayerWeight(_Animator.GetLayerIndex(HandRodLayer));
SetLayerWeight(HandRodLayer,
Mathf.MoveTowards(handRodLayerWeight, isHandRodLayerEnabled, Time.deltaTime * 3f));
var isLureRodLayerEnabled = _isRodLayerEnabled && Player.IsLureRod ? 1 : 0;
float lureRodLayerWeight = _Animator.GetLayerWeight(_Animator.GetLayerIndex(LureRodLayer));
SetLayerWeight(LureRodLayer,
Mathf.MoveTowards(lureRodLayerWeight, isLureRodLayerEnabled, Time.deltaTime * 3f));
}
#region
/// <summary>
/// 抬杆到底动画事件
/// </summary>
public void OnRodPowerUp()
{
}
/// <summary>
/// 开始抛出动画事件
/// </summary>
public void OnRodThrowStart()
{
// if (Player.State is PlayerStateThrow playerStateThrow)
// {
// playerStateThrow.OnRodThrowStart();
// }
}
/// <summary>
/// 抛竿结束动画事件
/// </summary>
public void OnRodThrownEnd()
{
// if (Player.Fsm.CurrentState is PlayerStateThrow playerStateThrow)
// {
// playerStateThrow.OnRodThrownEnd();
// }
}
#endregion
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0fc336a939c4416db623f3b4ae855265
timeCreated: 1766470716

View File

@@ -0,0 +1,29 @@
using System;
using RootMotion.FinalIK;
using UnityEngine;
namespace NBF
{
public class PlayerArm : PlayerMonoBehaviour
{
public bool FixLowerArm;
public bool IsLeft;
public LimbIK IK;
public Transform LowerArm;
public Transform RodContainer;
public FingerRig FingerRig;
[HideInInspector] public float interactionTargetWeight;
private const int MaxFixEyeAngle = 15;
protected override void OnAwake()
{
}
private void LateUpdate()
{
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 01ef40348d8b4d4da250acf0a921fc2a
timeCreated: 1768660096

View File

@@ -0,0 +1,24 @@
using UnityEngine;
namespace NBF
{
public class PlayerChest : PlayerMonoBehaviour
{
private const int MaxFixEyeAngle = 15;
private const int MinFixEyeAngle = -10;
private void LateUpdate()
{
FixArmAngle();
}
private void FixArmAngle()
{
var angle = Player.EyeAngle;
if (angle > MaxFixEyeAngle) angle = MaxFixEyeAngle;
else if (angle < MinFixEyeAngle) angle = MinFixEyeAngle;
var val = transform.localEulerAngles;
transform.localEulerAngles = new Vector3(val.x, val.y, val.z - angle);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e152a74e74b54d17ace5403a1570e12a
timeCreated: 1768668096

View File

@@ -0,0 +1,58 @@
using System;
using RootMotion.FinalIK;
using UnityEngine;
namespace NBF
{
public class PlayerIK : PlayerMonoBehaviour
{
public enum UpdateType
{
Update = 0,
FixedUpdate = 1,
LateUpdate = 2,
Default = 3
}
public UpdateType UpdateSelected;
private LookAtIK _LookAtIK;
[SerializeField] private float transitionWeightTimeScale = 1f;
protected override void OnAwake()
{
_LookAtIK = GetComponent<LookAtIK>();
}
private void Update()
{
if (UpdateSelected == UpdateType.Update)
{
IKUpdateHandler();
}
}
private void FixedUpdate()
{
if (UpdateSelected == UpdateType.FixedUpdate)
{
IKUpdateHandler();
}
}
private void LateUpdate()
{
if (UpdateSelected == UpdateType.LateUpdate)
{
IKUpdateHandler();
}
}
private void IKUpdateHandler()
{
_LookAtIK.UpdateSolverExternal();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cb36ecc5b1784d948837600cf18808cd
timeCreated: 1765121426

View File

@@ -0,0 +1,22 @@
using UnityEngine;
namespace NBF
{
public abstract class PlayerMonoBehaviour : MonoBehaviour
{
public Player Player { get; private set; }
public PlayerUnityComponent UnityComponent { get; private set; }
protected void Awake()
{
UnityComponent = GetComponentInParent<PlayerUnityComponent>();
Player = UnityComponent.Player;
OnAwake();
}
protected virtual void OnAwake()
{
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7fbde40efe5345cd8c05ea6c1f1914cf
timeCreated: 1773040970

View File

@@ -0,0 +1,25 @@
using ECM2;
using ECM2.Examples.FirstPerson;
using UnityEngine;
namespace NBF
{
public class PlayerUnityComponent : MonoBehaviour
{
public Player Player { get; set; }
public Transform Root;
public Transform Eye;
public Transform FppLook;
public Transform IK;
public PlayerModelAsset ModelAsset;
public CharacterMovement Character;
public FirstPersonCharacter FirstPerson;
[Header("视角相关")] public float MouseSensitivity = 0.1f;
[Space(15f)] public bool invertLook = true;
public float minPitch = -60f;
public float maxPitch = 60f;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a25908f34e4e4464a922b88337a5b733
timeCreated: 1773038189

View File

@@ -0,0 +1,200 @@
using Fantasy;
using Fantasy.Entitas;
using Fantasy.Entitas.Interface;
using UnityEngine;
using UnityEngine.InputSystem;
using Log = NBC.Log;
namespace NBF
{
public class PlayerInput : Entity
{
public Player Player { get; private set; }
public PlayerView View { get; private set; }
#region
public class PlayerViewAwakeSystem : AwakeSystem<PlayerInput>
{
protected override void Awake(PlayerInput self)
{
self.Player = self.GetParent<Player>();
self.View = self.Player.GetComponent<PlayerView>();
self.AddInputEvent();
}
}
public class PlayerViewUpdateSystem : UpdateSystem<PlayerInput>
{
protected override void Update(PlayerInput self)
{
self.UpdateMove();
}
}
public class PlayerViewDestroySystem : DestroySystem<PlayerInput>
{
protected override void Destroy(PlayerInput self)
{
self.RemoveInputEvent();
}
}
#endregion
#region Input
private void AddInputEvent()
{
InputManager.OnPlayerPerformed += OnPlayerCanceled;
InputManager.OnPlayerPerformed += OnPlayerPerformed;
InputManager.OnPlayerValueCanceled += OnPlayerValueCanceled;
InputManager.OnPlayerValuePerformed += OnPlayerValuePerformed;
}
private void RemoveInputEvent()
{
InputManager.OnPlayerPerformed += OnPlayerCanceled;
InputManager.OnPlayerPerformed += OnPlayerPerformed;
InputManager.OnPlayerValueCanceled += OnPlayerValueCanceled;
InputManager.OnPlayerValuePerformed += OnPlayerValuePerformed;
}
private void OnPlayerPerformed(string action)
{
if (action == InputDef.Player.Run)
{
Player.Run = true;
}
}
private void OnPlayerCanceled(string action)
{
if (action == InputDef.Player.Run)
{
Player.Run = false;
}
else if (action == InputDef.Player.ToBag)
{
//取消手持物品
Log.Info($"取消手持物品");
Player.UnUseItem();
// Game.Instance.StartCoroutine(UnUseItem());
}
else if (action.StartsWith(InputDef.Player.QuickStarts))
{
var index = int.Parse(action.Replace(InputDef.Player.QuickStarts, string.Empty));
Log.Info($"快速使用===={index}");
var item = RoleModel.Instance.GetSlotItem(index - 1);
if (item != null)
{
Player.UseItem(item);
}
}
}
private void OnPlayerValueCanceled(InputAction.CallbackContext context)
{
var actionName = context.action.name;
if (actionName == InputDef.Player.Move)
{
Player.MoveInput = Vector2.zero;
}
}
private void OnPlayerValuePerformed(InputAction.CallbackContext context)
{
var actionName = context.action.name;
if (actionName == InputDef.Player.Move)
{
var v2 = context.ReadValue<Vector2>();
Player.MoveInput = v2;
}
else if (actionName == InputDef.Player.Look)
{
}
}
#endregion
#region Move
private Quaternion _lastRotation;
private void UpdateMove()
{
UpdateGrounded();
ProcessMoveStates();
UpdateLookInput();
}
private void ProcessMoveStates()
{
{
var num2 = Player.Run ? 7 : 5;
Vector3 vector2 = View.Unity.FirstPerson.GetRightVector() * Player.MoveInput.x * num2;
vector2 += View.Unity.FirstPerson.GetForwardVector() * Player.MoveInput.y * num2;
// if (checkWaterBound)
// {
// SetMovementDirectionWithRaycastCheck(vector2);
// }
// else
{
View.Unity.FirstPerson.SetMovementDirection(vector2);
}
}
}
private void UpdateGrounded()
{
Player.IsGrounded = View.Unity.FirstPerson.IsGrounded();
Player.Speed = View.Unity.FirstPerson.velocity.magnitude;
Quaternion rotation = View.Unity.FirstPerson.transform.rotation;
// 计算当前帧与上一帧的旋转差异
Quaternion rotationDelta = rotation * Quaternion.Inverse(_lastRotation);
// 将四元数转换为角度轴表示
rotationDelta.ToAngleAxis(out float angle, out Vector3 axis);
// 确保角度在0-360范围内
if (angle > 180f) angle -= 360f;
// 获取Y轴旋转分量归一化处理
float yRotation = 0f;
if (Mathf.Abs(angle) > 0.001f && Mathf.Abs(axis.y) > 0.1f)
{
// 计算Y轴方向的旋转角度考虑旋转轴方向
yRotation = angle * Mathf.Sign(axis.y);
}
float maxTurnSpeed = 180f; // 度/秒
// 转换为角速度并归一化到[-1, 1]
float angularSpeed = yRotation / Time.deltaTime;
float turnValue = Mathf.Clamp(angularSpeed / maxTurnSpeed, -1f, 1f);
Player.RotationSpeed = turnValue;
_lastRotation = rotation;
}
#endregion
#region Look
private void UpdateLookInput()
{
Vector2 value = InputManager.GetLookInput();
var u3d = View.Unity;
u3d.FirstPerson.AddControlYawInput(value.x * u3d.MouseSensitivity);
u3d.FirstPerson.AddControlPitchInput((u3d.invertLook ? 0f - value.y : value.y) * u3d.MouseSensitivity,
u3d.minPitch, u3d.maxPitch);
}
#endregion
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2d74cb6e741243478aeb0a3053211fcd
timeCreated: 1773039193

View 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 PlayerStateView : 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<PlayerStateView>
{
protected override void Awake(PlayerStateView self)
{
self.Awake();
}
}
public class PlayerStateViewComponentUpdateSystem : UpdateSystem<PlayerStateView>
{
protected override void Update(PlayerStateView self)
{
self.Update();
}
}
public class OnPlayerStageChange : EventSystem<PlayerStateChangeEvent>
{
protected override void Handler(PlayerStateChangeEvent self)
{
var stateView = self.Player.GetComponent<PlayerStateView>();
if (stateView != null)
{
stateView.OnStageChange();
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f48ea2ea6a0e4b38aa97a3fd07f3a6cc
timeCreated: 1773060520

View File

@@ -0,0 +1,150 @@
using Fantasy.Async;
using Fantasy.Entitas;
using Fantasy.Entitas.Interface;
using NBF.Fishing2;
using NBF.Utils;
using UnityEngine;
namespace NBF
{
public class PlayerView : Entity
{
public Player Player { get; private set; }
public PlayerUnityComponent Unity { get; private set; }
#region
public void Awake()
{
Player = GetParent<Player>();
var gameObject = PrefabsHelper.CreatePlayer(SceneSettings.Instance.Node);
Unity = gameObject.GetComponent<PlayerUnityComponent>();
Unity.Player = Player;
CreatePlayerModel();
if (Player.IsSelf)
{
CameraManager.Instance.SetFppLook(Unity);
}
Unity.transform.localPosition = new Vector3(484, 1, 422);
}
public void Update()
{
}
public void LateUpdate()
{
Player.EyeAngle = GameUtils.GetVerticalAngle(Unity.transform, Unity.FppLook);
}
public void Destroy()
{
}
#endregion
#region
private void CreatePlayerModel()
{
var modelObject = PrefabsHelper.CreatePlayer(Unity.Root, "Human_Male");
modelObject.transform.localPosition = new Vector3(0, 1, 0);
Unity.ModelAsset = modelObject.GetComponent<PlayerModelAsset>();
Unity.ModelAsset.SetPlayer(Unity.FppLook);
}
#endregion
#region
public async FTask ChangeItem(PlayerItemChangeEvent playerStateChangeEvent)
{
var prevItem = playerStateChangeEvent.PrevItem;
var currItem = playerStateChangeEvent.Item;
if (Player.IsChangeItemIng) return;
Player.IsChangeItemIng = true;
if (currItem == null)
{
//收起物品
await UnUseItem(prevItem);
}
else
{
// 先收起旧的物品
await UnUseItemConfirm(prevItem);
var handItem = Player.HandItem;
//拿起新物品
var itemType = handItem.ConfigID.GetItemType();
if (itemType == ItemType.Rod)
{
var itemView = handItem.GetOrAddComponent<PlayerItemRodView>();
await itemView.InitShow(handItem);
Unity.ModelAsset.PlayerAnimator.OnUseItem(itemView);
}
}
Player.IsChangeItemIng = false;
}
#region 使
public async FTask UnUseItem(PlayerItem item)
{
if (item == null) return;
if (Player.IsChangeItemIng) return;
Player.IsChangeItemIng = true;
await UnUseItemConfirm(item);
Player.IsChangeItemIng = false;
}
private async FTask UnUseItemConfirm(PlayerItem item)
{
if (item != null)
{
Unity.ModelAsset.PlayerAnimator.OnUnUseItem();
await FTask.Wait(Scene, 100);
}
Player.ReleaseItem(item);
await FTask.Wait(Scene, 450);
}
#endregion
#endregion
}
public class PlayerViewAwakeSystem : AwakeSystem<PlayerView>
{
protected override void Awake(PlayerView self)
{
self.Awake();
}
}
public class PlayerViewDestroySystem : DestroySystem<PlayerView>
{
protected override void Destroy(PlayerView self)
{
self.Destroy();
}
}
public class PlayerViewUpdateSystem : UpdateSystem<PlayerView>
{
protected override void Update(PlayerView self)
{
self.Update();
}
}
public class PlayerViewLateUpdateSystem : LateUpdateSystem<PlayerView>
{
protected override void LateUpdate(PlayerView self)
{
self.LateUpdate();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 418da378516646cdb672fa05c2066432
timeCreated: 1773037811

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 98b05ca000114232a657f19095fdb49a
timeCreated: 1773063071

View File

@@ -0,0 +1,61 @@
using UnityEngine;
namespace NBF
{
public abstract class PlayerStageViewBase
{
public Player Player { get; private set; }
public PlayerView 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<PlayerView>();
}
/// <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()
{
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cce89f03f80b4fb8a0e36e66e9ffb3a9
timeCreated: 1773063081

View File

@@ -0,0 +1,6 @@
namespace NBF
{
public class PlayerStageViewFight : PlayerStageViewBase
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a9445a6593604dc19dea2bb8bb0819bc
timeCreated: 1773064542

View File

@@ -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
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 84665b6bc7c84642b365db024c7759fd
timeCreated: 1773064529

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1fca81636d7246e7a5f84684a8563ca3
timeCreated: 1773063824

View File

@@ -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
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 77cce716a7f94e0083789eb2953d5f79
timeCreated: 1773064499

View File

@@ -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
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 240bbc6c969a4d2e9759ac1df5e6ccf2
timeCreated: 1773064512

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 139e43e2a118492c974b67decf15056d
timeCreated: 1766477309

View 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);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ed7126c6f37c427e88ba321c63aeac2f
timeCreated: 1766582532

View 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();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 89060cfcd521410caf2f00ae7ecfa135
timeCreated: 1766477995

View File

@@ -0,0 +1,9 @@
using UnityEngine;
namespace NBF
{
public class FFish : MonoBehaviour
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d76aeec1876a4df2a93e8e8dcaee30fa
timeCreated: 1766586324

View 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();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 708753789f5b41f48b9b18197f54a9df
timeCreated: 1766582740

View File

@@ -0,0 +1,9 @@
using UnityEngine;
namespace NBF
{
public class FHandItem : MonoBehaviour
{
public int ConfigId;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5460b0f542fd45e38145b2a4fb12e329
timeCreated: 1766583615

View 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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0b4736177aeb4b70ba352e385554e5ab
timeCreated: 1766477615

View 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);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c0403ffd74ce46fab8bd4ef057e51432
timeCreated: 1766582567

View 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);
// }
// }
// }
// }

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 331fde19f47e431092cf5bd57c7bcfe4
timeCreated: 1766586159

View 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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3f91ba5f4ca745d4b29fb2116781e25f
timeCreated: 1766478011

View 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()
{
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b48fc45344c5439c9d19897cb5987abf
timeCreated: 1766478030

View File

@@ -0,0 +1,343 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Fantasy;
using Fantasy.Async;
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 async FTask InitRod(PlayerItem playerItem)
{
// ConfigId = itemBindInfo.Item;
// // Player = player;
//
// var playerView = player.GetComponent<PlayerView>();
//
// 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);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ef4dfd89c0c34916be91b55490eb1c9f
timeCreated: 1766477316

View File

@@ -0,0 +1,12 @@
using UnityEngine;
namespace NBF
{
public class FWeight : FGearBase
{
protected override void OnInit()
{
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a68c58e07092402dbc37a5f287e70b9b
timeCreated: 1766582543