using System; using System.Text; using cfg; using UnityEngine; namespace NBF { public enum GearType { SpinningFloat = 0, Spinning = 1, Hand = 2, Feeder = 3, Pole = 4 } [Serializable] public enum PlayerState : uint { None = 0, /// /// 闲置等待中 /// Idle = 1, /// /// 准备抛竿 /// Prepare = 2, /// /// 抛竿中 /// Throw = 3, /// /// 钓鱼中 /// Fishing = 4, /// /// 溜鱼中 /// Fight = 5 } [Serializable] public class FPlayerData : MonoService { public int PlayerID; /// /// 玩家当前装备的钓组 /// public FPlayerGearData currentGear; /// /// 玩家位置 /// public Vector3 position; /// /// 玩家角度 /// public Quaternion rotation; public float currentReelingSpeed; public bool isHandOnHandle; /// /// 线长度 /// public float lineLength; /// /// 收线速度 /// public float reelSpeed; /// /// 打开手电筒 /// public bool openLight; /// /// 打开望远镜 /// public bool openTelescope; public float EyeAngle; public bool Run; public bool ChangeItem; public bool IsLureRod; /// /// 是否地面 /// public bool IsGrounded; /// /// 移动速度 /// public float Speed; public float RotationSpeed; public Vector2 MoveInput; public SelectorRodSetting selectorRodSetting = SelectorRodSetting.Speed; private PlayerState _previousPlayerState = PlayerState.Idle; private PlayerState _playerState; 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 OnStateChange; private void Start() { NextState = State; } private void Update() { if (NextState != State) { State = NextState; } } } /// /// 玩家钓组数据 /// [Serializable] public class FPlayerGearData { public GearType Type = GearType.Spinning; public FRodData rod; public FReelData reel; public FBobberData bobber; public FHookData hook; public FBaitData bait; public FLureData lure; public FWeightData weight; public FLineData line; public FLeaderData leader; public FFeederData feeder; /// /// 获得唯一id /// /// public int GetUnitId() { int result = 0; if (rod != null) { result += rod.configId; } if (reel != null) { result += reel.configId; } if (bobber != null) { result += bobber.configId; } if (hook != null) { result += hook.configId; } if (bait != null) { result += bait.configId; } if (lure != null) { result += lure.configId; } if (weight != null) { result += weight.configId; } if (line != null) { result += line.configId; } if (leader != null) { result += leader.configId; } if (feeder != null) { result += feeder.configId; } return result; } public void SetBobberLastSetGroundValue(float value) { bobber.lastSetGroundValue = value; } public void SetReelSettings(int setType, float val, bool saveToPrefs = false) { if (setType == 0) { reel.currentSpeed = val; } if (setType == 1) { reel.currentDrag = val; } if (saveToPrefs) { // Instance._playerData.SaveEquipment(ItemType.Reel); } } } [Serializable] public abstract class FGearData { /// /// 唯一id /// public int id; /// /// 配置id /// public int configId; private Item _itemConfig; public Item ItemConfig { get { return _itemConfig ??= Game.Tables.TbItem.Get(configId); } } } /// /// 鱼竿数据 /// [Serializable] public class FRodData : FGearData { private Rod _config; public Rod Config { get { return _config ??= Game.Tables.TbRod.Get(configId); } } } /// /// 线轴数据 /// [Serializable] public class FReelData : FGearData { private Reel _config; public Reel Config { get { return _config ??= Game.Tables.TbReel.Get(configId); } } public float currentSpeed = 0.5f; public float currentDrag = 0.7f; } /// /// 浮漂数据 /// [Serializable] public class FBobberData : FGearData { private Bobber _config; public Bobber Config { get { return _config ??= Game.Tables.TbBobber.Get(configId); } } public float lastSetGroundValue; } /// /// 鱼钩数据 /// [Serializable] public class FHookData : FGearData { private Hook _config; public Hook Config { get { return _config ??= Game.Tables.TbHook.Get(configId); } } } /// /// 鱼饵数据 /// [Serializable] public class FBaitData : FGearData { private Bait _config; public Bait Config { get { return _config ??= Game.Tables.TbBait.Get(configId); } } } /// /// 鱼饵数据 /// [Serializable] public class FLureData : FGearData { private Lure _config; public Lure Config { get { return _config ??= Game.Tables.TbLure.Get(configId); } } } /// /// 沉子数据 /// [Serializable] public class FWeightData : FGearData { } /// /// 线数据 /// [Serializable] public class FLineData : FGearData { private Line _config; public Line Config { get { return _config ??= Game.Tables.TbLine.Get(configId); } } } /// /// 引线数据 /// [Serializable] public class FLeaderData : FGearData { // private Leader _config; // // public Leader Config // { // get { return _config ??= Game.Tables.TbLeader.Get(configId); } // } } /// /// 菲德数据 /// [Serializable] public class FFeederData : FGearData { private Feeder _config; public Feeder Config { get { return _config ??= Game.Tables.TbFeeder.Get(configId); } } } }