using NBC;
using UnityEngine;
namespace NBF
{
///
/// 抛竿中
///
public class PlayerStateThrow : PlayerStateBase
{
public override uint StateId => (uint)PlayerState.Throw;
public enum Phase
{
///
/// 等待动画事件回调
///
Waiting,
///
/// 前摇动画
///
AnimBegin,
///
/// 抛线动画
///
ThrowAnim,
///
/// 结束
///
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 动画回调
///
/// 抛竿动画事件
///
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
}
}