59 lines
1.3 KiB
C#
59 lines
1.3 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace NBF
|
|
{
|
|
public class FPlayerData : MonoService<FPlayerData>
|
|
{
|
|
private PlayerState _previousPlayerState = PlayerState.idle;
|
|
private PlayerState _playerState;
|
|
|
|
public bool ChangeItem;
|
|
public bool Run;
|
|
public bool IsGrounded;
|
|
public float Speed;
|
|
public float RotationSpeed;
|
|
public float ReelSpeed;
|
|
public float LineTension;
|
|
|
|
/// <summary>
|
|
/// 是否路亚竿
|
|
/// </summary>
|
|
public bool IsLureRod;
|
|
|
|
public Vector2 MoveInput;
|
|
|
|
|
|
public PlayerState PreviousState => _previousPlayerState;
|
|
|
|
public PlayerState State
|
|
{
|
|
get => _playerState;
|
|
set
|
|
{
|
|
_previousPlayerState = _playerState;
|
|
_playerState = value;
|
|
NextState = value;
|
|
OnStateChange?.Invoke(_playerState);
|
|
}
|
|
}
|
|
|
|
[SerializeField] private PlayerState NextState;
|
|
|
|
public event Action<PlayerState> OnStateChange;
|
|
|
|
|
|
private void Start()
|
|
{
|
|
NextState = State;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (NextState != State)
|
|
{
|
|
State = NextState;
|
|
}
|
|
}
|
|
}
|
|
} |