修改动画回调事件

This commit is contained in:
2026-03-11 09:06:24 +08:00
parent 1f1c603489
commit 40b142235e
9 changed files with 145 additions and 96 deletions

View File

@@ -0,0 +1,15 @@
using Fantasy.Event;
namespace NBF
{
public class OnPlayerItemRodLingChangeEvent: EventSystem<PlayerItemRodLingChangeEvent>
{
protected override void Handler(PlayerItemRodLingChangeEvent self)
{
var itemView = self.Item.GetComponent<PlayerItemView>();
itemView.Rod.SetLineLength();
// var view = self.Player.GetOrAddComponent<PlayerView>();
// view.ChangeItem(self).Coroutine();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 308a4c63d4da4a5e83db7426790c9b6e
timeCreated: 1773155866

View File

@@ -85,7 +85,7 @@ namespace NBF
_IK = GetComponent<PlayerIK>();
_isInit = true;
}
public void OnUnUseItem()
{
@@ -152,10 +152,14 @@ namespace NBF
/// </summary>
public void OnRodThrowStart()
{
// if (Player.State is PlayerStateThrow playerStateThrow)
// {
// playerStateThrow.OnRodThrowStart();
// }
if (Player.State == PlayerState.Throw)
{
var playerStateView = Player.GetComponent<PlayerStateView>();
if (playerStateView.CurrentStateView is PlayerStageViewThrow playerStateThrow)
{
playerStateThrow.OnRodThrowStart();
}
}
}
/// <summary>
@@ -163,10 +167,14 @@ namespace NBF
/// </summary>
public void OnRodThrownEnd()
{
// if (Player.Fsm.CurrentState is PlayerStateThrow playerStateThrow)
// {
// playerStateThrow.OnRodThrownEnd();
// }
if (Player.State == PlayerState.Throw)
{
var playerStateView = Player.GetComponent<PlayerStateView>();
if (playerStateView.CurrentStateView is PlayerStageViewThrow playerStateThrow)
{
playerStateThrow.OnRodThrownEnd();
}
}
}
#endregion

View File

@@ -16,6 +16,8 @@ namespace NBF
private PlayerStageViewBase _currentStateView;
private Player _player;
public PlayerStageViewBase CurrentStateView => _currentStateView;
public void Awake()
{
_player = GetParent<Player>();

View File

@@ -3,6 +3,36 @@ using UnityEngine;
namespace NBF
{
public enum PlayerState : uint
{
None = 0,
/// <summary>
/// 闲置等待中
/// </summary>
Idle = 1,
/// <summary>
/// 准备抛竿
/// </summary>
Prepare = 2,
/// <summary>
/// 抛竿中
/// </summary>
Throw = 3,
/// <summary>
/// 钓鱼中
/// </summary>
Fishing = 4,
/// <summary>
/// 溜鱼中
/// </summary>
Fight = 5
}
public abstract class PlayerStageViewBase
{
public Player Player { get; private set; }

View File

@@ -12,17 +12,10 @@ namespace NBF
{
public class FRod : FHandItem
{
private float _tension;
public PlayerItem PlayerItem;
public override int ConfigId => PlayerItem?.ConfigID ?? 0;
/// <summary>
/// 可用的
/// </summary>
public bool Usable { get; private set; }
public RodAsset Asset;
public FReel Reel;
@@ -41,29 +34,6 @@ namespace NBF
[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()
{
@@ -72,42 +42,43 @@ namespace NBF
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);
}
// 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);
// }
// SetLineLength();
}
public void SetLineLength(float lineLength, bool stretchRope = true)
public void SetLineLength()
{
if (!Line) return;
if (Line.LineType == LineType.Spinning)
{
//没有浮漂类型
Line.Lure.SetJointDistance(lineLength);
if (stretchRope)
Line.Lure.SetJointDistance(PlayerItem.LineLength);
if (PlayerItem.StretchRope)
{
Line.SetTargetLength(Tension > 0f ? 0f : lineLength);
Line.SetTargetLength(PlayerItem.Tension > 0f ? 0f : PlayerItem.LineLength);
}
}
else
{
//有浮漂
Line.Lure.SetJointDistance(floatLength);
Line.Bobber.SetJointDistance(lineLength - floatLength);
if (stretchRope)
Line.Lure.SetJointDistance(PlayerItem.FloatLength);
Line.Bobber.SetJointDistance(PlayerItem.LineLength - PlayerItem.FloatLength);
if (PlayerItem.StretchRope)
{
Line.SetTargetLength(Tension > 0f ? 0f : lineLength - floatLength);
Line.SetTargetLength(PlayerItem.Tension > 0f ? 0f : PlayerItem.LineLength - PlayerItem.FloatLength);
}
}
}
@@ -204,6 +175,7 @@ namespace NBF
}
await FTask.WaitFrame(playerView.Scene); //等待1帧
SetLineLength();
if (Reel)
{
Reel.reelingDrag = 0.699f;
@@ -243,8 +215,6 @@ namespace NBF
transform.SetParent(playerViewUnity.ModelAsset.RodRoot);
transform.localPosition = Vector3.zero;
transform.rotation = playerViewUnity.ModelAsset.RodRoot.rotation;
Usable = true;
}