diff --git a/Assets/PlayerInputControl.inputactions b/Assets/PlayerInputControl.inputactions index 07986a7b7..1365a2e26 100644 --- a/Assets/PlayerInputControl.inputactions +++ b/Assets/PlayerInputControl.inputactions @@ -459,7 +459,7 @@ "id": "c1f7a91b-d0fd-4a62-997e-7fb9b69bf235", "path": "/rightStick", "interactions": "", - "processors": "", + "processors": "ScaleVector2(x=40,y=40)", "groups": ";Gamepad", "action": "Look", "isComposite": false, @@ -978,7 +978,7 @@ "id": "348bd961-a6a0-4d13-b414-83b43201bc10", "expectedControlType": "", "processors": "", - "interactions": "", + "interactions": "Hold", "initialStateCheck": false }, { @@ -987,7 +987,7 @@ "id": "da1344ed-a4b5-43ef-bad6-a3f6bb06ff23", "expectedControlType": "", "processors": "", - "interactions": "", + "interactions": "Hold", "initialStateCheck": false }, { @@ -996,7 +996,7 @@ "id": "dafd152b-aa0a-48bb-890d-289ab3a3e713", "expectedControlType": "", "processors": "", - "interactions": "", + "interactions": "Hold", "initialStateCheck": false }, { @@ -1005,7 +1005,7 @@ "id": "e0dbeebd-c69d-44bd-83de-94fcce8c6727", "expectedControlType": "", "processors": "", - "interactions": "", + "interactions": "Hold", "initialStateCheck": false }, { @@ -1041,6 +1041,28 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "e834d5a6-95f1-4142-9da6-4cbcc8618342", + "path": "/buttonEast", + "interactions": "", + "processors": "", + "groups": "", + "action": "Back", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "48a10b34-e3b4-4a90-98a2-95e128a3417a", + "path": "/buttonEast", + "interactions": "", + "processors": "", + "groups": "", + "action": "Back", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "a6e94404-e896-4fec-b3bf-affd31b12571", @@ -1052,6 +1074,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "7028032c-6c7f-4846-8d2c-a41c3c2822fd", + "path": "/buttonEast", + "interactions": "", + "processors": "", + "groups": "", + "action": "Enter", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "23dac47b-935f-4261-8044-a8612edf3fda", @@ -1074,6 +1107,28 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "5e809757-a6a4-4f89-9256-619af1216748", + "path": "/leftShoulder", + "interactions": "", + "processors": "", + "groups": "", + "action": "Prev", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "5a43b881-410f-4e67-913f-cbc379ae6953", + "path": "/leftShoulder", + "interactions": "", + "processors": "", + "groups": "", + "action": "Prev", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "2661bf5d-0afe-4f8c-a4e8-2aa6150c724d", @@ -1085,6 +1140,28 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "7250c0b2-9b1c-445e-8c8e-125dcf79e29f", + "path": "/rightShoulder", + "interactions": "", + "processors": "", + "groups": "", + "action": "Next", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "9fa9e49d-5262-4890-8ba2-6c84695f88aa", + "path": "/rightShoulder", + "interactions": "", + "processors": "", + "groups": "", + "action": "Next", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "487ceb23-336d-45f6-a782-3b4e9d9f0cd1", @@ -1096,6 +1173,28 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "589ddbb5-aedc-483d-957c-1fd7c1a12002", + "path": "/leftTrigger", + "interactions": "", + "processors": "", + "groups": "", + "action": "SubPrev", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "0fe51227-7d8b-4baa-9d25-8396deefc34d", + "path": "/leftTrigger", + "interactions": "", + "processors": "", + "groups": "", + "action": "SubPrev", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "463ec073-6e9d-4b1d-9956-8ec19838aa3e", @@ -1107,6 +1206,28 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "2c584e41-80cd-463e-8423-ac74c932c90b", + "path": "/rightTrigger", + "interactions": "", + "processors": "", + "groups": "", + "action": "SubNext", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "c8394c43-028f-4056-b5bd-f81395997f15", + "path": "/rightTrigger", + "interactions": "", + "processors": "", + "groups": "", + "action": "SubNext", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "053ddbac-9f73-4672-be59-abfdb6037aea", @@ -1118,6 +1239,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "2e150513-8adf-4e87-b5c9-cab09870835e", + "path": "/leftStick/right", + "interactions": "", + "processors": "", + "groups": "", + "action": "Right", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "031b930d-59b6-4a26-9dfe-97764c3e8b37", @@ -1129,6 +1261,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "dced9424-e4e1-40d9-8aea-b69491365e74", + "path": "/leftStick/left", + "interactions": "", + "processors": "", + "groups": "", + "action": "Left", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "45f78626-cbf2-4e1f-904d-d82e4c2a2f41", @@ -1140,6 +1283,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "2e119597-8f21-4c82-916c-57ffcd0f34c5", + "path": "/leftStick/down", + "interactions": "", + "processors": "", + "groups": "", + "action": "Down", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "f1a47b3c-e79f-4ab3-86b6-fcc0a6470114", @@ -1151,6 +1305,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "9a43ed61-260a-4f92-9e49-3df421db4051", + "path": "/leftStick/up", + "interactions": "", + "processors": "", + "groups": "", + "action": "Up", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "393f1eb9-d10d-4cd1-87e7-ea299f92b2da", diff --git a/Assets/Resources/GameItemsPrefabs/Lines/FFishingLine_0.prefab b/Assets/Resources/GameItemsPrefabs/Lines/FFishingLine_0.prefab index b1e95441e..dccf2ee49 100644 --- a/Assets/Resources/GameItemsPrefabs/Lines/FFishingLine_0.prefab +++ b/Assets/Resources/GameItemsPrefabs/Lines/FFishingLine_0.prefab @@ -713,17 +713,17 @@ MonoBehaviour: obiRopeSegment_1: {fileID: 114755058551407608} obiRopeSegment_2: {fileID: 114352801149539185} obiRopeSegment_3: {fileID: 0} - LineConnector_0: {fileID: 138430089226111772} + LineConnector_0: {fileID: 1161489717910266977} LineConnector_1: {fileID: 145801244473724727} LineConnector_2: {fileID: 145615548544929331} LineConnector_3: {fileID: 0} - currentRodFishingLineComponent: {fileID: 0} - toRodConnector: {fileID: 114110690660507634} ObiLineOut: 0 EndLineRigidbody_0: {fileID: 0} EndLineRigidbody_1: {fileID: 0} EndLineRigidbody_2: {fileID: 0} EndLineRigidbody_3: {fileID: 0} + pinchController: {fileID: 0} + Rod: {fileID: 0} --- !u!1 &1399535376626843 GameObject: m_ObjectHideFlags: 0 @@ -860,11 +860,10 @@ SpringJoint: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1399535376626843} - serializedVersion: 3 + serializedVersion: 4 m_ConnectedBody: {fileID: 54033698817467605} m_ConnectedArticulationBody: {fileID: 0} m_Anchor: {x: 0, y: 0, z: 0} - m_Axis: {x: 1, y: 0, z: 0} m_AutoConfigureConnectedAnchor: 0 m_ConnectedAnchor: {x: 0, y: 0, z: 0} m_Spring: 2500 @@ -891,7 +890,7 @@ GameObject: - component: {fileID: 23864529173902638} - component: {fileID: 54033698817467605} - component: {fileID: 114898669112954178} - - component: {fileID: 138430089226111772} + - component: {fileID: 1161489717910266977} m_Layer: 10 m_Name: LineConnector_0 m_TagString: Untagged @@ -1007,22 +1006,19 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: kinematicForParticles: 1 ---- !u!138 &138430089226111772 -FixedJoint: +--- !u!114 &1161489717910266977 +MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1584826894208304} - serializedVersion: 1 - m_ConnectedBody: {fileID: 0} - m_ConnectedArticulationBody: {fileID: 0} - m_BreakForce: Infinity - m_BreakTorque: Infinity - m_EnableCollision: 0 - m_EnablePreprocessing: 1 - m_MassScale: 1 - m_ConnectedMassScale: 1 + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 112f7ad42d8149c1944bb51067ef1966, type: 3} + m_Name: + m_EditorClassIdentifier: + target: {fileID: 0} --- !u!1 &1777911290578827 GameObject: m_ObjectHideFlags: 0 @@ -1159,11 +1155,10 @@ SpringJoint: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1777911290578827} - serializedVersion: 3 + serializedVersion: 4 m_ConnectedBody: {fileID: 54633220251865601} m_ConnectedArticulationBody: {fileID: 0} m_Anchor: {x: 0, y: 0, z: 0} - m_Axis: {x: 1, y: 0, z: 0} m_AutoConfigureConnectedAnchor: 0 m_ConnectedAnchor: {x: 0, y: 0, z: 0} m_Spring: 2000 diff --git a/Assets/Scripts/Common/Attrobites.meta b/Assets/Scripts/Common/Attrobites.meta new file mode 100644 index 000000000..d61788c9f --- /dev/null +++ b/Assets/Scripts/Common/Attrobites.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7cb50811095d496fad57afd7535d0f73 +timeCreated: 1748180763 \ No newline at end of file diff --git a/Assets/Scripts/Common/Attrobites/AttributeHelper.cs b/Assets/Scripts/Common/Attrobites/AttributeHelper.cs new file mode 100644 index 000000000..0a2417ea6 --- /dev/null +++ b/Assets/Scripts/Common/Attrobites/AttributeHelper.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace NBF +{ + public static class AttributeHelper + { + // 获取特定嵌套类中带有InputIconAttribute的常量字段 + public static Dictionary> GetNestedClassInputIconFields() + { + var result = new Dictionary>(); + + // 获取InputDef类型 + Type inputDefType = typeof(NBF.InputDef); + + // 检查UI类 + Type uiType = inputDefType.GetNestedType("UI"); + if (uiType != null) + { + var uiFields = GetInputIconFieldsFromType(uiType); + if (uiFields.Count > 0) + { + result.Add("UI", uiFields); + } + } + + // 检查Player类 + Type playerType = inputDefType.GetNestedType("Player"); + if (playerType != null) + { + var playerFields = GetInputIconFieldsFromType(playerType); + if (playerFields.Count > 0) + { + result.Add("Player", playerFields); + } + } + + return result; + } + + // 从特定类型获取带有InputIconAttribute的常量字段 + private static List GetInputIconFieldsFromType(Type type) + { + List result = new List(); + + // 只获取公共常量字段 + FieldInfo[] fields = type.GetFields( + BindingFlags.Public | + BindingFlags.Static | + BindingFlags.FlattenHierarchy); + + foreach (FieldInfo field in fields) + { + // 检查是否是常量且带有InputIconAttribute + if (field.IsLiteral && !field.IsInitOnly && + Attribute.IsDefined(field, typeof(InputIconAttribute))) + { + result.Add(field); + } + } + + return result; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Common/Attrobites/AttributeHelper.cs.meta b/Assets/Scripts/Common/Attrobites/AttributeHelper.cs.meta new file mode 100644 index 000000000..f77203f0f --- /dev/null +++ b/Assets/Scripts/Common/Attrobites/AttributeHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fa024ae7ea104f809ace6beff59c12d8 +timeCreated: 1748188551 \ No newline at end of file diff --git a/Assets/Scripts/Common/Attrobites/InputIconAttribute.cs b/Assets/Scripts/Common/Attrobites/InputIconAttribute.cs new file mode 100644 index 000000000..6451b3aab --- /dev/null +++ b/Assets/Scripts/Common/Attrobites/InputIconAttribute.cs @@ -0,0 +1,22 @@ +using System; + +namespace NBF +{ + [AttributeUsage(AttributeTargets.Field)] + public class InputIconAttribute : Attribute + { + public string KeyBoardIcon; + public string ControllerIcon; + + /// + /// + /// + /// 键盘图标 + /// 控制器图标 + public InputIconAttribute(string keyBoardIcon, string controllerIcon) + { + KeyBoardIcon = keyBoardIcon; + ControllerIcon = controllerIcon; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Common/Attrobites/InputIconAttribute.cs.meta b/Assets/Scripts/Common/Attrobites/InputIconAttribute.cs.meta new file mode 100644 index 000000000..9e9a57711 --- /dev/null +++ b/Assets/Scripts/Common/Attrobites/InputIconAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5fb17097160c43ee9840411aded17084 +timeCreated: 1748180773 \ No newline at end of file diff --git a/Assets/Scripts/Common/Input.meta b/Assets/Scripts/Common/Input.meta new file mode 100644 index 000000000..b57d0abc3 --- /dev/null +++ b/Assets/Scripts/Common/Input.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d846463d130b4191a5a4a9d2e2dfe45b +timeCreated: 1748180579 \ No newline at end of file diff --git a/Assets/Scripts/Common/Input/InputCursorExtension.cs b/Assets/Scripts/Common/Input/InputCursorExtension.cs new file mode 100644 index 000000000..52a6b0b6d --- /dev/null +++ b/Assets/Scripts/Common/Input/InputCursorExtension.cs @@ -0,0 +1,46 @@ +using NBC; + +namespace NBF +{ + public static class InputCursorExtension + { + public static void InputInit() + { + UI.Inst.On(UIEvents.UIShow, UIShow, null, 1); + UI.Inst.On(UIEvents.UIHide, UIHide, null, 1); + } + + public static void Dispose() + { + } + + private static void UIShow(EventArgs ev) + { + CheckUICursor(); + } + + private static void UIHide(EventArgs ev) + { + CheckUICursor(); + } + + + private static void CheckUICursor() + { + var uis = UI.Inst.GetAllUI(); + bool showCursor = false; + foreach (var ui in uis) + { + if (!ui.IsShowing) continue; + if (ui.IsShowCursor) + { + showCursor = true; + break; + } + } + Log.Error($"showCursor={showCursor}"); + InputManager.IsUIStopInput = showCursor; + InputManager.SetMouseCursor(showCursor); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Common/Input/InputCursorExtension.cs.meta b/Assets/Scripts/Common/Input/InputCursorExtension.cs.meta new file mode 100644 index 000000000..179b156b1 --- /dev/null +++ b/Assets/Scripts/Common/Input/InputCursorExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0644b8eb12e44351ab75b467f90d4c32 +timeCreated: 1748185434 \ No newline at end of file diff --git a/Assets/Scripts/Fishing/InputManager.cs b/Assets/Scripts/Common/Input/InputManager.cs similarity index 80% rename from Assets/Scripts/Fishing/InputManager.cs rename to Assets/Scripts/Common/Input/InputManager.cs index 860918191..89c18a3e6 100644 --- a/Assets/Scripts/Fishing/InputManager.cs +++ b/Assets/Scripts/Common/Input/InputManager.cs @@ -7,6 +7,12 @@ using UnityEngine.InputSystem; namespace NBF { + public enum ControllerType + { + KeyboardMouse = 0, + GamePad = 1 + } + public class InputManager : MonoBehaviour { public static InputManager Instance { get; private set; } @@ -44,17 +50,62 @@ namespace NBF public static PlayerInputControl PlayerInputControl { get; private set; } + /// + /// 手柄输入 + /// + public static bool IsControllerInput; + /// /// ui阻止游戏输入 /// public static bool IsUIStopInput; + public static ControllerType ControllerType = ControllerType.KeyboardMouse; + private void Awake() { Instance = this; + InputCursorExtension.InputInit(); DontDestroyOnLoad(gameObject); } + private void Start() + { + PlayerInputControl = new PlayerInputControl(); + PlayerInputControl.Enable(); + AddEvent(); + } + + private void OnDestroy() + { + RemoveEvent(); + InputCursorExtension.Dispose(); + } + + + public static void SetMouseCursor(bool val) + { + if (val) + { + if (ControllerType == ControllerType.KeyboardMouse) + { + Cursor.visible = true; + } + + Cursor.lockState = CursorLockMode.None; + } + else if (ControllerType == ControllerType.KeyboardMouse) + { + Cursor.visible = false; + } + + Cursor.visible = val; + if (!val) + { + Cursor.lockState = CursorLockMode.Confined; + } + } + public static Vector2 GetMovementInput() { if (IsUIStopInput) return Vector2.zero; @@ -67,17 +118,6 @@ namespace NBF return PlayerInputControl.Player.Look?.ReadValue() ?? Vector2.zero; } - private void Start() - { - PlayerInputControl = new PlayerInputControl(); - PlayerInputControl.Enable(); - AddEvent(); - } - - private void OnDestroy() - { - RemoveEvent(); - } private void AddEvent() { @@ -95,7 +135,7 @@ namespace NBF } } } - else if (actionMap.name == "Normal") + else if (actionMap.name == "Player") { foreach (var action in actionMap.actions) { @@ -139,6 +179,8 @@ namespace NBF { OnOp2Action?.Invoke(true); } + + OnPlayerPerformed?.Invoke(actionName); } private void OnPlayerButtonCanceled(InputAction.CallbackContext context) @@ -153,6 +195,8 @@ namespace NBF { OnOp2Action?.Invoke(false); } + + OnPlayerCanceled?.Invoke(actionName); } diff --git a/Assets/Scripts/Fishing/InputManager.cs.meta b/Assets/Scripts/Common/Input/InputManager.cs.meta similarity index 100% rename from Assets/Scripts/Fishing/InputManager.cs.meta rename to Assets/Scripts/Common/Input/InputManager.cs.meta diff --git a/Assets/Scripts/Common/PermanentCommon.cs b/Assets/Scripts/Common/PermanentCommon.cs new file mode 100644 index 000000000..d5c092582 --- /dev/null +++ b/Assets/Scripts/Common/PermanentCommon.cs @@ -0,0 +1,30 @@ +using NBC; +using UnityEngine; + +namespace NBF +{ + /// + /// 常驻公共脚本 + /// + public class PermanentCommon + { + private static bool _init; + private static PermanentCommon _inst; + + public static PermanentCommon Inst + { + get { return _inst ??= new PermanentCommon(); } + } + + public static void Init() + { + if (_init) return; + _init = true; + } + + public static void Dispose() + { + _init = false; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Common/PermanentCommon.cs.meta b/Assets/Scripts/Common/PermanentCommon.cs.meta new file mode 100644 index 000000000..c6bab4ecc --- /dev/null +++ b/Assets/Scripts/Common/PermanentCommon.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3816467cfd1648e685a33ebfd1d9fb7d +timeCreated: 1748184924 \ No newline at end of file diff --git a/Assets/Scripts/Def/InputDef.cs b/Assets/Scripts/Def/InputDef.cs index b7480eec5..9e056b876 100644 --- a/Assets/Scripts/Def/InputDef.cs +++ b/Assets/Scripts/Def/InputDef.cs @@ -1,27 +1,143 @@ -namespace NBF +using System; +using System.Collections.Generic; +using System.Reflection; +using NBC; +using UnityEngine; + +namespace NBF { public class InputDef { public class UI { + public static Dictionary> Icons = new Dictionary>(); + + [InputIcon("icon_controller_123", "icon_controller_2")] public const string Back = "Back"; + + [InputIcon("icon_controller_129", "icon_controller_1")] public const string Enter = "Enter"; + + [InputIcon("icon_controller_127", "icon_controller_19")] public const string Tab = "Tab"; + + [InputIcon("icon_controller_29", "icon_controller_89")] public const string Prev = "Prev"; + + [InputIcon("icon_controller_30", "icon_controller_77")] public const string Next = "Next"; + + [InputIcon("icon_controller_98", "icon_controller_27")] public const string SubPrev = "SubPrev"; + + [InputIcon("icon_controller_75", " icon_controller_28")] public const string SubNext = "SubNext"; - public const string Left = "Left"; - public const string Right = "Right"; - public const string Up = "Up"; - public const string Down = "Down"; + + [InputIcon("", "")] public const string Left = "Left"; + [InputIcon("", "")] public const string Right = "Right"; + [InputIcon("", "")] public const string Up = "Up"; + [InputIcon("", "")] public const string Down = "Down"; } - public class Player + public static class Player { + public static Dictionary> Icons = new Dictionary>(); public const string Run = "Run"; public const string Use1 = "Use1"; public const string Use2 = "Use2"; } + + #region Load Icon + + public static void LoadIcon() + { + // 获取InputDef类型 + Type inputDefType = typeof(NBF.InputDef); + + // 检查UI类 + Type uiType = inputDefType.GetNestedType("UI"); + if (uiType != null) + { + var uiFields = GetInputIconFieldsFromType(uiType); + if (uiFields.Count > 0) + { + foreach (var field in uiFields) + { + InputIconAttribute attribute = + (InputIconAttribute)Attribute.GetCustomAttribute(field, typeof(InputIconAttribute)); + + string value = (string)field.GetValue(null); // 获取常量值 + if (attribute != null) + { + List icons = new List + { + attribute.KeyBoardIcon, + attribute.ControllerIcon + }; + UI.Icons[value] = icons; + } + } + } + } + + // 检查Player类 + Type playerType = inputDefType.GetNestedType("Player"); + if (playerType != null) + { + var playerFields = GetInputIconFieldsFromType(playerType); + if (playerFields.Count > 0) + { + foreach (var field in playerFields) + { + InputIconAttribute attribute = + (InputIconAttribute)Attribute.GetCustomAttribute(field, typeof(InputIconAttribute)); + + string value = (string)field.GetValue(null); // 获取常量值 + if (attribute != null) + { + List icons = new List + { + attribute.KeyBoardIcon, + attribute.ControllerIcon + }; + Player.Icons[value] = icons; + } + } + } + } + + // foreach (var key in InputDef.UI.Icons.Keys) + // { + // var icons = InputDef.UI.Icons[key]; + // Log.Error($"KEY={key} icon={string.Join(",", icons)}"); + // } + } + + + // 从特定类型获取带有InputIconAttribute的常量字段 + private static List GetInputIconFieldsFromType(Type type) + { + List result = new List(); + + // 只获取公共常量字段 + FieldInfo[] fields = type.GetFields( + BindingFlags.Public | + BindingFlags.Static | + BindingFlags.FlattenHierarchy); + + foreach (FieldInfo field in fields) + { + // 检查是否是常量且带有InputIconAttribute + if (field.IsLiteral && !field.IsInitOnly && + Attribute.IsDefined(field, typeof(InputIconAttribute))) + { + result.Add(field); + } + } + + return result; + } + + #endregion } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Player/Gear/FHook.cs b/Assets/Scripts/Fishing/Player/Gear/FHook.cs index 009d8efd9..1f65df60f 100644 --- a/Assets/Scripts/Fishing/Player/Gear/FHook.cs +++ b/Assets/Scripts/Fishing/Player/Gear/FHook.cs @@ -103,12 +103,12 @@ public class FHook : FPlayerGear private void OnCollisionEnter(Collision collision) { - if (!waterDisplacement.isInWater && (bool)Owner.Gears.Rod && - (bool)Owner.Gears.Rod.lineHandler && !Owner.Gears.Rod.currentFish && - Owner.Data.lineLength > 5f && - Vector3.Distance(transform.position, Owner.Gears.Rod.transform.position) > 5f) - { - // GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("HOOK_ON_THE_GROUND"), FScriptsHandler.Instance.m_Canvas.transform, deleteLast: true); - } + // if (!waterDisplacement.isInWater && (bool)Owner.Gears.Rod && + // (bool)Owner.Gears.Rod.lineHandler && !Owner.Gears.Rod.currentFish && + // Owner.Data.lineLength > 5f && + // Vector3.Distance(transform.position, Owner.Gears.Rod.transform.position) > 5f) + // { + // GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("HOOK_ON_THE_GROUND"), FScriptsHandler.Instance.m_Canvas.transform, deleteLast: true); + // } } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Player/PlayerCharacter/PlayerCharacter.cs b/Assets/Scripts/Fishing/Player/PlayerCharacter/PlayerCharacter.cs index 1af3c67d7..7319c40f0 100644 --- a/Assets/Scripts/Fishing/Player/PlayerCharacter/PlayerCharacter.cs +++ b/Assets/Scripts/Fishing/Player/PlayerCharacter/PlayerCharacter.cs @@ -55,7 +55,7 @@ namespace NBF transform.position = _player.Data.position; transform.rotation = _player.Data.rotation; - App.Inst.SetMouseCurrsor(false); + InputManager.OnPlayerCanceled += OnPlayerCanceled; InputManager.OnPlayerPerformed += OnPlayerPerformed; // InputManager.OnRunAction += OnRunAction; @@ -192,7 +192,7 @@ namespace NBF { // Move Vector2 movementInput = InputManager.GetMovementInput(); - + Vector3 movementDirection = Vector3.zero; movementDirection += Vector3.forward * movementInput.y; diff --git a/Assets/Scripts/Fishing/PlayerInputControl.cs b/Assets/Scripts/Fishing/PlayerInputControl.cs index b7cb55a66..6b072226f 100644 --- a/Assets/Scripts/Fishing/PlayerInputControl.cs +++ b/Assets/Scripts/Fishing/PlayerInputControl.cs @@ -547,7 +547,7 @@ namespace NBF ""id"": ""c1f7a91b-d0fd-4a62-997e-7fb9b69bf235"", ""path"": ""/rightStick"", ""interactions"": """", - ""processors"": """", + ""processors"": ""ScaleVector2(x=40,y=40)"", ""groups"": "";Gamepad"", ""action"": ""Look"", ""isComposite"": false, @@ -1066,7 +1066,7 @@ namespace NBF ""id"": ""348bd961-a6a0-4d13-b414-83b43201bc10"", ""expectedControlType"": """", ""processors"": """", - ""interactions"": """", + ""interactions"": ""Hold"", ""initialStateCheck"": false }, { @@ -1075,7 +1075,7 @@ namespace NBF ""id"": ""da1344ed-a4b5-43ef-bad6-a3f6bb06ff23"", ""expectedControlType"": """", ""processors"": """", - ""interactions"": """", + ""interactions"": ""Hold"", ""initialStateCheck"": false }, { @@ -1084,7 +1084,7 @@ namespace NBF ""id"": ""dafd152b-aa0a-48bb-890d-289ab3a3e713"", ""expectedControlType"": """", ""processors"": """", - ""interactions"": """", + ""interactions"": ""Hold"", ""initialStateCheck"": false }, { @@ -1093,7 +1093,7 @@ namespace NBF ""id"": ""e0dbeebd-c69d-44bd-83de-94fcce8c6727"", ""expectedControlType"": """", ""processors"": """", - ""interactions"": """", + ""interactions"": ""Hold"", ""initialStateCheck"": false }, { @@ -1129,6 +1129,28 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""e834d5a6-95f1-4142-9da6-4cbcc8618342"", + ""path"": ""/buttonEast"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Back"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""48a10b34-e3b4-4a90-98a2-95e128a3417a"", + ""path"": ""/buttonEast"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Back"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""a6e94404-e896-4fec-b3bf-affd31b12571"", @@ -1140,6 +1162,17 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""7028032c-6c7f-4846-8d2c-a41c3c2822fd"", + ""path"": ""/buttonEast"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Enter"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""23dac47b-935f-4261-8044-a8612edf3fda"", @@ -1162,6 +1195,28 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""5e809757-a6a4-4f89-9256-619af1216748"", + ""path"": ""/leftShoulder"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Prev"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""5a43b881-410f-4e67-913f-cbc379ae6953"", + ""path"": ""/leftShoulder"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Prev"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""2661bf5d-0afe-4f8c-a4e8-2aa6150c724d"", @@ -1173,6 +1228,28 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""7250c0b2-9b1c-445e-8c8e-125dcf79e29f"", + ""path"": ""/rightShoulder"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Next"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""9fa9e49d-5262-4890-8ba2-6c84695f88aa"", + ""path"": ""/rightShoulder"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Next"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""487ceb23-336d-45f6-a782-3b4e9d9f0cd1"", @@ -1184,6 +1261,28 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""589ddbb5-aedc-483d-957c-1fd7c1a12002"", + ""path"": ""/leftTrigger"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""SubPrev"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""0fe51227-7d8b-4baa-9d25-8396deefc34d"", + ""path"": ""/leftTrigger"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""SubPrev"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""463ec073-6e9d-4b1d-9956-8ec19838aa3e"", @@ -1195,6 +1294,28 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""2c584e41-80cd-463e-8423-ac74c932c90b"", + ""path"": ""/rightTrigger"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""SubNext"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""c8394c43-028f-4056-b5bd-f81395997f15"", + ""path"": ""/rightTrigger"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""SubNext"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""053ddbac-9f73-4672-be59-abfdb6037aea"", @@ -1206,6 +1327,17 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""2e150513-8adf-4e87-b5c9-cab09870835e"", + ""path"": ""/leftStick/right"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Right"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""031b930d-59b6-4a26-9dfe-97764c3e8b37"", @@ -1217,6 +1349,17 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""dced9424-e4e1-40d9-8aea-b69491365e74"", + ""path"": ""/leftStick/left"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Left"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""45f78626-cbf2-4e1f-904d-d82e4c2a2f41"", @@ -1228,6 +1371,17 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""2e119597-8f21-4c82-916c-57ffcd0f34c5"", + ""path"": ""/leftStick/down"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Down"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""f1a47b3c-e79f-4ab3-86b6-fcc0a6470114"", @@ -1239,6 +1393,17 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""9a43ed61-260a-4f92-9e49-3df421db4051"", + ""path"": ""/leftStick/up"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Up"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""393f1eb9-d10d-4cd1-87e7-ea299f92b2da"", diff --git a/Assets/Scripts/NBC/UI/Runtime/Component/IUIPanel.cs b/Assets/Scripts/NBC/UI/Runtime/Component/IUIPanel.cs index e4b44fcca..b20cbad8d 100644 --- a/Assets/Scripts/NBC/UI/Runtime/Component/IUIPanel.cs +++ b/Assets/Scripts/NBC/UI/Runtime/Component/IUIPanel.cs @@ -18,7 +18,9 @@ namespace NBC bool IsDotDel { get; } bool IsModal { get; } - + + bool IsShowCursor { get; } + void SetUIManager(UIManager kit); void SetData(object args); object GetData(); diff --git a/Assets/Scripts/NBC/UI/Runtime/Component/UIPanel.cs b/Assets/Scripts/NBC/UI/Runtime/Component/UIPanel.cs index 36eec2686..53f4dc99a 100644 --- a/Assets/Scripts/NBC/UI/Runtime/Component/UIPanel.cs +++ b/Assets/Scripts/NBC/UI/Runtime/Component/UIPanel.cs @@ -35,6 +35,11 @@ namespace NBC /// public virtual int Id { get; protected set; } + /// + /// 是否显示光标,屏蔽游戏内输入 + /// + public virtual bool IsShowCursor { get; protected set; } + /// /// 面板打开动画 /// diff --git a/Assets/Scripts/Startup/App.cs b/Assets/Scripts/Startup/App.cs index b567dce03..1c0bafebd 100644 --- a/Assets/Scripts/Startup/App.cs +++ b/Assets/Scripts/Startup/App.cs @@ -1,4 +1,6 @@ -using System.Collections; +using System; +using System.Collections; +using System.Collections.Generic; using System.Reflection; using FairyGUI; using NBC; @@ -9,12 +11,6 @@ using UnityEngine.Video; namespace NBF { - public enum ControllerType - { - KeyboardMouse = 0, - GamePad = 1 - } - public class App : MonoBehaviour { public static App Inst { get; private set; } @@ -35,6 +31,11 @@ namespace NBF // new GameObject("GameManager").AddComponent(); } + private void OnDestroy() + { + PermanentCommon.Dispose(); + } + void Start() { ES3.Init(); @@ -85,9 +86,11 @@ namespace NBF public void StartGame() { + PermanentCommon.Init(); + InputDef.LoadIcon(); UI.Inst.OpenUI(); LoadData(); - //Fishing.Inst.Go(1); + // Fishing.Inst.Go(1); } private void LoadData() @@ -118,17 +121,15 @@ namespace NBF public ControllerType controllerType = ControllerType.GamePad; - public void SetMouseCurrsor(bool val) + public void SetMouseCursor(bool val) { if (val) { - // InputManager inputManager = FindObjectOfType(); if (controllerType == ControllerType.KeyboardMouse) { Cursor.visible = true; } - // inputManager.SetCursorPositionToScreenCenter(); Cursor.lockState = CursorLockMode.None; } else if (controllerType == ControllerType.KeyboardMouse) diff --git a/Assets/Scripts/UI/Shops/FishingShopPanel.cs b/Assets/Scripts/UI/Shops/FishingShopPanel.cs index f56aff711..b9ad12d88 100644 --- a/Assets/Scripts/UI/Shops/FishingShopPanel.cs +++ b/Assets/Scripts/UI/Shops/FishingShopPanel.cs @@ -24,6 +24,7 @@ namespace NBF { base.OnInit(); this.AutoAddClick(OnClick); + IsShowCursor = true; for (int i = 0; i < 10; i++) { diff --git a/Fishing2.sln.DotSettings.user b/Fishing2.sln.DotSettings.user index cf6daf4b4..ab2b19c66 100644 --- a/Fishing2.sln.DotSettings.user +++ b/Fishing2.sln.DotSettings.user @@ -1,4 +1,5 @@  + ForceIncluded ForceIncluded ForceIncluded ForceIncluded