Files
Fishing2/Assets/Scripts/Fishing/Player/States/PlayerStateThrow.cs
2026-01-11 23:58:02 +08:00

145 lines
3.7 KiB
C#

using NBC;
using UnityEngine;
namespace NBF
{
/// <summary>
/// 抛竿中
/// </summary>
public class PlayerStateThrow : PlayerStateBase
{
public override uint StateId => (uint)PlayerState.Throw;
public enum Phase
{
/// <summary>
/// 等待动画事件回调
/// </summary>
Waiting,
/// <summary>
/// 前摇动画
/// </summary>
AnimBegin,
/// <summary>
/// 抛线动画
/// </summary>
ThrowAnim,
/// <summary>
/// 结束
/// </summary>
Done,
ErrorDone
}
public Phase Stage = Phase.Waiting;
public float ChargedProgress;
protected override void onEnter()
{
_owner.ModelAsset.PlayerAnimator.StartThrow = true;
ChargedProgress = (float)Params.Get(0);
Debug.Log($"PlayerThrow ChargedProgress={ChargedProgress}");
Stage = Phase.Waiting;
// _owner.Gears.Reel?.Unlock();
}
protected override uint onUpdate()
{
CheckStateTimeout(10);
if (Stage == Phase.AnimBegin)
{
AnimBegin();
ThrowPosition();
}
else if (Stage == Phase.ThrowAnim)
{
ThrowAnim();
}
else if (Stage == Phase.Done)
{
return (uint)PlayerState.Fishing;
}
else if (Stage == Phase.ErrorDone)
{
return (uint)PlayerState.Idle;
}
return base.onUpdate();
}
#region
/// <summary>
/// 抛竿动画事件
/// </summary>
public void RodForceThrowStart()
{
// Debug.LogError($"RodForceThrowStart==");
_owner.ModelAsset.PlayerAnimator.PrepareThrow = false;
_owner.ModelAsset.PlayerAnimator.StartThrow = false;
Stage = Phase.AnimBegin;
}
#endregion
#region 线
private void AnimBegin()
{
_owner.ModelAsset.PlayerAnimator.PrepareThrow = false;
_owner.ModelAsset.PlayerAnimator.StartThrow = false;
_owner.ModelAsset.PlayerAnimator.BaitThrown = true;
Stage = Phase.ThrowAnim;
}
#endregion
#region 竿线
private NTask _throwAnim;
private void ThrowPosition()
{
// if (_owner.PlayerAnimatorCtrl.ThrowMode == ThrowModeEnum.Float)
// {
// _owner.Gears.Rod.lineHandler.pinchController?.ReleasePinch();
// _throwAnim = new BobThrowAnim(_owner);
// _throwAnim.Run(DefRunner.Scheduler);
// }
// else
// {
// _throwAnim = new LureThrowAnim(_owner);
// _throwAnim.Run(DefRunner.Scheduler);
// }
}
private void ThrowAnim()
{
if (_throwAnim.IsDone)
{
// if (_throwAnim.Status == NTaskStatus.Success)
// {
// if (_owner.PlayerAnimatorCtrl.ThrowMode == ThrowModeEnum.Spin)
// {
// SetArm();
// }
//
// Stage = Phase.Done;
// Debug.LogError($"抛线后,线长度={_owner.Data.lineLength}");
// }
// else
// {
// Stage = Phase.ErrorDone;
// }
}
}
#endregion
}
}