大修改调整
This commit is contained in:
@@ -18,36 +18,62 @@ namespace NBF
|
||||
|
||||
#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 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 OnGround = Animator.StringToHash("OnGround");
|
||||
|
||||
public static readonly int RodRight = Animator.StringToHash("rod right");
|
||||
|
||||
public static readonly int RodForward = Animator.StringToHash("rod forward");
|
||||
|
||||
public static readonly int PreciseCast = Animator.StringToHash("Precise Cast");
|
||||
|
||||
public static readonly int PreciseIdle = Animator.StringToHash("Precise Idle");
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -64,6 +90,7 @@ namespace NBF
|
||||
Player.Data.OnStateChange += PlayerFSMState_OnValueChanged;
|
||||
}
|
||||
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Player.OnFishingSetEquiped -= OnFishingSetEquiped_OnRaised;
|
||||
@@ -78,21 +105,6 @@ namespace NBF
|
||||
_IK.SetBipedLeftHandIK(enabled: false, null);
|
||||
}
|
||||
|
||||
private void OnCastLure()
|
||||
{
|
||||
Player.Data.State = PlayerState.baitFlies;
|
||||
// SFXGameManagement.PlaySound("Cast Fishing Rod", base.transform);
|
||||
}
|
||||
|
||||
private void OnBailUnnarm()
|
||||
{
|
||||
// if (IsThrowButtonPressed.Value)
|
||||
// {
|
||||
// _Animator.SetBool(ThrowFar, value: true);
|
||||
// Player.Data.State = PlayerState.casting;
|
||||
// OnBailOpen?.Invoke();
|
||||
// }
|
||||
}
|
||||
|
||||
private void OnFishingSetEquiped_OnRaised(FHandItem item)
|
||||
{
|
||||
@@ -107,16 +119,6 @@ namespace NBF
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayAnimation(string state, string layer)
|
||||
{
|
||||
_Animator.CrossFade(state, 0.3f, _Animator.GetLayerIndex(layer));
|
||||
}
|
||||
|
||||
public void PlayPreciseCastAnimation()
|
||||
{
|
||||
_Animator.SetBool(PreciseIdle, value: false);
|
||||
_Animator.SetTrigger(PreciseCast);
|
||||
}
|
||||
|
||||
public void SetLayerWeight(string layer, float weight)
|
||||
{
|
||||
@@ -125,94 +127,119 @@ namespace NBF
|
||||
|
||||
private void PlayerFSMState_OnValueChanged(PlayerState state)
|
||||
{
|
||||
switch (Player.Data.PreviousState)
|
||||
{
|
||||
case PlayerState.vehicle:
|
||||
_IsInVehicle = false;
|
||||
_Animator.SetBool(BoatDriving, value: false);
|
||||
break;
|
||||
case PlayerState.swiming:
|
||||
_Animator.SetBool(IsSwiming, value: false);
|
||||
break;
|
||||
case PlayerState.preciseCastIdle:
|
||||
_Animator.SetBool(PreciseIdle, value: false);
|
||||
break;
|
||||
case PlayerState.prepare:
|
||||
_Animator.SetBool(RodArming, value: false);
|
||||
break;
|
||||
case PlayerState.casting:
|
||||
_Animator.SetBool(ThrowFar, value: false);
|
||||
break;
|
||||
case PlayerState.collectFish:
|
||||
_magicBlending.BlendAsset.globalWeight = 0f;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case PlayerState.idle:
|
||||
case PlayerState.move:
|
||||
_Animator.SetBool(BaitInWater, value: false);
|
||||
_Animator.SetBool(HeldRod, value: false);
|
||||
_Animator.SetBool(ThrowFar, value: false);
|
||||
_Animator.SetBool(RodArming, value: false);
|
||||
break;
|
||||
case PlayerState.prepare:
|
||||
_Animator.SetBool(RodArming, value: true);
|
||||
_Animator.SetBool(HeldRod, value: true);
|
||||
break;
|
||||
case PlayerState.fishing:
|
||||
_Animator.SetBool(HeldRod, value: true);
|
||||
_Animator.SetBool(BaitInWater, value: true);
|
||||
break;
|
||||
case PlayerState.vehicle:
|
||||
_Animator.SetBool(BaitInWater, value: false);
|
||||
_Animator.SetBool(HeldRod, value: false);
|
||||
_Animator.SetBool(ThrowFar, value: false);
|
||||
_Animator.SetBool(RodArming, value: false);
|
||||
_Animator.SetBool(BoatDriving, value: true);
|
||||
_IK.SetBipedLeftHandIK(enabled: true);
|
||||
_IsInVehicle = true;
|
||||
break;
|
||||
case PlayerState.vehicleFishing:
|
||||
_Animator.SetBool(BaitInWater, value: false);
|
||||
_Animator.SetBool(HeldRod, value: false);
|
||||
_Animator.SetBool(ThrowFar, value: false);
|
||||
_Animator.SetBool(RodArming, value: false);
|
||||
_IsInVehicle = true;
|
||||
break;
|
||||
case PlayerState.swiming:
|
||||
_Animator.SetBool(IsSwiming, value: true);
|
||||
break;
|
||||
case PlayerState.collectFish:
|
||||
_Animator.SetBool(BaitInWater, value: false);
|
||||
_IK.SetAimIK(enabled: false);
|
||||
_magicBlending.BlendAsset.globalWeight = 1f;
|
||||
break;
|
||||
case PlayerState.preciseCastIdle:
|
||||
_Animator.SetBool(PreciseIdle, value: true);
|
||||
break;
|
||||
case PlayerState.casting:
|
||||
case PlayerState.baitFlies:
|
||||
case PlayerState.fight:
|
||||
case PlayerState.fishView:
|
||||
case PlayerState.throwFish:
|
||||
case PlayerState.flyModeDebug:
|
||||
break;
|
||||
}
|
||||
// switch (Player.Data.PreviousState)
|
||||
// {
|
||||
// case PlayerState.vehicle:
|
||||
// _IsInVehicle = false;
|
||||
// _Animator.SetBool(BoatDriving, value: false);
|
||||
// break;
|
||||
// case PlayerState.swiming:
|
||||
// _Animator.SetBool(IsSwiming, value: false);
|
||||
// break;
|
||||
// case PlayerState.preciseCastIdle:
|
||||
// _Animator.SetBool(PreciseIdle, value: false);
|
||||
// break;
|
||||
// case PlayerState.prepare:
|
||||
// _Animator.SetBool(RodArming, value: false);
|
||||
// break;
|
||||
// case PlayerState.casting:
|
||||
// _Animator.SetBool(ThrowFar, value: false);
|
||||
// break;
|
||||
// case PlayerState.collectFish:
|
||||
// _magicBlending.BlendAsset.globalWeight = 0f;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// switch (state)
|
||||
// {
|
||||
// switch (Player.Data.PreviousState)
|
||||
// {
|
||||
// case PlayerState.vehicle:
|
||||
// _IsInVehicle = false;
|
||||
// _Animator.SetBool(BoatDriving, value: false);
|
||||
// break;
|
||||
// case PlayerState.swiming:
|
||||
// _Animator.SetBool(IsSwiming, value: false);
|
||||
// break;
|
||||
// case PlayerState.preciseCastIdle:
|
||||
// _Animator.SetBool(PreciseIdle, value: false);
|
||||
// break;
|
||||
// case PlayerState.prepare:
|
||||
// _Animator.SetBool(RodArming, value: false);
|
||||
// break;
|
||||
// case PlayerState.casting:
|
||||
// _Animator.SetBool(ThrowFar, value: false);
|
||||
// break;
|
||||
// case PlayerState.collectFish:
|
||||
// _magicBlending.BlendAsset.globalWeight = 0f;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// switch (state)
|
||||
// {
|
||||
// case PlayerState.idle:
|
||||
// case PlayerState.move:
|
||||
// _Animator.SetBool(BaitInWater, value: false);
|
||||
// _Animator.SetBool(HeldRod, value: false);
|
||||
// _Animator.SetBool(ThrowFar, value: false);
|
||||
// _Animator.SetBool(RodArming, value: false);
|
||||
// break;
|
||||
// case PlayerState.prepare:
|
||||
// _Animator.SetBool(RodArming, value: true);
|
||||
// _Animator.SetBool(HeldRod, value: true);
|
||||
// break;
|
||||
// case PlayerState.fishing:
|
||||
// _Animator.SetBool(HeldRod, value: true);
|
||||
// _Animator.SetBool(BaitInWater, value: true);
|
||||
// break;
|
||||
// case PlayerState.vehicle:
|
||||
// _Animator.SetBool(BaitInWater, value: false);
|
||||
// _Animator.SetBool(HeldRod, value: false);
|
||||
// _Animator.SetBool(ThrowFar, value: false);
|
||||
// _Animator.SetBool(RodArming, value: false);
|
||||
// _Animator.SetBool(BoatDriving, value: true);
|
||||
// _IK.SetBipedLeftHandIK(enabled: true);
|
||||
// _IsInVehicle = true;
|
||||
// break;
|
||||
// case PlayerState.vehicleFishing:
|
||||
// _Animator.SetBool(BaitInWater, value: false);
|
||||
// _Animator.SetBool(HeldRod, value: false);
|
||||
// _Animator.SetBool(ThrowFar, value: false);
|
||||
// _Animator.SetBool(RodArming, value: false);
|
||||
// _IsInVehicle = true;
|
||||
// break;
|
||||
// case PlayerState.swiming:
|
||||
// _Animator.SetBool(IsSwiming, value: true);
|
||||
// break;
|
||||
// case PlayerState.collectFish:
|
||||
// _Animator.SetBool(BaitInWater, value: false);
|
||||
// _IK.SetAimIK(enabled: false);
|
||||
// _magicBlending.BlendAsset.globalWeight = 1f;
|
||||
// break;
|
||||
// case PlayerState.preciseCastIdle:
|
||||
// _Animator.SetBool(PreciseIdle, value: true);
|
||||
// break;
|
||||
// case PlayerState.casting:
|
||||
// case PlayerState.baitFlies:
|
||||
// case PlayerState.fight:
|
||||
// case PlayerState.fishView:
|
||||
// case PlayerState.throwFish:
|
||||
// case PlayerState.flyModeDebug:
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (Player.Data.State == PlayerState.swiming)
|
||||
{
|
||||
float value = Mathf.Lerp(_Animator.GetFloat(Forward), Player.Data.Speed / 2.5f,
|
||||
Time.deltaTime * 5f);
|
||||
float value2 = Mathf.Lerp(_Animator.GetFloat(Turn), Player.Data.RotationSpeed, Time.deltaTime * 5f);
|
||||
_Animator.SetFloat(Forward, Mathf.Clamp01(value));
|
||||
_Animator.SetFloat(Turn, Mathf.Clamp(value2, -1f, 1f));
|
||||
}
|
||||
else
|
||||
// if (Player.Data.State == PlayerState.swiming)
|
||||
// {
|
||||
// float value = Mathf.Lerp(_Animator.GetFloat(Forward), Player.Data.Speed / 2.5f,
|
||||
// Time.deltaTime * 5f);
|
||||
// float value2 = Mathf.Lerp(_Animator.GetFloat(Turn), Player.Data.RotationSpeed, Time.deltaTime * 5f);
|
||||
// _Animator.SetFloat(Forward, Mathf.Clamp01(value));
|
||||
// _Animator.SetFloat(Turn, Mathf.Clamp(value2, -1f, 1f));
|
||||
// }
|
||||
// else
|
||||
{
|
||||
float value3 = Mathf.Lerp(_Animator.GetFloat(Forward), Player.Data.Speed / 5f,
|
||||
Time.deltaTime * 20f);
|
||||
@@ -221,16 +248,14 @@ namespace NBF
|
||||
_Animator.SetFloat(Turn, Mathf.Clamp(value4, -1f, 1f));
|
||||
}
|
||||
|
||||
var rod = Vector3.zero;
|
||||
if (Player.Rod)
|
||||
{
|
||||
rod = Player.Rod.transform.position;
|
||||
}
|
||||
// var rod = Vector3.zero;
|
||||
// if (Player.Rod)
|
||||
// {
|
||||
// rod = Player.Rod.transform.position;
|
||||
// }
|
||||
|
||||
_Animator.SetBool(OnGroundHash, _IsInVehicle || Player.Data.IsGrounded);
|
||||
|
||||
_Animator.SetBool(OnGround, _IsInVehicle || Player.Data.IsGrounded);
|
||||
_Animator.SetFloat(RodRight, rod.x);
|
||||
_Animator.SetFloat(RodForward, rod.y);
|
||||
|
||||
|
||||
var isHandRodLayerEnabled = _isRodLayerEnabled && !Player.Data.IsLureRod ? 1 : 0;
|
||||
|
||||
@@ -244,5 +269,30 @@ namespace NBF
|
||||
SetLayerWeight(LureRodLayer,
|
||||
Mathf.MoveTowards(lureRodLayerWeight, isLureRodLayerEnabled, Time.deltaTime * 3f));
|
||||
}
|
||||
|
||||
#region 动画事件
|
||||
|
||||
/// <summary>
|
||||
/// 抬杆到底动画事件
|
||||
/// </summary>
|
||||
public void OnRodPowerUp()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始抛出动画事件
|
||||
/// </summary>
|
||||
public void OnRodThrowStart()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 抛竿结束动画事件
|
||||
/// </summary>
|
||||
public void OnRodThrownEnd()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user