大修改调整
This commit is contained in:
145
Assets/Scripts/Fishing/Player/States/PlayerStateThrow.cs
Normal file
145
Assets/Scripts/Fishing/Player/States/PlayerStateThrow.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user