Files
Fishing2/Assets/Scripts/Fishing/Player/AnimatorCtrl/PlayerAnimator.cs
2025-05-17 22:33:16 +08:00

353 lines
11 KiB
C#

using System;
using UnityEngine;
using UnityEngine.Serialization;
namespace NBF
{
public enum ThrowModeEnum : int
{
Spin = 0,
Float = 1,
}
public enum HandItemType
{
Default = 0,
HandRod = 1,
SpinRod = 2,
}
public class PlayerAnimator : MonoBehaviour
{
#region
private static readonly int StartThrowHash = Animator.StringToHash("startThrow");
private static readonly int LureThrownHash = Animator.StringToHash("lureThrown");
private static readonly int PrepareThrowHash = Animator.StringToHash("prepareThrow");
private static readonly int LeftHandHash = Animator.StringToHash("leftHand");
private static readonly int MoveSpeedHash = Animator.StringToHash("moveSpeed");
private static readonly int BoatVelocityHash = Animator.StringToHash("boatVelocity");
private static readonly int BoatDirHash = Animator.StringToHash("boatDir");
private static readonly int BoatHash = Animator.StringToHash("boat");
private static readonly int CastingHash = Animator.StringToHash("casting");
private static readonly int TelestickHash = Animator.StringToHash("telestick");
private static readonly int TelestickPullHash = Animator.StringToHash("telestick_pull");
private static readonly int UseRodPodHash = Animator.StringToHash("use_rod_pod");
private static readonly int ItemSourceHash = Animator.StringToHash("item_source");
private static readonly int ItemDestHash = Animator.StringToHash("item_dest");
private static readonly int RodReadyHash = Animator.StringToHash("rod_ready");
private static readonly int HitchRecoverDirHash = Animator.StringToHash("hitchRecoverDir");
private static readonly int HitchRecoverHash = Animator.StringToHash("hitchRecover");
private static readonly int SitOrStandHash = Animator.StringToHash("sitOrStand");
private static readonly int ShtekerHash = Animator.StringToHash("shteker");
private static readonly int ItemInHandsHash = Animator.StringToHash("item_in_hands");
private static readonly int ChangeItemHash = Animator.StringToHash("change_item");
private static readonly int ItemTypeHash = Animator.StringToHash("item_type");
private static readonly int ItemActionHash = Animator.StringToHash("item_action");
private static readonly int ItemActionPowerHash = Animator.StringToHash("item_action_power");
private static readonly int PodsakActionHash = Animator.StringToHash("podsak_action");
private static readonly int FishingFinalHash = Animator.StringToHash("fishing_final");
private static readonly int SpinOrTeleHash = Animator.StringToHash("spin_or_tele");
private static readonly int TwitchHash = Animator.StringToHash("twitch");
private static readonly int TwitchDirHash = Animator.StringToHash("twitch_dir");
private static readonly int ThrowSpeedMultHash = Animator.StringToHash("throw_speed_mult");
private static readonly int ConvTestHash = Animator.StringToHash("conv_test");
private static readonly int BoatPoseHash = Animator.StringToHash("boat_pose");
private static readonly int QuadDirectionHash = Animator.StringToHash("quad_direction");
private static readonly int StretchMaxHash = Animator.StringToHash("stretch_max");
private static readonly int ExamineItemHash = Animator.StringToHash("examine_item");
private static readonly int TillerDirectionHash = Animator.StringToHash("tiller_direction");
private static readonly int TestTriggerHash = Animator.StringToHash("test_trigger");
private static readonly int ThrowModeHash = Animator.StringToHash("throw_mode");
private static readonly int PullUpRodHash = Animator.StringToHash("pull_up_rod");
public bool StartThrow
{
get => animator.GetBool(StartThrowHash);
set => animator.SetBool(StartThrowHash, value);
}
public bool LureThrown
{
get => animator.GetBool(LureThrownHash);
set => animator.SetBool(LureThrownHash, value);
}
public bool PrepareThrow
{
get => animator.GetBool(PrepareThrowHash);
set => animator.SetBool(PrepareThrowHash, value);
}
public bool LeftHand
{
get => animator.GetBool(LeftHandHash);
set => animator.SetBool(LeftHandHash, value);
}
public float MoveSpeed
{
get => animator.GetFloat(MoveSpeedHash);
set => animator.SetFloat(MoveSpeedHash, value);
}
public float BoatVelocity
{
get => animator.GetFloat(BoatVelocityHash);
set => animator.SetFloat(BoatVelocityHash, value);
}
public float BoatDir
{
get => animator.GetFloat(BoatDirHash);
set => animator.SetFloat(BoatDirHash, value);
}
public bool Boat
{
get => animator.GetBool(BoatHash);
set => animator.SetBool(BoatHash, value);
}
public bool Casting
{
get => animator.GetBool(CastingHash);
set => animator.SetBool(CastingHash, value);
}
public bool Telestick
{
get => animator.GetBool(TelestickHash);
set => animator.SetBool(TelestickHash, value);
}
public bool TelestickPull
{
get => animator.GetBool(TelestickPullHash);
set => animator.SetBool(TelestickPullHash, value);
}
public bool UseRodPod
{
get => animator.GetBool(UseRodPodHash);
set => animator.SetBool(UseRodPodHash, value);
}
public int ItemSource
{
get => animator.GetInteger(ItemSourceHash);
set => animator.SetInteger(ItemSourceHash, value);
}
public int ItemDest
{
get => animator.GetInteger(ItemDestHash);
set => animator.SetInteger(ItemDestHash, value);
}
public bool RodReady
{
get => animator.GetBool(RodReadyHash);
set => animator.SetBool(RodReadyHash, value);
}
public float HitchRecoverDir
{
get => animator.GetFloat(HitchRecoverDirHash);
set => animator.SetFloat(HitchRecoverDirHash, value);
}
public void SetHitchRecoverTrigger()
{
animator.SetTrigger(HitchRecoverHash);
}
public void ResetHitchRecoverTrigger()
{
animator.ResetTrigger(HitchRecoverHash);
}
public float SitOrStand
{
get => animator.GetFloat(SitOrStandHash);
set => animator.SetFloat(SitOrStandHash, value);
}
public bool Shteker
{
get => animator.GetBool(ShtekerHash);
set => animator.SetBool(ShtekerHash, value);
}
public bool ItemInHands
{
get => animator.GetBool(ItemInHandsHash);
set => animator.SetBool(ItemInHandsHash, value);
}
public bool ChangeItem
{
get => animator.GetBool(ChangeItemHash);
set => animator.SetBool(ChangeItemHash, value);
}
public HandItemType ItemType
{
get => (HandItemType)animator.GetInteger(ItemTypeHash);
set => animator.SetInteger(ItemTypeHash, (int)value);
}
public void SetItemActionTrigger()
{
animator.SetTrigger(ItemActionHash);
}
public void ResetItemActionTrigger()
{
animator.ResetTrigger(ItemActionHash);
}
public float ItemActionPower
{
get => animator.GetFloat(ItemActionPowerHash);
set => animator.SetFloat(ItemActionPowerHash, value);
}
public bool PodsakAction
{
get => animator.GetBool(PodsakActionHash);
set => animator.SetBool(PodsakActionHash, value);
}
public bool PullUpRod
{
get => animator.GetBool(PullUpRodHash);
set => animator.SetBool(PullUpRodHash, value);
}
public float FishingFinal
{
get => animator.GetFloat(FishingFinalHash);
set => animator.SetFloat(FishingFinalHash, value);
}
public float SpinOrTele
{
get => animator.GetFloat(SpinOrTeleHash);
set => animator.SetFloat(SpinOrTeleHash, value);
}
public void SetTwitchTrigger()
{
animator.SetTrigger(TwitchHash);
}
public void ResetTwitchTrigger()
{
animator.ResetTrigger(TwitchHash);
}
public float TwitchDir
{
get => animator.GetFloat(TwitchDirHash);
set => animator.SetFloat(TwitchDirHash, value);
}
public float ThrowSpeedMult
{
get => animator.GetFloat(ThrowSpeedMultHash);
set => animator.SetFloat(ThrowSpeedMultHash, value);
}
public void SetConvTestTrigger()
{
animator.SetTrigger(ConvTestHash);
}
public void ResetConvTestTrigger()
{
animator.ResetTrigger(ConvTestHash);
}
public int BoatPose
{
get => animator.GetInteger(BoatPoseHash);
set => animator.SetInteger(BoatPoseHash, value);
}
public float QuadDirection
{
get => animator.GetFloat(QuadDirectionHash);
set => animator.SetFloat(QuadDirectionHash, value);
}
public bool StretchMax
{
get => animator.GetBool(StretchMaxHash);
set => animator.SetBool(StretchMaxHash, value);
}
public void SetExamineItemTrigger()
{
animator.SetTrigger(ExamineItemHash);
}
public void ResetExamineItemTrigger()
{
animator.ResetTrigger(ExamineItemHash);
}
public float TillerDirection
{
get => animator.GetFloat(TillerDirectionHash);
set => animator.SetFloat(TillerDirectionHash, value);
}
public void SetTestTrigger()
{
animator.SetTrigger(TestTriggerHash);
}
public void ResetTestTrigger()
{
animator.ResetTrigger(TestTriggerHash);
}
public ThrowModeEnum ThrowMode
{
get
{
var val = animator.GetInteger(ThrowModeHash);
return (ThrowModeEnum)val;
}
set => animator.SetInteger(ThrowModeHash, (int)value);
}
#endregion
public FPlayer Player;
public Animator animator;
private void Awake()
{
animator = GetComponent<Animator>();
}
#region
/// <summary>
/// 抛竿开始
/// </summary>
public void RodForceThrowStart()
{
if (Player.Fsm.CurrentState is PlayerThrow playerThrow)
{
playerThrow.RodForceThrowStart();
}
}
#endregion
}
}