diff --git a/.com-unity-codely.json b/.com-unity-codely.json index 4de79c0e1..765c38310 100644 --- a/.com-unity-codely.json +++ b/.com-unity-codely.json @@ -1,9 +1,9 @@ { "unity_port": 25916, "created_date": "2026-02-10T01:48:10.3375388Z", - "project_path": "D:/myself/Fishing2/Assets", + "project_path": "D:/myself/Games/Fishing2/Assets", "reloading": false, "reason": "ready", "seq": 1, - "last_heartbeat": "2026-03-09T09:50:14.4988583Z" + "last_heartbeat": "2026-03-09T15:41:07.6469285Z" } \ No newline at end of file diff --git a/Assets/AssetCaches.asset b/Assets/AssetCaches.asset index 702d3a0a8..ec686c9c8 100644 --- a/Assets/AssetCaches.asset +++ b/Assets/AssetCaches.asset @@ -18658,8 +18658,53 @@ MonoBehaviour: - {fileID: 102900000, guid: aa3f5467c0c153642ac320466aee0ec1, type: 3} FilterEnum: 0 Filter: '*' - - Path: Assets/ResRaw/Prefabs/Line/LineHand1.prefab - Address: Plyaer/LineHand1 + - Path: Assets/ResRaw/Prefabs/Line/FishingRopeLong.asset + Address: Plyaer/FishingRopeLong + Type: Missing + Bundle: main/plyaer.bundle + Tags: + Group: + Name: Plyaer + Enable: 1 + BundleMode: 0 + AddressMode: 2 + Tags: + Collectors: + - {fileID: 102900000, guid: aa3f5467c0c153642ac320466aee0ec1, type: 3} + FilterEnum: 0 + Filter: '*' + - Path: Assets/ResRaw/Prefabs/Line/FishingRopeLong2.asset + Address: Plyaer/FishingRopeLong2 + Type: Missing + Bundle: main/plyaer.bundle + Tags: + Group: + Name: Plyaer + Enable: 1 + BundleMode: 0 + AddressMode: 2 + Tags: + Collectors: + - {fileID: 102900000, guid: aa3f5467c0c153642ac320466aee0ec1, type: 3} + FilterEnum: 0 + Filter: '*' + - Path: Assets/ResRaw/Prefabs/Line/FishingRopeShort.asset + Address: Plyaer/FishingRopeShort + Type: Missing + Bundle: main/plyaer.bundle + Tags: + Group: + Name: Plyaer + Enable: 1 + BundleMode: 0 + AddressMode: 2 + Tags: + Collectors: + - {fileID: 102900000, guid: aa3f5467c0c153642ac320466aee0ec1, type: 3} + FilterEnum: 0 + Filter: '*' + - Path: Assets/ResRaw/Prefabs/Line/Float (4).prefab + Address: Plyaer/Float (4) Type: GameObject Bundle: main/plyaer.bundle Tags: @@ -18688,6 +18733,36 @@ MonoBehaviour: - {fileID: 102900000, guid: aa3f5467c0c153642ac320466aee0ec1, type: 3} FilterEnum: 0 Filter: '*' + - Path: Assets/ResRaw/Prefabs/Line/RopeSegment_4.asset + Address: Plyaer/RopeSegment_4 + Type: Missing + Bundle: main/plyaer.bundle + Tags: + Group: + Name: Plyaer + Enable: 1 + BundleMode: 0 + AddressMode: 2 + Tags: + Collectors: + - {fileID: 102900000, guid: aa3f5467c0c153642ac320466aee0ec1, type: 3} + FilterEnum: 0 + Filter: '*' + - Path: Assets/ResRaw/Prefabs/Line/Spool.mat + Address: Plyaer/Spool + Type: Material + Bundle: main/plyaer.bundle + Tags: + Group: + Name: Plyaer + Enable: 1 + BundleMode: 0 + AddressMode: 2 + Tags: + Collectors: + - {fileID: 102900000, guid: aa3f5467c0c153642ac320466aee0ec1, type: 3} + FilterEnum: 0 + Filter: '*' - Path: Assets/ResRaw/Prefabs/Player/Anim/AnimationClip/CameraCrouch.anim Address: Plyaer/CameraCrouch Type: AnimationClip diff --git a/Assets/Scripts/Fishing/Data/LocalDataManager.cs b/Assets/Scripts/Fishing/Data/LocalDataManager.cs deleted file mode 100644 index 8209703e9..000000000 --- a/Assets/Scripts/Fishing/Data/LocalDataManager.cs +++ /dev/null @@ -1,94 +0,0 @@ -// // 新文件:D:\myself\Fishing2\Assets\Scripts\Fishing\Data\LocalDataManager.cs -// -// using System.Collections.Generic; -// using UnityEngine; -// -// namespace NBF -// { -// /// -// /// 本地单机模式的数据管理器(模拟服务器转发) -// /// -// public class LocalDataManager : PlayerDataManager -// { -// public override bool IsLocalMode => true; -// -// private Dictionary _localPlayers = new(); -// private uint _sequenceCounter; -// -// protected void Awake() -// { -// Instance = this; -// } -// -// public void RegisterPlayer(FPlayerData player) -// { -// if (!_localPlayers.ContainsKey(player.PlayerID)) -// { -// _localPlayers.Add(player.PlayerID, player); -// player.IsLocalPlayer = true; -// } -// } -// -// public override void OnPlayerStateChanged(FPlayerData player, PlayerState newState) -// { -// // 本地模式下,广播给其他本地玩家(分屏) -// foreach (var kvp in _localPlayers) -// { -// if (kvp.Value != player) -// { -// // 直接应用状态(或者加入简单的延迟模拟) -// kvp.Value.State = newState; -// } -// } -// } -// -// public override void OnHeldItemChanged(FPlayerData player, HeldItemInfo newItem) -// { -// foreach (var kvp in _localPlayers) -// { -// if (kvp.Value != player) -// { -// kvp.Value.CurrentHeldItem = newItem; -// } -// } -// } -// -// public override void SendStateSnapshot(FPlayerData player) -// { -// _sequenceCounter++; -// var snapshot = player.ToNetworkSnapshot(_sequenceCounter); -// -// // 本地广播 -// foreach (var kvp in _localPlayers) -// { -// if (kvp.Value != player) -// { -// ReceiveStateSnapshot(kvp.Key, snapshot); -// } -// } -// } -// -// public override void ReceiveStateSnapshot(int playerID, PlayerStateSnapshot snapshot) -// { -// if (_localPlayers.TryGetValue(playerID, out var player)) -// { -// player.ApplyFromNetworkSnapshot(snapshot); -// } -// } -// -// // 定时同步(例如每秒 10 次) -// private float _syncTimer; -// private void Update() -// { -// _syncTimer += Time.deltaTime; -// if (_syncTimer >= 0.1f) // 10Hz -// { -// _syncTimer = 0; -// foreach (var player in _localPlayers.Values) -// { -// SendStateSnapshot(player); -// } -// } -// } -// } -// } diff --git a/Assets/Scripts/Fishing/Data/LocalDataManager.cs.meta b/Assets/Scripts/Fishing/Data/LocalDataManager.cs.meta deleted file mode 100644 index 7c4676e83..000000000 --- a/Assets/Scripts/Fishing/Data/LocalDataManager.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: ec2bd63eb6c143fdb528da693a8c6969 -timeCreated: 1773028161 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Data/NetworkDataManager.cs b/Assets/Scripts/Fishing/Data/NetworkDataManager.cs deleted file mode 100644 index 3a458bab0..000000000 --- a/Assets/Scripts/Fishing/Data/NetworkDataManager.cs +++ /dev/null @@ -1,60 +0,0 @@ -// using UnityEngine; -// -// namespace NBF -// { -// /// -// /// 网络模式的数据管理器 -// /// -// public class NetworkDataManager : PlayerDataManager -// { -// public override bool IsLocalMode => false; -// -// // TODO: 这里集成你的网络库(Steamworks、Photon、Mirror 等) -// // public SteamNetworkClient NetworkClient; -// -// protected void Awake() -// { -// Instance = this; -// } -// -// public override void OnPlayerStateChanged(FPlayerData player, PlayerState newState) -// { -// // 如果是本地玩家,发送到服务器 -// if (player.IsLocalPlayer) -// { -// SendStateSnapshot(player); -// } -// } -// -// public override void OnHeldItemChanged(FPlayerData player, HeldItemInfo newItem) -// { -// if (player.IsLocalPlayer) -// { -// // TODO: 发送物品切换消息到服务器 -// Debug.Log($"发送物品切换:{newItem.ItemType}, ConfigID={newItem.ConfigID}"); -// } -// } -// -// public override void SendStateSnapshot(FPlayerData player) -// { -// if (!player.IsLocalPlayer) return; -// -// // TODO: 通过 Steam 或其他网络库发送 -// // NetworkClient.SendStateSnapshot(player.ToNetworkSnapshot()); -// } -// -// public override void ReceiveStateSnapshot(int playerID, PlayerStateSnapshot snapshot) -// { -// // TODO: 从网络接收其他玩家的状态 -// // 找到或创建对应的玩家对象 -// var player = FindOrCreatePlayer(playerID); -// player.ApplyFromNetworkSnapshot(snapshot); -// } -// -// private FPlayerData FindOrCreatePlayer(int playerID) -// { -// // TODO: 实现玩家对象池或动态生成 -// return FindObjectOfType(); -// } -// } -// } \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Data/NetworkDataManager.cs.meta b/Assets/Scripts/Fishing/Data/NetworkDataManager.cs.meta deleted file mode 100644 index e0720da5e..000000000 --- a/Assets/Scripts/Fishing/Data/NetworkDataManager.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f1a06ba516ea46f0920729b2af6484c1 -timeCreated: 1773028213 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Data/PlayerDataManager.cs b/Assets/Scripts/Fishing/Data/PlayerDataManager.cs deleted file mode 100644 index 806b587a5..000000000 --- a/Assets/Scripts/Fishing/Data/PlayerDataManager.cs +++ /dev/null @@ -1,56 +0,0 @@ -// using System; -// using System.Collections.Generic; -// using UnityEngine; -// -// namespace NBF -// { -// public interface IDataSource -// { -// } -// -// /// -// /// 数据管理器基类(本地和网络共享接口) -// /// -// public class PlayerDataManager : MonoBehaviour -// { -// public static PlayerDataManager Instance { get; private set; } -// -// public FPlayerData Self { get; set; } -// -// private Dictionary _players = new Dictionary(); -// -// protected void Awake() -// { -// Instance = this; -// } -// -// -// /// -// /// 玩家状态变更时调用 -// /// -// public void OnPlayerStateChanged(FPlayerData player, PlayerState newState) -// { -// } -// -// /// -// /// 手持物品变更时调用 -// /// -// public void OnHeldItemChanged(FPlayerData player, HeldItemInfo newItem) -// { -// } -// -// /// -// /// 发送玩家状态快照 -// /// -// public void SendStateSnapshot(FPlayerData player) -// { -// } -// -// /// -// /// 接收并应用网络快照 -// /// -// public void ReceiveStateSnapshot(int playerID, PlayerStateSnapshot snapshot) -// { -// } -// } -// } \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Data/PlayerDataManager.cs.meta b/Assets/Scripts/Fishing/Data/PlayerDataManager.cs.meta deleted file mode 100644 index 783cfccdc..000000000 --- a/Assets/Scripts/Fishing/Data/PlayerDataManager.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0478bf9a256a46beb65fd0307c7b5b9b -timeCreated: 1773028149 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Data/StateEnterParams.cs b/Assets/Scripts/Fishing/Data/StateEnterParams.cs index 2fd78927a..54af7e70b 100644 --- a/Assets/Scripts/Fishing/Data/StateEnterParams.cs +++ b/Assets/Scripts/Fishing/Data/StateEnterParams.cs @@ -4,6 +4,11 @@ using UnityEngine; namespace NBF { + public class StateParamsConst + { + public const string ChargedProgress = "ChargedProgress"; + } + /// /// 状态进入参数(用于网络同步和动画/表现播放) /// diff --git a/Assets/Scripts/Fishing/New/Data/Player.cs b/Assets/Scripts/Fishing/New/Data/Player.cs index 5db3b8875..b363a4757 100644 --- a/Assets/Scripts/Fishing/New/Data/Player.cs +++ b/Assets/Scripts/Fishing/New/Data/Player.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Fantasy; using Fantasy.Entitas; using UnityEngine; @@ -17,18 +18,13 @@ namespace NBF public bool IsSelf => RoleModel.Instance.Id == Id; // ========== 物理状态(高频同步) ========== - public Vector3 position; - public Quaternion rotation; + public Vector3 Position; + public Quaternion Rotation; public Vector2 MoveInput; public float Speed; public float RotationSpeed; public bool IsGrounded; public bool Run; - - // ========== 钓鱼相关状态(中频同步) ========== - public float currentReelingSpeed; - public float lineLength; - public float reelSpeed; public float EyeAngle; /// @@ -36,29 +32,21 @@ namespace NBF /// public long TagValue; - - // ========== 状态机 ========== - private PlayerState _previousPlayerState = PlayerState.Idle; - private PlayerState _playerState; - public PlayerState PreviousState => _previousPlayerState; + /// + /// 上一个状态 + /// + public PlayerState PreviousState; /// - /// 当前状态的进入参数(本地和远程都适用) + /// 当前状态 /// - public StateEnterParams CurrentStateParams { get; private set; } = new StateEnterParams(); + public PlayerState State; + + /// + /// 状态参数 + /// + public StateEnterParams StateParams; - public PlayerState State - { - get => _playerState; - set - { - if (_playerState != value) - { - _previousPlayerState = _playerState; - _playerState = value; - } - } - } /// /// 玩家的物品 @@ -75,9 +63,12 @@ namespace NBF /// public PlayerItem HandItem => Items[HandItemId]; + #region 初始化 + public void InitPlayer(MapUnitInfo unitInfo) { AddComponent(); + AddComponent(); if (unitInfo.Id == RoleModel.Instance.Id) { //自己 @@ -85,13 +76,61 @@ namespace NBF } } + #endregion + + #region 物品 public void UnUseItem() { + if (Items.TryGetValue(HandItemId, out var item)) + { + item.Dispose(); + } + + HandItemId = 0; + ItemChangeEvent(); } - public void UseItem(ItemInfo item) + public void UseItem(ItemBindInfo item) { + var playerItem = Create(Scene); + playerItem.Init(item); + ItemChangeEvent(); } + + private void ItemChangeEvent() + { + Scene.EventComponent.Publish(new PlayerStateChangeEvent + { + Player = this + }); + } + + #endregion + + #region 状态切换 + + /// + /// 切换状态 + /// + /// + /// + public void ChangeState(PlayerState state, StateEnterParams stateParams = null) + { + if (state == State) + { + return; + } + + PreviousState = State; + State = state; + StateParams = stateParams; + Scene.EventComponent.Publish(new PlayerStateChangeEvent + { + Player = this + }); + } + + #endregion } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/Data/PlayerEvent.cs b/Assets/Scripts/Fishing/New/Data/PlayerEvent.cs new file mode 100644 index 000000000..6b47a6bbd --- /dev/null +++ b/Assets/Scripts/Fishing/New/Data/PlayerEvent.cs @@ -0,0 +1,12 @@ +namespace NBF +{ + public struct PlayerStateChangeEvent + { + public Player Player; + } + + public struct PlayerItemChangeEvent + { + public Player Player; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/Data/PlayerEvent.cs.meta b/Assets/Scripts/Fishing/New/Data/PlayerEvent.cs.meta new file mode 100644 index 000000000..ef02a788d --- /dev/null +++ b/Assets/Scripts/Fishing/New/Data/PlayerEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c10a4d3f5e354dc9a046ddf7219354b2 +timeCreated: 1773060354 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/Data/PlayerItem.cs b/Assets/Scripts/Fishing/New/Data/PlayerItem.cs index 0b206c0ad..c22f05901 100644 --- a/Assets/Scripts/Fishing/New/Data/PlayerItem.cs +++ b/Assets/Scripts/Fishing/New/Data/PlayerItem.cs @@ -1,4 +1,6 @@ -using Fantasy.Entitas; +using System.Collections.Generic; +using Fantasy; +using Fantasy.Entitas; namespace NBF { @@ -8,5 +10,16 @@ namespace NBF /// 配置id /// public int ConfigID; + + /// + /// 绑定的子物体 + /// + public List BindItems = new List(); + + public void Init(ItemBindInfo bindInfo) + { + ConfigID = bindInfo.Item; + BindItems.AddRange(bindInfo.BindItems); + } } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/Event.meta b/Assets/Scripts/Fishing/New/Event.meta new file mode 100644 index 000000000..e6b701519 --- /dev/null +++ b/Assets/Scripts/Fishing/New/Event.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 172aa8a5a1444ccbad1647479739c232 +timeCreated: 1773060255 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/Handle.meta b/Assets/Scripts/Fishing/New/View/Handle.meta new file mode 100644 index 000000000..dd7dee8a5 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/Handle.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 958b50133e064daf9764313f24b892da +timeCreated: 1773069791 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/Handle/OnPlayerStateChangeEvent.cs b/Assets/Scripts/Fishing/New/View/Handle/OnPlayerStateChangeEvent.cs new file mode 100644 index 000000000..a7c2ea535 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/Handle/OnPlayerStateChangeEvent.cs @@ -0,0 +1,13 @@ +using Fantasy.Event; + +namespace NBF.Handle +{ + public class OnPlayerStateChangeEvent : EventSystem + { + protected override void Handler(PlayerStateChangeEvent self) + { + var view = self.Player.GetOrAddComponent(); + view.ShowItem(); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/Handle/OnPlayerStateChangeEvent.cs.meta b/Assets/Scripts/Fishing/New/View/Handle/OnPlayerStateChangeEvent.cs.meta new file mode 100644 index 000000000..2712d6109 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/Handle/OnPlayerStateChangeEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b5897acb7a6e40fcb3123362df1669f3 +timeCreated: 1773069799 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/PlayerInputComponent.cs b/Assets/Scripts/Fishing/New/View/PlayerInputComponent.cs index 16c1327ae..e5c0277f5 100644 --- a/Assets/Scripts/Fishing/New/View/PlayerInputComponent.cs +++ b/Assets/Scripts/Fishing/New/View/PlayerInputComponent.cs @@ -1,8 +1,9 @@ -using Fantasy.Entitas; +using Fantasy; +using Fantasy.Entitas; using Fantasy.Entitas.Interface; -using NBC; using UnityEngine; using UnityEngine.InputSystem; +using Log = NBC.Log; namespace NBF { @@ -89,8 +90,15 @@ namespace NBF var item = RoleModel.Instance.GetSlotItem(index - 1); if (item != null) { - Player.UseItem(item); - // Game.Instance.StartCoroutine(UseItem(item)); + var itemBindInfo = ItemBindInfo.Create(); + itemBindInfo.Item = item.ConfigId; + var binds = RoleModel.Instance.GetBindItems(item.Id); + foreach (var itemInfo in binds) + { + itemBindInfo.BindItems.Add(itemInfo.ConfigId); + } + + Player.UseItem(itemBindInfo); } } } @@ -121,7 +129,7 @@ namespace NBF #region Move - private Quaternion lastRotation; + private Quaternion _lastRotation; private void UpdateMove() { @@ -155,7 +163,7 @@ namespace NBF Quaternion rotation = View.Unity.FirstPerson.transform.rotation; // 计算当前帧与上一帧的旋转差异 - Quaternion rotationDelta = rotation * Quaternion.Inverse(lastRotation); + Quaternion rotationDelta = rotation * Quaternion.Inverse(_lastRotation); // 将四元数转换为角度轴表示 rotationDelta.ToAngleAxis(out float angle, out Vector3 axis); @@ -179,7 +187,7 @@ namespace NBF Player.RotationSpeed = turnValue; - lastRotation = rotation; + _lastRotation = rotation; } #endregion diff --git a/Assets/Scripts/Fishing/New/View/PlayerItemViewComponent.cs b/Assets/Scripts/Fishing/New/View/PlayerItemViewComponent.cs new file mode 100644 index 000000000..332a0ea07 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/PlayerItemViewComponent.cs @@ -0,0 +1,67 @@ +using System.Collections; +using Fantasy.Entitas; + +namespace NBF +{ + public class PlayerItemViewComponent : Entity + { + public void ShowItem() + { + // Game.Instance.StartCoroutine() + } + + #region 使用物品 + + // public IEnumerator UseItem(ItemInfo item) + // { + // if (Data.ChangeItem) yield break; + // Data.ChangeItem = true; + // var itemType = item?.ConfigId.GetItemType(); + // if (itemType == ItemType.Rod) + // { + // //判断旧的是否要收回 + // yield return UnUseItemConfirm(); + // + // Data.IsLureRod = true; + // var rodType = (ItemSubType)item.Config.Type; + // if (rodType == ItemSubType.RodTele) + // { + // Data.IsLureRod = false; + // } + // + // Rod = + // item.Config.InstantiateAndComponent(SceneSettings.Instance.GearNode, Vector3.zero, + // Quaternion.identity); + // yield return Rod.InitRod(this, item); + // Tackles.Add(Rod); + // OnFishingSetEquiped?.Invoke(Rod); + // } + // + // Data.ChangeItem = false; + // } + // + // public IEnumerator UnUseItem() + // { + // if (Data.ChangeItem) yield break; + // Data.ChangeItem = true; + // yield return UnUseItemConfirm(); + // Data.ChangeItem = false; + // } + // + // private IEnumerator UnUseItemConfirm() + // { + // if (Rod != null) + // { + // OnFishingSetUnequip?.Invoke(); + // yield return Rod.Destroy(); + // yield return new WaitForSeconds(0.35f); + // Destroy(Rod.gameObject); + // Tackles.Remove(Rod); + // Rod = null; + // yield return new WaitForSeconds(0.15f); + // } + // } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/PlayerItemViewComponent.cs.meta b/Assets/Scripts/Fishing/New/View/PlayerItemViewComponent.cs.meta new file mode 100644 index 000000000..0ad1990c2 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/PlayerItemViewComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cf5f405feb8f431ea52d8f33b3cb2e29 +timeCreated: 1773069665 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/PlayerStateViewComponent.cs b/Assets/Scripts/Fishing/New/View/PlayerStateViewComponent.cs new file mode 100644 index 000000000..dd50e0216 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/PlayerStateViewComponent.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; +using Fantasy.Entitas; +using Fantasy.Entitas.Interface; +using Fantasy.Event; + +namespace NBF +{ + /// + /// 状态显示层组件 + /// + public class PlayerStateViewComponent : Entity + { + private readonly Dictionary _stageViews = + new Dictionary(); + + private PlayerStageViewBase _currentStateView; + private Player _player; + + public void Awake() + { + _player = GetParent(); + _stageViews.Add(PlayerState.Idle, new PlayerStageViewIdle()); + _stageViews.Add(PlayerState.Prepare, new PlayerStageViewPrepare()); + _stageViews.Add(PlayerState.Throw, new PlayerStageViewThrow()); + _stageViews.Add(PlayerState.Fishing, new PlayerStageViewFishing()); + _stageViews.Add(PlayerState.Fight, new PlayerStageViewFight()); + foreach (var playerStageView in _stageViews.Values) + { + playerStageView.Init(_player); + } + } + + public void Update() + { + _currentStateView?.Update(); + } + + public void OnStageChange() + { + if (_currentStateView != null) + { + _currentStateView.Exit(); + } + + _currentStateView = _stageViews.GetValueOrDefault(_player.State); + _currentStateView.Enter(_player.StateParams, _player.PreviousState); + } + } + + public class PlayerStateViewComponentAwakeSystem : AwakeSystem + { + protected override void Awake(PlayerStateViewComponent self) + { + self.Awake(); + } + } + + public class PlayerStateViewComponentUpdateSystem : UpdateSystem + { + protected override void Update(PlayerStateViewComponent self) + { + self.Update(); + } + } + + public class OnPlayerStageChange : EventSystem + { + protected override void Handler(PlayerStateChangeEvent self) + { + var stateView = self.Player.GetComponent(); + if (stateView != null) + { + stateView.OnStageChange(); + } + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/PlayerStateViewComponent.cs.meta b/Assets/Scripts/Fishing/New/View/PlayerStateViewComponent.cs.meta new file mode 100644 index 000000000..4c0a32512 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/PlayerStateViewComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f48ea2ea6a0e4b38aa97a3fd07f3a6cc +timeCreated: 1773060520 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/PlayerViewComponent.cs b/Assets/Scripts/Fishing/New/View/PlayerViewComponent.cs index 7ac25f989..519cec874 100644 --- a/Assets/Scripts/Fishing/New/View/PlayerViewComponent.cs +++ b/Assets/Scripts/Fishing/New/View/PlayerViewComponent.cs @@ -24,6 +24,7 @@ namespace NBF { CameraManager.Instance.SetFppLook(Unity); } + Unity.transform.localPosition = new Vector3(484, 1, 422); } @@ -47,7 +48,7 @@ namespace NBF private void CreatePlayerModel() { var modelObject = PrefabsHelper.CreatePlayer(Unity.Root, "Human_Male"); - modelObject.transform.localPosition = Vector3.zero; + modelObject.transform.localPosition = new Vector3(0, 1, 0); Unity.ModelAsset = modelObject.GetComponent(); Unity.ModelAsset.SetPlayer(Unity.FppLook); } diff --git a/Assets/Scripts/Fishing/New/View/States.meta b/Assets/Scripts/Fishing/New/View/States.meta new file mode 100644 index 000000000..895b7880e --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 98b05ca000114232a657f19095fdb49a +timeCreated: 1773063071 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/States/PlayerStageViewBase.cs b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewBase.cs new file mode 100644 index 000000000..00ee7fcbe --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewBase.cs @@ -0,0 +1,61 @@ +using UnityEngine; + +namespace NBF +{ + public abstract class PlayerStageViewBase + { + public Player Player { get; private set; } + public PlayerViewComponent PlayerView { get; private set; } + protected float EnterTime { get; set; } + + protected PlayerState PreviousState { get; private set; } + protected StateEnterParams Params; + + public void Init(Player player) + { + Player = player; + PlayerView = player.GetComponent(); + } + + /// + /// 检查状态超时 + /// + public void CheckStateTimeout(float time) + { + if (Time.time - EnterTime >= time) + { + Player.ChangeState(PlayerState.Idle); + } + } + + public void Enter(StateEnterParams par = null, PlayerState prevState = PlayerState.None) + { + Params = par; + PreviousState = prevState; + EnterTime = Time.time; + OnEnter(); + } + + protected virtual void OnEnter() + { + } + + public void Exit() + { + OnExit(); + } + + protected virtual void OnExit() + { + } + + public void Update() + { + OnUpdate(); + } + + protected virtual void OnUpdate() + { + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/States/PlayerStageViewBase.cs.meta b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewBase.cs.meta new file mode 100644 index 000000000..a9f309baf --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cce89f03f80b4fb8a0e36e66e9ffb3a9 +timeCreated: 1773063081 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/States/PlayerStageViewFight.cs b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewFight.cs new file mode 100644 index 000000000..b4d4690d5 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewFight.cs @@ -0,0 +1,6 @@ +namespace NBF +{ + public class PlayerStageViewFight : PlayerStageViewBase + { + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/States/PlayerStageViewFight.cs.meta b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewFight.cs.meta new file mode 100644 index 000000000..62c6c98dd --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewFight.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a9445a6593604dc19dea2bb8bb0819bc +timeCreated: 1773064542 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/States/PlayerStageViewFishing.cs b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewFishing.cs new file mode 100644 index 000000000..3a125c4e6 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewFishing.cs @@ -0,0 +1,99 @@ +using UnityEngine; + +namespace NBF +{ + public class PlayerStageViewFishing : PlayerStageViewBase + { + protected override void OnEnter() + { + Debug.LogError("enter PlayerStateFishing"); + PlayerView.Unity.ModelAsset.PlayerAnimator.BaitThrown = true; + } + + protected override void OnExit() + { + PlayerView.Unity.ModelAsset.PlayerAnimator.BaitThrown = false; + } + + protected override void OnUpdate() + { + PlayerState ret = PlayerState.None; + var isUpRod = false; + var isSubLine = false; + + if (InputManager.IsOp1) + { + if (!Player.IsLureRod) + { + //抬杆 + isUpRod = true; + } + else + { + //收线 + isSubLine = true; + } + } + + if (InputManager.IsOp2) + { + if (Player.IsLureRod) + { + //抬杆 + isUpRod = true; + } + } + + //Player.ModelAsset.PlayerAnimator.FishingUp = 0; + + if (isUpRod || PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp > 0) + { + var upForce = 1; + var addNum = upForce * Time.deltaTime; + if (!isUpRod) + { + addNum *= -1; + } + else + { + addNum *= 0.5f; + } + + // Debug.Log($"addNum={addNum}"); + PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp += addNum; + // Debug.LogError($"ishingFinal={Player.ModelAsset.PlayerAnimator.FishingUp}"); + if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp >= 1) + { + PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 1; + } + else if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp < 0) + { + PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 0; + } + + if (PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp >= 0.8f) + { + ret = CheckTackFish(); + } + } + else + { + PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 0; + } + + if (ret != PlayerState.None) + { + Player.ChangeState(ret); + } + } + + #region 检查上鱼或者返回待机 + + private PlayerState CheckTackFish() + { + return PlayerState.Idle; + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/States/PlayerStageViewFishing.cs.meta b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewFishing.cs.meta new file mode 100644 index 000000000..912429a6e --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewFishing.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 84665b6bc7c84642b365db024c7759fd +timeCreated: 1773064529 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/States/PlayerStageViewIdle.cs b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewIdle.cs new file mode 100644 index 000000000..eb41a4479 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewIdle.cs @@ -0,0 +1,25 @@ +namespace NBF +{ + public class PlayerStageViewIdle : PlayerStageViewBase + { + protected override void OnEnter() + { + InputManager.OnOp1Action += OnOp1Action; + } + + private void OnOp1Action(bool performed) + { + if (Player.HandItem == null) return; + if (performed) + { + Player.ChangeState(PlayerState.Prepare); + // _nextState = true; + } + } + + protected override void OnExit() + { + InputManager.OnOp1Action -= OnOp1Action; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/States/PlayerStageViewIdle.cs.meta b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewIdle.cs.meta new file mode 100644 index 000000000..b3d2aaeb8 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewIdle.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1fca81636d7246e7a5f84684a8563ca3 +timeCreated: 1773063824 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/States/PlayerStageViewPrepare.cs b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewPrepare.cs new file mode 100644 index 000000000..1c87ca363 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewPrepare.cs @@ -0,0 +1,73 @@ +using NBC; +using UnityEngine; + +namespace NBF +{ + public class PlayerStageViewPrepare : PlayerStageViewBase + { + public enum Phase + { + None, + + /// + /// 蓄力 + /// + Charged, + + /// + /// 确认蓄力结果 + /// + Confirm, + } + + public Phase Stage = Phase.Charged; + public float ChargedProgress; + + protected override void OnEnter() + { + Log.Info("enter PlayerStatePrepare"); + Stage = Phase.Charged; + PlayerView.Unity.ModelAsset.PlayerAnimator.PrepareThrow = true; + PlayerView.Unity.ModelAsset.PlayerAnimator.FishingUp = 0; + } + + protected override void OnUpdate() + { + if (Stage == Phase.Charged) + { + ThrowPowerCharged(); + } + else if (Stage == Phase.Confirm) + { + //确认蓄力结果, + Debug.Log($"确认蓄力结果,ChargedProgress={ChargedProgress}"); + var par = new StateEnterParams(); + par.SetFloat(StateParamsConst.ChargedProgress, ChargedProgress); + Player.ChangeState(PlayerState.Throw); + Stage = Phase.None; + } + } + + + #region 蓄力中 + + private void ThrowPowerCharged() + { + if (ChargedProgress < 1) + { + ChargedProgress += Time.deltaTime; + } + else if (ChargedProgress > 1) + { + ChargedProgress = 1; + } + + if (!InputManager.IsOp1) + { + Stage = Phase.Confirm; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/States/PlayerStageViewPrepare.cs.meta b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewPrepare.cs.meta new file mode 100644 index 000000000..daccfe6fb --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewPrepare.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 77cce716a7f94e0083789eb2953d5f79 +timeCreated: 1773064499 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/States/PlayerStageViewThrow.cs b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewThrow.cs new file mode 100644 index 000000000..2f35ca0b5 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewThrow.cs @@ -0,0 +1,75 @@ +using NBC; +using UnityEngine; + +namespace NBF +{ + public class PlayerStageViewThrow : PlayerStageViewBase + { + private bool _nextState = false; + public float ChargedProgress; + + protected override void OnEnter() + { + Log.Info("enter PlayerStateThrow"); + PlayerView.Unity.ModelAsset.PlayerAnimator.StartThrow = true; + + ChargedProgress = 0; + if (Params != null) + { + ChargedProgress = Params.GetFloat(StateParamsConst.ChargedProgress); + } + + Debug.Log($"PlayerThrow ChargedProgress={ChargedProgress}"); + _nextState = false; + // Stage = Phase.Waiting; + + // _owner.Gears.Reel?.Unlock(); + } + + protected override void OnUpdate() + { + CheckStateTimeout(10); + if (_nextState) + { + // return (uint)PlayerState.Fishing; + _nextState = false; + Player.ChangeState(PlayerState.Fishing); + } + } + + // IEnumerator ThrowCoroutine(float distance) + // { + // float startLength = 0.5f; + // Debug.Log($"REST LENGTH : {rope.restLength}"); + // do + // { + // float a = Vector3.Distance(rodTipTarget.position, attachedBody.transform.position); + // attachedBody.RBody.AddForce(playerForward.Value, ForceMode.VelocityChange); + // startLength = Mathf.Max(a, startLength); + // UnwindLine(attachedBody.RBody.linearVelocity.magnitude * Time.deltaTime); + // yield return null; + // } + // while ((bool)isBailOpen); + // } + + #region 动画回调 + + /// + /// 抛竿动画事件 + /// + public void OnRodThrowStart() + { + Debug.LogError("OnRodThrowStart"); + PlayerView.Unity.ModelAsset.PlayerAnimator.PrepareThrow = false; + PlayerView.Unity.ModelAsset.PlayerAnimator.StartThrow = false; + } + + public void OnRodThrownEnd() + { + Debug.LogError("OnRodThrownEnd"); + _nextState = true; + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing/New/View/States/PlayerStageViewThrow.cs.meta b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewThrow.cs.meta new file mode 100644 index 000000000..cbe934038 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/States/PlayerStageViewThrow.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 240bbc6c969a4d2e9759ac1df5e6ccf2 +timeCreated: 1773064512 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Tackle.meta b/Assets/Scripts/Fishing/New/View/Tackle.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle.meta rename to Assets/Scripts/Fishing/New/View/Tackle.meta diff --git a/Assets/Scripts/Fishing/Tackle/FBait.cs b/Assets/Scripts/Fishing/New/View/Tackle/FBait.cs similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FBait.cs rename to Assets/Scripts/Fishing/New/View/Tackle/FBait.cs diff --git a/Assets/Scripts/Fishing/Tackle/FBait.cs.meta b/Assets/Scripts/Fishing/New/View/Tackle/FBait.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FBait.cs.meta rename to Assets/Scripts/Fishing/New/View/Tackle/FBait.cs.meta diff --git a/Assets/Scripts/Fishing/Tackle/FBobber.cs b/Assets/Scripts/Fishing/New/View/Tackle/FBobber.cs similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FBobber.cs rename to Assets/Scripts/Fishing/New/View/Tackle/FBobber.cs diff --git a/Assets/Scripts/Fishing/Tackle/FBobber.cs.meta b/Assets/Scripts/Fishing/New/View/Tackle/FBobber.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FBobber.cs.meta rename to Assets/Scripts/Fishing/New/View/Tackle/FBobber.cs.meta diff --git a/Assets/Scripts/Fishing/Tackle/FFish.cs b/Assets/Scripts/Fishing/New/View/Tackle/FFish.cs similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FFish.cs rename to Assets/Scripts/Fishing/New/View/Tackle/FFish.cs diff --git a/Assets/Scripts/Fishing/Tackle/FFish.cs.meta b/Assets/Scripts/Fishing/New/View/Tackle/FFish.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FFish.cs.meta rename to Assets/Scripts/Fishing/New/View/Tackle/FFish.cs.meta diff --git a/Assets/Scripts/Fishing/Tackle/FGearBase.cs b/Assets/Scripts/Fishing/New/View/Tackle/FGearBase.cs similarity index 76% rename from Assets/Scripts/Fishing/Tackle/FGearBase.cs rename to Assets/Scripts/Fishing/New/View/Tackle/FGearBase.cs index 749422128..d63009363 100644 --- a/Assets/Scripts/Fishing/Tackle/FGearBase.cs +++ b/Assets/Scripts/Fishing/New/View/Tackle/FGearBase.cs @@ -3,10 +3,11 @@ using UnityEngine; namespace NBF { - public abstract class FGearBase : PlayerMonoBehaviour + public abstract class FGearBase : MonoBehaviour { public FRod Rod { get; protected set; } - public ItemInfo ItemInfo; + + public int ConfigId; public virtual void Init(FRod rod) @@ -15,9 +16,9 @@ namespace NBF OnInit(); } - public void SetItemInfo(ItemInfo itemInfo) + public void SetItemConfigId(int id) { - ItemInfo = itemInfo; + ConfigId = id; } diff --git a/Assets/Scripts/Fishing/Tackle/FGearBase.cs.meta b/Assets/Scripts/Fishing/New/View/Tackle/FGearBase.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FGearBase.cs.meta rename to Assets/Scripts/Fishing/New/View/Tackle/FGearBase.cs.meta diff --git a/Assets/Scripts/Fishing/New/View/Tackle/FHandItem.cs b/Assets/Scripts/Fishing/New/View/Tackle/FHandItem.cs new file mode 100644 index 000000000..1b6920cb7 --- /dev/null +++ b/Assets/Scripts/Fishing/New/View/Tackle/FHandItem.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace NBF +{ + public class FHandItem : MonoBehaviour + { + public int ConfigId; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Tackle/FHandItem.cs.meta b/Assets/Scripts/Fishing/New/View/Tackle/FHandItem.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FHandItem.cs.meta rename to Assets/Scripts/Fishing/New/View/Tackle/FHandItem.cs.meta diff --git a/Assets/Scripts/Fishing/Tackle/FHook.cs b/Assets/Scripts/Fishing/New/View/Tackle/FHook.cs similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FHook.cs rename to Assets/Scripts/Fishing/New/View/Tackle/FHook.cs diff --git a/Assets/Scripts/Fishing/Tackle/FHook.cs.meta b/Assets/Scripts/Fishing/New/View/Tackle/FHook.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FHook.cs.meta rename to Assets/Scripts/Fishing/New/View/Tackle/FHook.cs.meta diff --git a/Assets/Scripts/Fishing/Tackle/FLine.cs b/Assets/Scripts/Fishing/New/View/Tackle/FLine.cs similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FLine.cs rename to Assets/Scripts/Fishing/New/View/Tackle/FLine.cs diff --git a/Assets/Scripts/Fishing/Tackle/FLine.cs.meta b/Assets/Scripts/Fishing/New/View/Tackle/FLine.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FLine.cs.meta rename to Assets/Scripts/Fishing/New/View/Tackle/FLine.cs.meta diff --git a/Assets/Scripts/Fishing/Tackle/FLineHandler.cs b/Assets/Scripts/Fishing/New/View/Tackle/FLineHandler.cs similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FLineHandler.cs rename to Assets/Scripts/Fishing/New/View/Tackle/FLineHandler.cs diff --git a/Assets/Scripts/Fishing/Tackle/FLineHandler.cs.meta b/Assets/Scripts/Fishing/New/View/Tackle/FLineHandler.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FLineHandler.cs.meta rename to Assets/Scripts/Fishing/New/View/Tackle/FLineHandler.cs.meta diff --git a/Assets/Scripts/Fishing/Tackle/FLure.cs b/Assets/Scripts/Fishing/New/View/Tackle/FLure.cs similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FLure.cs rename to Assets/Scripts/Fishing/New/View/Tackle/FLure.cs diff --git a/Assets/Scripts/Fishing/Tackle/FLure.cs.meta b/Assets/Scripts/Fishing/New/View/Tackle/FLure.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FLure.cs.meta rename to Assets/Scripts/Fishing/New/View/Tackle/FLure.cs.meta diff --git a/Assets/Scripts/Fishing/Tackle/FReel.cs b/Assets/Scripts/Fishing/New/View/Tackle/FReel.cs similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FReel.cs rename to Assets/Scripts/Fishing/New/View/Tackle/FReel.cs diff --git a/Assets/Scripts/Fishing/Tackle/FReel.cs.meta b/Assets/Scripts/Fishing/New/View/Tackle/FReel.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FReel.cs.meta rename to Assets/Scripts/Fishing/New/View/Tackle/FReel.cs.meta diff --git a/Assets/Scripts/Fishing/Tackle/FRod.cs b/Assets/Scripts/Fishing/New/View/Tackle/FRod.cs similarity index 85% rename from Assets/Scripts/Fishing/Tackle/FRod.cs rename to Assets/Scripts/Fishing/New/View/Tackle/FRod.cs index 1ff566801..269ecd2b4 100644 --- a/Assets/Scripts/Fishing/Tackle/FRod.cs +++ b/Assets/Scripts/Fishing/New/View/Tackle/FRod.cs @@ -20,8 +20,6 @@ namespace NBF public RodAsset Asset; - public ItemInfo ItemInfo; - public FReel Reel; public FHook Hook; public FBobber Bobber; @@ -124,12 +122,12 @@ namespace NBF yield return 1; } - public IEnumerator InitRod(ItemInfo itemInfo) + public IEnumerator InitRod(Player player, ItemBindInfo itemBindInfo) { - ItemInfo = itemInfo; + ConfigId = itemBindInfo.Item; // Player = player; - var playerView = Player.GetComponent(); + var playerView = player.GetComponent(); var playerViewUnity = playerView.Unity; @@ -138,7 +136,7 @@ namespace NBF transform.localScale = Vector3.one; SceneSettings.Instance.GearNode.position = playerViewUnity.transform.position; yield return 1; - var obj = new GameObject($"rod_{itemInfo.Id}_{itemInfo.ConfigId}"); + var obj = new GameObject($"rod_{ConfigId}"); obj.transform.SetParent(SceneSettings.Instance.GearNode); // obj.transform.SetParent(player.transform); // obj.transform.localPosition = Vector3.zero; @@ -149,55 +147,55 @@ namespace NBF var parent = GearRoot; - List children = RoleModel.Instance.GetBindItems(itemInfo.Id); + // List children = RoleModel.Instance.GetBindItems(itemInfo.Id); - ItemInfo lineItemInfo = null; CreateFishingHandler(); yield return 1; //等待1帧 // children.Sort(); - foreach (var child in children) + foreach (var childConfigId in itemBindInfo.BindItems) { - var itemType = child.ConfigId.GetItemType(); + var itemType = childConfigId.GetItemType(); + var config = Game.Tables.TbItem.Get(childConfigId); if (itemType == ItemType.Reel) { - Reel = child.Config.InstantiateAndComponent(Asset.ReelConnector, Vector3.zero, + Reel = config.InstantiateAndComponent(Asset.ReelConnector, Vector3.zero, Quaternion.identity); - Reel.SetItemInfo(child); + Reel.SetItemConfigId(childConfigId); } else if (itemType == ItemType.Bobber) { - Bobber = child.Config.InstantiateAndComponent(parent, Vector3.zero, + Bobber = config.InstantiateAndComponent(parent, Vector3.zero, Quaternion.identity); - Bobber.SetItemInfo(child); + Bobber.SetItemConfigId(childConfigId); } else if (itemType == ItemType.Hook) { - Hook = child.Config.InstantiateAndComponent(parent, Vector3.zero, + Hook = config.InstantiateAndComponent(parent, Vector3.zero, Quaternion.identity); - Hook.SetItemInfo(child); + Hook.SetItemConfigId(childConfigId); } else if (itemType == ItemType.Bait) { - Bait = child.Config.InstantiateAndComponent(parent, Vector3.zero, + Bait = config.InstantiateAndComponent(parent, Vector3.zero, Quaternion.identity); - Bait.SetItemInfo(child); + Bait.SetItemConfigId(childConfigId); } else if (itemType == ItemType.Lure) { - Lure = child.Config.InstantiateAndComponent(parent, Vector3.zero, + Lure = config.InstantiateAndComponent(parent, Vector3.zero, Quaternion.identity); - Lure.SetItemInfo(child); + Lure.SetItemConfigId(childConfigId); } else if (itemType == ItemType.Weight) { - Weight = child.Config.InstantiateAndComponent(parent, Vector3.zero, + Weight = config.InstantiateAndComponent(parent, Vector3.zero, Quaternion.identity); - Weight.SetItemInfo(child); + Weight.SetItemConfigId(childConfigId); } else if (itemType == ItemType.Line) { - lineItemInfo = child; + // lineItemInfo = child; } } @@ -251,7 +249,8 @@ namespace NBF if (Line == null) { Debug.LogError("创建钓组====="); - var rodType = (ItemSubType)ItemInfo.Config.Type; + var itemConfig = Game.Tables.TbItem.Get(ConfigId); + var rodType = (ItemSubType)itemConfig.Type; if (rodType == ItemSubType.RodTele) { CreateObiFishingLine(0); diff --git a/Assets/Scripts/Fishing/Tackle/FRod.cs.meta b/Assets/Scripts/Fishing/New/View/Tackle/FRod.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FRod.cs.meta rename to Assets/Scripts/Fishing/New/View/Tackle/FRod.cs.meta diff --git a/Assets/Scripts/Fishing/Tackle/FWeight.cs b/Assets/Scripts/Fishing/New/View/Tackle/FWeight.cs similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FWeight.cs rename to Assets/Scripts/Fishing/New/View/Tackle/FWeight.cs diff --git a/Assets/Scripts/Fishing/Tackle/FWeight.cs.meta b/Assets/Scripts/Fishing/New/View/Tackle/FWeight.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/Tackle/FWeight.cs.meta rename to Assets/Scripts/Fishing/New/View/Tackle/FWeight.cs.meta diff --git a/Assets/Scripts/Fishing/Tackle/FHandItem.cs b/Assets/Scripts/Fishing/Tackle/FHandItem.cs deleted file mode 100644 index 08365e056..000000000 --- a/Assets/Scripts/Fishing/Tackle/FHandItem.cs +++ /dev/null @@ -1,8 +0,0 @@ -using UnityEngine; - -namespace NBF -{ - public class FHandItem : PlayerMonoBehaviour - { - } -} \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Tackle/FVirtualTackle.cs b/Assets/Scripts/Fishing/Tackle/FVirtualTackle.cs deleted file mode 100644 index 0dee640e0..000000000 --- a/Assets/Scripts/Fishing/Tackle/FVirtualTackle.cs +++ /dev/null @@ -1,233 +0,0 @@ -// using System.Collections; -// using Fantasy; -// using UnityEngine; -// -// namespace NBF -// { -// /// -// /// 虚拟钓组 -// /// -// public class FVirtualTackle -// { -// private ItemInfo _itemInfo; -// private FPlayer _player; -// -// -// public FRod Rod; -// -// -// public FVirtualTackle(ItemInfo itemInfo, FPlayer player) -// { -// _itemInfo = itemInfo; -// _player = player; -// } -// -// public IEnumerator Create() -// { -// var parent = _player.transform; -// // parent.position = _player.transform.position; -// -// -// Rod = _itemInfo.Config.InstantiateAndComponent(parent, Vector3.zero, Quaternion.identity); -// -// -// // var rodObject = _itemInfo.Config.Instantiate(parent, Vector3.zero, Quaternion.identity); -// // Rod = rodObject.GetComponent(); -// // if (Rod == null) -// // { -// // Rod = rodObject.AddComponent(); -// // } -// // var rodConfig = RodConfig.Get(itemInfo.ConfigId); -// // itemInfo.Config -// -// // var data = Player.Data.currentGear; -// // var rodConfig = data.rod.Config; -// // var cloneObj = rodConfig.Instantiate(parent, Vector3.zero, Player.MainArm.RodContainer.rotation); -// // if (cloneObj == null) -// // { -// // yield break; -// // } -// // -// // Rod = cloneObj.GetComponent(); -// // if (Rod == null) -// // { -// // Rod = cloneObj.AddComponent(); -// // } -// // -// // -// // if (Rod) -// // { -// // Rod.transform.localPosition = Vector3.zero; -// // Rod.transform.rotation = Player.MainArm.RodContainer.rotation; -// // -// // if (rodConfig.ring > 0) -// // { -// // var ringConfig = GameRings.Get(rodConfig.ring); -// // var ringObject = ringConfig.Instantiate(Rod.transform); -// // ringObject.SetActive(false); -// // Rod.SetRing(ringObject.GetComponent()); -// // } -// // } -// // else -// // { -// // yield break; -// // } -// // -// // if (data.line != null) -// // { -// // var linePrefab = data.line.Config.Instantiate(parent); -// // Line = linePrefab.GetComponent(); -// // } -// // -// // if (data.reel != null) -// // { -// // var reelPrefab = data.reel.Config.Create(parent); -// // Reel = reelPrefab.GetComponent(); -// // } -// // -// // if (data.bobber != null) -// // { -// // var bobberPrefab = data.bobber.Config.Create(parent); -// // Bobber = bobberPrefab.GetComponent(); -// // } -// // -// // if (data.hook != null) -// // { -// // var hookPrefab = data.hook.Config.Create(parent); -// // Hook = hookPrefab.GetComponent(); -// // } -// // -// // if (data.bait != null) -// // { -// // var baitPrefab = data.bait.Config.Create(parent); -// // -// // if (baitPrefab.TryGetComponent(out var bait)) -// // { -// // Bait = bait; -// // } -// // } -// // -// // if (data.lure != null) -// // { -// // var baitPrefab = data.lure.Config.Create(parent); -// // if (baitPrefab.TryGetComponent(out var lure)) -// // { -// // Lure = lure; -// // } -// // } -// // -// // -// // if (data.weight != null) -// // { -// // var weightPrefab = data.weight.Config.Instantiate(parent); -// // Weight = weightPrefab.GetComponent(); -// // } -// // -// // Debug.LogError("CreateOrHideGear"); -// // yield return 1; -// // Rod.Initialize(Player, data.rod); -// // Rod.CreateFishingHandler(); -// // -// // if (Line) -// // { -// // Line.Initialize(Player, data.line); -// // -// // -// // if ((bool)Rod.lineHandler.obiRopeSegment_1) -// // { -// // Rod.lineHandler.obiRopeSegment_1.GetComponent().material = -// // Line.lineMat; -// // } -// // -// // if ((bool)Rod.lineHandler.obiRopeSegment_2) -// // { -// // Rod.lineHandler.obiRopeSegment_2.GetComponent().material = -// // Line.lineMat; -// // } -// // -// // if ((bool)Rod.lineHandler.obiRopeSegment_3) -// // { -// // Rod.lineHandler.obiRopeSegment_3.GetComponent().material = -// // Line.lineMat; -// // } -// // } -// // -// // if (Reel) -// // { -// // // Reel.maxReelStrength = data.reel.Config.strength; -// // // Reel.reelingSpeed = 0.5f; //slotsEquip.reel.currentSpeed; -// // Reel.reelingDrag = 0.699f; //slotsEquip.reel.currentDrag; -// // Reel.transform.SetParent(Rod.rodAsset.ReelConnector); -// // Reel.transform.localPosition = Vector3.zero; -// // Reel.transform.localEulerAngles = Vector3.zero; -// // // Reel.reelAsset.szpulaObject.GetComponent().material = Line.szpulaMat; -// // Reel.Initialize(Player, data.reel); -// // } -// // -// // if (Bobber) -// // { -// // Bobber.floatDisplacement = data.bobber.Config.displacement; -// // // if ((double)slotsEquip.ffloat.lastSetGroundValue > 0.2) -// // // { -// // // Bobber.newDeepth = slotsEquip.ffloat.lastSetGroundValue; -// // // } -// // -// // Bobber.newDeepth = 0.5f; -// // -// // Bobber.Initialize(Player, data.bobber); -// // Bobber.transform.position = Rod.lineHandler.LineConnector_1.transform.position; -// // Bobber.gameObject.GetComponent().connectedBody = -// // Rod.lineHandler.LineConnector_1.GetComponent(); -// // } -// // -// // -// // if (Hook) -// // { -// // Hook.Initialize(Player, data.hook); -// // -// // Hook.transform.position = Rod.lineHandler.LineConnector_2.transform.position; -// // Hook.transform.rotation = Rod.lineHandler.LineConnector_2.transform.rotation; // 确保旋转也同步 -// // var target = Rod.lineHandler.LineConnector_2.GetComponent(); -// // var joint = Hook.gameObject.GetComponent(); -// // // // 关键设置:关闭自动锚点计算,手动设置锚点 -// // // joint.autoConfigureConnectedAnchor = false; -// // // joint.anchor = Vector3.zero; // 以 Hook 自身中心为锚点 -// // // joint.connectedAnchor = Vector3.zero; // 以目标物体的中心为锚点 -// // joint.connectedBody = target; -// // // // 强制物理引擎立即更新变换(避免1帧延迟) -// // // Physics.SyncTransforms(); -// // // joint.autoConfigureConnectedAnchor = false; -// // // joint.anchor = Vector3.zero; -// // // joint.connectedAnchor = Vector3.zero; -// // Rod.LureHookWaterDisplacement = Hook.GetComponent(); -// // } -// // -// // if (Bait) -// // { -// // Bait.Initialize(Player, data.bait); -// // Bait.transform.position = Hook.hookAsset.baitConnector.position; -// // Bait.transform.SetParent(Hook.hookAsset.baitConnector); -// // } -// // -// // if (Lure) -// // { -// // Lure.Initialize(Player, data.bait); -// // Lure.transform.position = Rod.lineHandler.LineConnector_1.transform.position; -// // Lure.gameObject.GetComponent().connectedBody = -// // Rod.lineHandler.LineConnector_1.GetComponent(); -// // Rod.LureHookWaterDisplacement = Lure.GetComponent(); -// // } -// // -// // if (Weight) -// // { -// // Weight.weight = data.weight.Config.weight; -// // Weight.Initialize(Player, data.weight); -// // } -// } -// -// public IEnumerator Destroy() -// { -// yield return 1; -// } -// } -// } \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Tackle/FVirtualTackle.cs.meta b/Assets/Scripts/Fishing/Tackle/FVirtualTackle.cs.meta deleted file mode 100644 index 2a6638b46..000000000 --- a/Assets/Scripts/Fishing/Tackle/FVirtualTackle.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4092f341d83540c0b6ba0e2db3669f1b -timeCreated: 1766478162 \ No newline at end of file diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs b/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs index b99cea1ff..0a5f6b2d5 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs @@ -4876,7 +4876,7 @@ namespace Fantasy MessageObjectPool.Return(this); } [ProtoMember(1)] - public long ConfigId { get; set; } + public int ConfigId { get; set; } [ProtoMember(2)] public int Count { get; set; } } @@ -4922,9 +4922,9 @@ namespace Fantasy MessageObjectPool.Return(this); } [ProtoMember(1)] - public long Item { get; set; } + public int Item { get; set; } [ProtoMember(2)] - public List BindItems { get; set; } = new List(); + public List BindItems { get; set; } = new List(); } /// /// 物品信息 diff --git a/Assets/Scripts/NBC/FSM.meta b/Assets/Scripts/NBC/FSM.meta index cacffe65b..8fdfd1b9a 100644 --- a/Assets/Scripts/NBC/FSM.meta +++ b/Assets/Scripts/NBC/FSM.meta @@ -1,3 +1,8 @@ fileFormatVersion: 2 guid: 8ef2143da4eb4506bd2956385af09162 -timeCreated: 1732110071 \ No newline at end of file +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.waveharmonic.crest/Runtime/Materials/Water Volume.mat b/Packages/com.waveharmonic.crest/Runtime/Materials/Water Volume.mat index 6c68558e8..ca31a78d1 100644 --- a/Packages/com.waveharmonic.crest/Runtime/Materials/Water Volume.mat +++ b/Packages/com.waveharmonic.crest/Runtime/Materials/Water Volume.mat @@ -12,26 +12,22 @@ Material: m_Parent: {fileID: 0} m_ModifiedSerializedProperties: 0 m_ValidKeywords: - - CREST_FLOW_ON - d_Crest_NoMaskDepth - d_Dithering m_InvalidKeywords: - - CREST_CAUSTICS_ON - - CREST_FOAM_ON - _ALPHATEST_ON - _BUILTIN_ALPHATEST_ON - _BUILTIN_AlphaClip - _BUILTIN_SURFACE_TYPE_TRANSPARENT - - _BUILTIN_TRANSPARENT_RECEIVES_SHADOWS - _DOUBLESIDED_ON - - _EMISSION - _ENABLE_FOG_ON_TRANSPARENT + - _REFRACTION_PLANE - _SURFACE_TYPE_TRANSPARENT - _TRANSPARENT_WRITES_MOTION_VEC - m_LightmapFlags: 4 + m_LightmapFlags: 2 m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: -1 + m_DoubleSidedGI: 1 + m_CustomRenderQueue: 3000 stringTagMap: {} disabledShaderPasses: [] m_LockedProperties: @@ -51,7 +47,7 @@ Material: - _Crest_DitheringEnabled: 1 - _Crest_Version: 0 m_Floats: - - CREST_FLOW: 1 + - CREST_FLOW: 0 - _Crest_AmbientTerm: 1 - _Crest_Anisotropy: 0.5 - _Crest_CausticsDepthOfField: 6