From 4f45ec5818e7ea869193bfb5f9bcd9846dc85729 Mon Sep 17 00:00:00 2001 From: Tore Bergebakken Date: Sat, 16 Mar 2024 18:30:30 +0100 Subject: [PATCH] Add basic "pause" menu --- Assets/Prefabs/Input/Player.prefab | 575 +++++++++++++++++- .../Input/PlayerControls.inputactions | 151 +++-- Assets/Scripts/Control&Input/InputManager.cs | 8 + .../PlayerInputManagerController.cs | 12 +- .../Scripts/Control&Input/PlayerMovement.cs | 9 +- Assets/Scripts/Gamestate/PlayerManager.cs | 8 +- .../Scripts/Interactables/CollectableChip.cs | 2 +- Assets/Scripts/UI/PauseMenu.cs | 43 ++ Assets/Scripts/UI/PauseMenu.cs.meta | 11 + Assets/Scripts/UI/PlayerHUDController.cs | 3 + 10 files changed, 749 insertions(+), 73 deletions(-) create mode 100644 Assets/Scripts/UI/PauseMenu.cs create mode 100644 Assets/Scripts/UI/PauseMenu.cs.meta diff --git a/Assets/Prefabs/Input/Player.prefab b/Assets/Prefabs/Input/Player.prefab index e7639e818..5e049893f 100644 --- a/Assets/Prefabs/Input/Player.prefab +++ b/Assets/Prefabs/Input/Player.prefab @@ -66,6 +66,7 @@ MonoBehaviour: m_Bits: 65399 lookSpeed: 3 LookSpeedZoom: 0.75 + mouseZoomSpeedFactor: 0.1 groundDrag: 6 airDrag: 1 maxVelocityBeforeExtraDamping: 10 @@ -884,7 +885,7 @@ GameObject: - component: {fileID: 1053768020010034934} - component: {fileID: 4217260705503384286} m_Layer: 5 - m_Name: Panel + m_Name: DeathScreen m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1326,6 +1327,7 @@ RectTransform: - {fileID: 1417967732049705392} - {fileID: 4777486860895138767} - {fileID: 4412023050163012269} + - {fileID: 9062846435806837360} m_Father: {fileID: 71015680234268071} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -1360,6 +1362,7 @@ MonoBehaviour: deathScreen: {fileID: 1029316632486890240} deathText: {fileID: 9172283963218471322} damageBorderFlashDuration: 0.2 + pauseMenu: {fileID: 9026255908890535554} popupSpammer: {fileID: 6535424167945181997} speedLines: {fileID: 1712702864845135441} speedLineEase: @@ -1436,7 +1439,7 @@ MonoBehaviour: m_ScaleFactor: 1 m_ReferenceResolution: {x: 800, y: 600} m_ScreenMatchMode: 0 - m_MatchWidthOrHeight: 0 + m_MatchWidthOrHeight: 1 m_PhysicalUnit: 3 m_FallbackScreenDPI: 96 m_DefaultSpriteDPI: 96 @@ -1623,6 +1626,141 @@ SortingGroup: m_SortingLayer: 0 m_SortingOrder: 1 m_SortAtRoot: 0 +--- !u!1 &4031715069306126866 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8959131022343325934} + - component: {fileID: 2960949326746526939} + - component: {fileID: 5186343667818732479} + m_Layer: 5 + m_Name: DeathText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8959131022343325934 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4031715069306126866} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 9062846435806837360} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 618.3755, y: -220} + m_SizeDelta: {x: 600, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2960949326746526939 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4031715069306126866} + m_CullTransparentMesh: 1 +--- !u!114 &5186343667818732479 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4031715069306126866} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: NOT PAUSED + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: aa99fff0688574ba78204625170fa6e0, type: 2} + m_sharedMaterial: {fileID: 2100000, guid: a5dba56b90a3ca6978a283b93ad4fe3f, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 80 + m_fontSizeBase: 80 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 1024 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} --- !u!1 &4536483048541249167 GameObject: m_ObjectHideFlags: 0 @@ -2002,7 +2140,7 @@ RectTransform: m_GameObject: {fileID: 5696341598124916686} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalScale: {x: 0.1, y: 0.1, z: 0.1} m_ConstrainProportionsScale: 1 m_Children: [] m_Father: {fileID: 8513528357214213258} @@ -2068,8 +2206,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 0.6 - m_fontSizeBase: 0.6 + m_fontSize: 6 + m_fontSizeBase: 6 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 18 @@ -2122,6 +2260,95 @@ SortingGroup: m_SortingLayer: 0 m_SortingOrder: 3 m_SortAtRoot: 0 +--- !u!1 &6761098110666084126 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 9062846435806837360} + - component: {fileID: 31868674008252044} + - component: {fileID: 3547151340487049972} + - component: {fileID: 9026255908890535554} + m_Layer: 5 + m_Name: PauseMenu + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &9062846435806837360 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6761098110666084126} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 8959131022343325934} + - {fileID: 7972565997110201751} + - {fileID: 3722375041483207122} + m_Father: {fileID: 3570743071879246586} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &31868674008252044 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6761098110666084126} + m_CullTransparentMesh: 1 +--- !u!114 &3547151340487049972 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6761098110666084126} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_ChildAlignment: 4 + m_Spacing: 20 + m_ChildForceExpandWidth: 0 + m_ChildForceExpandHeight: 0 + m_ChildControlWidth: 0 + m_ChildControlHeight: 0 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 + m_ReverseArrangement: 0 +--- !u!114 &9026255908890535554 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6761098110666084126} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c1ad5a90f418f9b49957689cdff9f045, type: 3} + m_Name: + m_EditorClassIdentifier: + initiallySelectedButton: {fileID: 3053268689299130685} --- !u!1 &6847997470167737139 GameObject: m_ObjectHideFlags: 0 @@ -3280,3 +3507,341 @@ Transform: m_CorrespondingSourceObject: {fileID: 6673173064753799651, guid: 27ac4408b426ae745a1792dde18c79ba, type: 3} m_PrefabInstance: {fileID: 3287810421515891185} m_PrefabAsset: {fileID: 0} +--- !u!1001 &4554590363426943075 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 9062846435806837360} + m_Modifications: + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_Navigation.m_SelectOnUp + value: + objectReference: {fileID: 8598450697563878776} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_Navigation.m_SelectOnDown + value: + objectReference: {fileID: 8598450697563878776} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: 9026255908890535554} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: Resume + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName + value: PauseMenu, Assembly-CSharp + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 3765489543879290160, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_text + value: Resume + objectReference: {fileID: 0} + - target: {fileID: 3765489543879290160, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_fontSize + value: 60 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_RootOrder + value: -1 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_AnchorMin.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_SizeDelta.x + value: 300 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_SizeDelta.y + value: 60 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_AnchoredPosition.x + value: 618.3755 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_AnchoredPosition.y + value: -320 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7072107538278606930, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_Name + value: Resume + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: e472bbf090cca566cae93eec176f8dff, type: 3} +--- !u!114 &3053268689299130685 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + m_PrefabInstance: {fileID: 4554590363426943075} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!224 &7972565997110201751 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + m_PrefabInstance: {fileID: 4554590363426943075} + m_PrefabAsset: {fileID: 0} +--- !u!1001 &7077847880157137958 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 9062846435806837360} + m_Modifications: + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_Navigation.m_SelectOnUp + value: + objectReference: {fileID: 3053268689299130685} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_Navigation.m_SelectOnDown + value: + objectReference: {fileID: 3053268689299130685} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_Mode + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: 9026255908890535554} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: Leave + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_MethodName + value: MoveToDefault + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[2].m_MethodName + value: + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName + value: PauseMenu, Assembly-CSharp + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_TargetAssemblyTypeName + value: MainMenuMoveCamera, Assembly-CSharp + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[2].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: + objectReference: {fileID: 0} + - target: {fileID: 3765489543879290160, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_text + value: Leave + objectReference: {fileID: 0} + - target: {fileID: 3765489543879290160, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_fontSize + value: 60 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_RootOrder + value: -1 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_AnchorMin.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_SizeDelta.x + value: 300 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_SizeDelta.y + value: 60 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_AnchoredPosition.x + value: 618.3755 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_AnchoredPosition.y + value: -400 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7072107538278606930, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + propertyPath: m_Name + value: Leave + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: e472bbf090cca566cae93eec176f8dff, type: 3} +--- !u!224 &3722375041483207122 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + m_PrefabInstance: {fileID: 7077847880157137958} + m_PrefabAsset: {fileID: 0} +--- !u!114 &8598450697563878776 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1543121137935169886, guid: e472bbf090cca566cae93eec176f8dff, type: 3} + m_PrefabInstance: {fileID: 7077847880157137958} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/ScriptableObjects/Input/PlayerControls.inputactions b/Assets/ScriptableObjects/Input/PlayerControls.inputactions index 67f172272..d4ff37ec8 100644 --- a/Assets/ScriptableObjects/Input/PlayerControls.inputactions +++ b/Assets/ScriptableObjects/Input/PlayerControls.inputactions @@ -58,6 +58,15 @@ "processors": "", "interactions": "", "initialStateCheck": false + }, + { + "name": "Exit", + "type": "Button", + "id": "59e83c07-8e52-4bf8-9438-5a6d37054de2", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false } ], "bindings": [ @@ -284,7 +293,7 @@ { "name": "", "id": "0030f558-1dce-4039-95e4-2c065ead1db1", - "path": "/escape", + "path": "/backspace", "interactions": "", "processors": "", "groups": "MouseAndKeyboard", @@ -478,6 +487,28 @@ "action": "LeftTab", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "9a1572fe-6205-45fc-8244-3502f75c7d39", + "path": "/select", + "interactions": "", + "processors": "", + "groups": "", + "action": "Exit", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "846526c8-752a-4905-9e41-6ec6d2d80a37", + "path": "/escape", + "interactions": "", + "processors": "", + "groups": "", + "action": "Exit", + "isComposite": false, + "isPartOfComposite": false } ] }, @@ -494,15 +525,6 @@ "interactions": "", "initialStateCheck": false }, - { - "name": "Cancel", - "type": "Button", - "id": "6c813086-0914-48e7-a994-f4c36f04f63c", - "expectedControlType": "Button", - "processors": "", - "interactions": "", - "initialStateCheck": false - }, { "name": "Move", "type": "Value", @@ -556,6 +578,15 @@ "processors": "", "interactions": "", "initialStateCheck": false + }, + { + "name": "Exit", + "type": "Button", + "id": "6c813086-0914-48e7-a994-f4c36f04f63c", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false } ], "bindings": [ @@ -581,28 +612,6 @@ "isComposite": false, "isPartOfComposite": false }, - { - "name": "", - "id": "898c171c-67f9-4de3-b99e-3eea3e5a4dda", - "path": "/buttonEast", - "interactions": "", - "processors": "", - "groups": "Gamepad", - "action": "Cancel", - "isComposite": false, - "isPartOfComposite": false - }, - { - "name": "", - "id": "fe8cd325-d420-4946-a7f0-40e4e1c72e6e", - "path": "/escape", - "interactions": "", - "processors": "", - "groups": "MouseAndKeyboard", - "action": "Cancel", - "isComposite": false, - "isPartOfComposite": false - }, { "name": "", "id": "65cc362b-78a9-46ba-b196-d471cbc76387", @@ -800,6 +809,28 @@ "action": "Interact", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "898c171c-67f9-4de3-b99e-3eea3e5a4dda", + "path": "/select", + "interactions": "", + "processors": "", + "groups": "Gamepad", + "action": "Exit", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "fe8cd325-d420-4946-a7f0-40e4e1c72e6e", + "path": "/escape", + "interactions": "", + "processors": "", + "groups": "MouseAndKeyboard", + "action": "Exit", + "isComposite": false, + "isPartOfComposite": false } ] }, @@ -826,27 +857,27 @@ "initialStateCheck": true }, { - "name": "Cancel", + "name": "Select", "type": "Button", - "id": "9e0bf922-98f3-49e8-9ea8-7897bbb5249f", + "id": "81e31669-1c45-46b3-b49d-6daa89095b81", "expectedControlType": "Button", "processors": "", "interactions": "", "initialStateCheck": false }, { - "name": "Select", + "name": "Interact", "type": "Button", - "id": "81e31669-1c45-46b3-b49d-6daa89095b81", + "id": "360c3d67-b75e-4f1a-8700-e3d62ef4f857", "expectedControlType": "Button", "processors": "", "interactions": "", "initialStateCheck": false }, { - "name": "Interact", + "name": "Exit", "type": "Button", - "id": "360c3d67-b75e-4f1a-8700-e3d62ef4f857", + "id": "9e0bf922-98f3-49e8-9ea8-7897bbb5249f", "expectedControlType": "Button", "processors": "", "interactions": "", @@ -942,28 +973,6 @@ "isComposite": false, "isPartOfComposite": true }, - { - "name": "", - "id": "4b0e4d83-9aaf-4d27-8ef7-830284a247cc", - "path": "/buttonEast", - "interactions": "", - "processors": "", - "groups": "Gamepad", - "action": "Cancel", - "isComposite": false, - "isPartOfComposite": false - }, - { - "name": "", - "id": "56f3ff90-eaed-417f-806b-5c5933c8b942", - "path": "/escape", - "interactions": "", - "processors": "", - "groups": "MouseAndKeyboard", - "action": "Cancel", - "isComposite": false, - "isPartOfComposite": false - }, { "name": "", "id": "5d89d078-c0ba-4983-9a06-ce3dd87d1f5d", @@ -1007,6 +1016,28 @@ "action": "Interact", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "4b0e4d83-9aaf-4d27-8ef7-830284a247cc", + "path": "/select", + "interactions": "", + "processors": "", + "groups": "Gamepad", + "action": "Exit", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "56f3ff90-eaed-417f-806b-5c5933c8b942", + "path": "/escape", + "interactions": "", + "processors": "", + "groups": "MouseAndKeyboard", + "action": "Exit", + "isComposite": false, + "isPartOfComposite": false } ] } diff --git a/Assets/Scripts/Control&Input/InputManager.cs b/Assets/Scripts/Control&Input/InputManager.cs index f0b651f61..613de0be8 100644 --- a/Assets/Scripts/Control&Input/InputManager.cs +++ b/Assets/Scripts/Control&Input/InputManager.cs @@ -16,6 +16,7 @@ public class InputManager : MonoBehaviour // Menu-related public InputEvent onSelect; public InputEvent onCancel; + public InputEvent onExit; public InputEvent onLeftTab; public InputEvent onRightTab; public InputEvent onAnyKey; @@ -79,6 +80,7 @@ public void AddListeners() playerInput.actions["Join"].performed += AnyKey; playerInput.actions["Select"].performed += Select; playerInput.actions["Cancel"].performed += Cancel; + playerInput.actions["Exit"].performed += Exit; playerInput.actions["Move"].performed += Move; playerInput.actions["Move"].canceled += Move; playerInput.actions["LeftTab"].performed += LeftTab; @@ -159,6 +161,7 @@ private void RemoveAllListeners() // Abusing that empty delegate bodies are defined as null to remove all invocation lists. onSelect = null; onCancel = null; + onExit = null; onMovePerformed = null; onMoveCanceled = null; onLeftTab = null; @@ -196,6 +199,11 @@ private void Cancel(InputAction.CallbackContext ctx) onCancel?.Invoke(ctx); } + private void Exit(InputAction.CallbackContext ctx) + { + onExit?.Invoke(ctx); + } + private void LeftTab(InputAction.CallbackContext ctx) { onLeftTab?.Invoke(ctx); diff --git a/Assets/Scripts/Control&Input/PlayerInputManagerController.cs b/Assets/Scripts/Control&Input/PlayerInputManagerController.cs index 3d5c7bc33..981498587 100644 --- a/Assets/Scripts/Control&Input/PlayerInputManagerController.cs +++ b/Assets/Scripts/Control&Input/PlayerInputManagerController.cs @@ -79,10 +79,7 @@ public void ChangeInputMaps(string mapNameOrId) { playerInputs.ForEach(playerInput => { - playerInput.playerInput.SwitchCurrentActionMap(mapNameOrId); - playerInput.RemoveListeners(); - playerInput.AddListeners(); - + ChangeInputMapForPlayer(mapNameOrId, playerInput); // Free the playerInputs from their mortail coils (Player prefab or similar assets) var previousParent = playerInput.transform.parent; playerInput.transform.parent = null; @@ -91,4 +88,11 @@ public void ChangeInputMaps(string mapNameOrId) Destroy(previousParent.gameObject); }); } + + public void ChangeInputMapForPlayer(string mapNameOrId, InputManager playerInput) + { + playerInput.playerInput.SwitchCurrentActionMap(mapNameOrId); + playerInput.RemoveListeners(); + playerInput.AddListeners(); + } } diff --git a/Assets/Scripts/Control&Input/PlayerMovement.cs b/Assets/Scripts/Control&Input/PlayerMovement.cs index 928faba5d..b65a42427 100644 --- a/Assets/Scripts/Control&Input/PlayerMovement.cs +++ b/Assets/Scripts/Control&Input/PlayerMovement.cs @@ -141,6 +141,8 @@ public class PlayerMovement : MonoBehaviour [SerializeField] protected LayerMask steppingIgnoreMask; + public bool ShouldNotRespondToInputs = false; + protected virtual void Start() { @@ -343,6 +345,8 @@ protected void UpdatePosition(Vector3 input) private void UpdateRotation() { + if (ShouldNotRespondToInputs) + return; var lookSpeedFactor = inputManager.ZoomActive ? inputManager.IsMouseAndKeyboard ? LookSpeedZoom * mouseZoomSpeedFactor : LookSpeedZoom : lookSpeed; @@ -368,7 +372,7 @@ protected void UpdateAnimatorParameters() animator.SetFloat("Right", Vector3.Dot(body.velocity, transform.right) / maxVelocityBeforeExtraDamping); } - void OnDrawGizmos() + private void OnDrawGizmos() { if (!hitbox) return; var extents = new Vector3(1, 1.5f + airThreshold, 1); @@ -426,6 +430,7 @@ private void OnStepDetected(RaycastHit raycastHit, Vector3 rayDirection) } } } + protected virtual void FixedUpdate() { if (FindSteppingGround() && body.velocity.magnitude > 0.08f) @@ -433,7 +438,7 @@ protected virtual void FixedUpdate() FindStep(); } - var positionInput = new Vector3(inputManager.moveInput.x, 0, inputManager.moveInput.y); + var positionInput = ShouldNotRespondToInputs ? Vector3.zero : new Vector3(inputManager.moveInput.x, 0, inputManager.moveInput.y); UpdatePosition(positionInput); // Limit velocity when not grounded if (state == PlayerState.GROUNDED) diff --git a/Assets/Scripts/Gamestate/PlayerManager.cs b/Assets/Scripts/Gamestate/PlayerManager.cs index 1809c0999..988664711 100644 --- a/Assets/Scripts/Gamestate/PlayerManager.cs +++ b/Assets/Scripts/Gamestate/PlayerManager.cs @@ -168,6 +168,11 @@ void OnDeath(HealthController healthController, float damage, DamageInfo info) playerShadow.gameObject.SetActive(false); } + private void OnPause(InputAction.CallbackContext ctx) + { + hudController?.PauseMenu?.SetPlayerInput(inputManager, this); + } + protected void TurnIntoRagdoll(DamageInfo info) { GetComponent().GetAccumulatedForce(); @@ -209,6 +214,7 @@ public void SetPlayerInput(InputManager playerInput) inputManager.onSelect += TryPlaceBid; inputManager.onFirePerformed += TryPlaceBid; inputManager.onInteract += Interact; + inputManager.onExit += OnPause; // Set camera on canvas var canvas = hudController.GetComponent(); canvas.worldCamera = inputManager.GetComponentInChildren(); @@ -218,7 +224,7 @@ public void SetPlayerInput(InputManager playerInput) var meshRenderer = meshBase.GetComponentInChildren().material.color = identity.color; } - void OnDestroy() + private void OnDestroy() { if (healthController) { diff --git a/Assets/Scripts/Interactables/CollectableChip.cs b/Assets/Scripts/Interactables/CollectableChip.cs index 9291a87c3..9425a6a7a 100644 --- a/Assets/Scripts/Interactables/CollectableChip.cs +++ b/Assets/Scripts/Interactables/CollectableChip.cs @@ -11,7 +11,7 @@ public class CollectableChip : MonoBehaviour private AudioSource audioSource; - void Start() + private void Start() { audioSource = GetComponent(); // Animate spin and bounce diff --git a/Assets/Scripts/UI/PauseMenu.cs b/Assets/Scripts/UI/PauseMenu.cs new file mode 100644 index 000000000..2315e7db9 --- /dev/null +++ b/Assets/Scripts/UI/PauseMenu.cs @@ -0,0 +1,43 @@ +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.InputSystem; +using UnityEngine.UI; + +public class PauseMenu : MonoBehaviour +{ + [SerializeField] private Selectable initiallySelectedButton; + + private PlayerManager player; + + private InputManager input; + + public void SetPlayerInput(InputManager input, PlayerManager player) + { + this.player = player; + this.input = input; + gameObject.SetActive(true); + EventSystem.current.SetSelectedGameObject(initiallySelectedButton.gameObject); + PlayerInputManagerController.Singleton.ChangeInputMapForPlayer("Menu", input); + input.onExit += Resume; + input.onCancel += Resume; + player.GetComponent().ShouldNotRespondToInputs = true; + } + + public void Resume() + { + gameObject.SetActive(false); + PlayerInputManagerController.Singleton.ChangeInputMapForPlayer("FPS", input); + player.SetPlayerInput(input); + player.GetComponent().ShouldNotRespondToInputs = false; + } + + private void Resume(InputAction.CallbackContext ctx) + { + Resume(); + } + + public void Leave() + { + MatchController.Singleton.ReturnToMainMenu(); + } +} diff --git a/Assets/Scripts/UI/PauseMenu.cs.meta b/Assets/Scripts/UI/PauseMenu.cs.meta new file mode 100644 index 000000000..5e931998d --- /dev/null +++ b/Assets/Scripts/UI/PauseMenu.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c1ad5a90f418f9b49957689cdff9f045 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI/PlayerHUDController.cs b/Assets/Scripts/UI/PlayerHUDController.cs index b8301e01a..3e7bd262a 100644 --- a/Assets/Scripts/UI/PlayerHUDController.cs +++ b/Assets/Scripts/UI/PlayerHUDController.cs @@ -70,6 +70,9 @@ public class PlayerHUDController : MonoBehaviour private Material damageBorder; + [SerializeField] + private PauseMenu pauseMenu; + public PauseMenu PauseMenu => pauseMenu; [Header("Effects")]