From 1421c56fba57dace2f31afe50af68cb96be2b760 Mon Sep 17 00:00:00 2001 From: Tore Bergebakken Date: Sun, 17 Mar 2024 22:43:46 +0100 Subject: [PATCH] wip fix feedback --- Assets/Prefabs/Input/Player.prefab | 165 ++++++++++++++++-- Assets/Scenes/CraterTown.unity | 2 +- .../Input/PlayerControls.inputactions | 55 ++++++ .../Scripts/Control&Input/PlayerMovement.cs | 23 ++- Assets/Scripts/Gamestate/PlayerManager.cs | 31 +++- Assets/Scripts/UI/PauseMenu.cs | 11 +- 6 files changed, 252 insertions(+), 35 deletions(-) diff --git a/Assets/Prefabs/Input/Player.prefab b/Assets/Prefabs/Input/Player.prefab index 5e049893f..c24d88d8d 100644 --- a/Assets/Prefabs/Input/Player.prefab +++ b/Assets/Prefabs/Input/Player.prefab @@ -95,6 +95,7 @@ MonoBehaviour: steppingIgnoreMask: serializedVersion: 2 m_Bits: 1 + ShouldNotRespondToInputs: 0 --- !u!23 &71015680234268065 MeshRenderer: m_ObjectHideFlags: 0 @@ -1638,7 +1639,7 @@ GameObject: - component: {fileID: 2960949326746526939} - component: {fileID: 5186343667818732479} m_Layer: 5 - m_Name: DeathText + m_Name: Title m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1661,8 +1662,8 @@ RectTransform: 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_AnchoredPosition: {x: 533.3334, y: -190} + m_SizeDelta: {x: 800, y: 80} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &2960949326746526939 CanvasRenderer: @@ -1692,10 +1693,10 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: NOT PAUSED + m_text: HOWDY PARDNER m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: aa99fff0688574ba78204625170fa6e0, type: 2} - m_sharedMaterial: {fileID: 2100000, guid: a5dba56b90a3ca6978a283b93ad4fe3f, type: 2} + m_sharedMaterial: {fileID: 7168929159514863053, guid: aa99fff0688574ba78204625170fa6e0, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] @@ -1725,9 +1726,9 @@ MonoBehaviour: m_enableAutoSizing: 0 m_fontSizeMin: 18 m_fontSizeMax: 72 - m_fontStyle: 0 + m_fontStyle: 1 m_HorizontalAlignment: 2 - m_VerticalAlignment: 1024 + m_VerticalAlignment: 256 m_textAlignment: 65535 m_characterSpacing: 0 m_wordSpacing: 0 @@ -2292,6 +2293,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 8959131022343325934} + - {fileID: 7961745893845564163} - {fileID: 7972565997110201751} - {fileID: 3722375041483207122} m_Father: {fileID: 3570743071879246586} @@ -2632,6 +2634,141 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &7778794485325406989 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7961745893845564163} + - component: {fileID: 7436160053416547595} + - component: {fileID: 884870747379211561} + m_Layer: 5 + m_Name: Subtitle + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7961745893845564163 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7778794485325406989} + 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: 533.3334, y: -270} + m_SizeDelta: {x: 600, y: 40} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7436160053416547595 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7778794485325406989} + m_CullTransparentMesh: 1 +--- !u!114 &884870747379211561 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7778794485325406989} + 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: The game is 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: 40 + m_fontSizeBase: 40 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 1 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 256 + 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 &8105111567943840941 GameObject: m_ObjectHideFlags: 0 @@ -3585,7 +3722,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} propertyPath: m_SizeDelta.x - value: 300 + value: 400 objectReference: {fileID: 0} - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} propertyPath: m_SizeDelta.y @@ -3621,11 +3758,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} propertyPath: m_AnchoredPosition.x - value: 618.3755 + value: 533.3334 objectReference: {fileID: 0} - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} propertyPath: m_AnchoredPosition.y - value: -320 + value: -340 objectReference: {fileID: 0} - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -3730,7 +3867,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3765489543879290160, guid: e472bbf090cca566cae93eec176f8dff, type: 3} propertyPath: m_text - value: Leave + value: End Match objectReference: {fileID: 0} - target: {fileID: 3765489543879290160, guid: e472bbf090cca566cae93eec176f8dff, type: 3} propertyPath: m_fontSize @@ -3766,7 +3903,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} propertyPath: m_SizeDelta.x - value: 300 + value: 400 objectReference: {fileID: 0} - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} propertyPath: m_SizeDelta.y @@ -3802,11 +3939,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} propertyPath: m_AnchoredPosition.x - value: 618.3755 + value: 533.3334 objectReference: {fileID: 0} - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} propertyPath: m_AnchoredPosition.y - value: -400 + value: -420 objectReference: {fileID: 0} - target: {fileID: 5877506774103653876, guid: e472bbf090cca566cae93eec176f8dff, type: 3} propertyPath: m_LocalEulerAnglesHint.x diff --git a/Assets/Scenes/CraterTown.unity b/Assets/Scenes/CraterTown.unity index bfebacd27..e97bbee3a 100644 --- a/Assets/Scenes/CraterTown.unity +++ b/Assets/Scenes/CraterTown.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 662445327} - m_IndirectSpecularColor: {r: 0.09672264, g: 0.24035963, b: 0.4926994, a: 1} + m_IndirectSpecularColor: {r: 0.03905226, g: 0.20194778, b: 0.4885325, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: diff --git a/Assets/ScriptableObjects/Input/PlayerControls.inputactions b/Assets/ScriptableObjects/Input/PlayerControls.inputactions index d4ff37ec8..12fe311ff 100644 --- a/Assets/ScriptableObjects/Input/PlayerControls.inputactions +++ b/Assets/ScriptableObjects/Input/PlayerControls.inputactions @@ -499,6 +499,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "8f4504be-133a-4f66-b0d3-793290c87279", + "path": "/start", + "interactions": "", + "processors": "", + "groups": "", + "action": "Exit", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "846526c8-752a-4905-9e41-6ec6d2d80a37", @@ -509,6 +520,17 @@ "action": "Exit", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "3670069a-df39-40ea-8a7c-c4b797451183", + "path": "/p", + "interactions": "", + "processors": "", + "groups": "", + "action": "Exit", + "isComposite": false, + "isPartOfComposite": false } ] }, @@ -821,6 +843,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "b5e45b4a-8d1c-4a6b-90af-6270f64a9acf", + "path": "/start", + "interactions": "", + "processors": "", + "groups": "", + "action": "Exit", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "fe8cd325-d420-4946-a7f0-40e4e1c72e6e", @@ -831,6 +864,17 @@ "action": "Exit", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "be69b80f-1ccc-473a-9084-888986ef60df", + "path": "/p", + "interactions": "", + "processors": "", + "groups": "", + "action": "Exit", + "isComposite": false, + "isPartOfComposite": false } ] }, @@ -1028,6 +1072,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "55d97c0c-c237-4916-8da5-6e4d5ee4e368", + "path": "/start", + "interactions": "", + "processors": "", + "groups": "", + "action": "Exit", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "56f3ff90-eaed-417f-806b-5c5933c8b942", diff --git a/Assets/Scripts/Control&Input/PlayerMovement.cs b/Assets/Scripts/Control&Input/PlayerMovement.cs index 7751ea339..b2c3fb76a 100644 --- a/Assets/Scripts/Control&Input/PlayerMovement.cs +++ b/Assets/Scripts/Control&Input/PlayerMovement.cs @@ -156,17 +156,12 @@ protected virtual void Start() /// /// Function for setting a playerInput and adding movement related listeners to it. /// - /// - public void SetPlayerInput(InputManager player) + /// + public void SetPlayerInput(InputManager input) { - inputManager = player; + ReassignPlayerInput(input); var playerManager = GetComponent(); gunHolder = playerManager.GunHolder.gameObject; - inputManager.onSelect += OnJump; - inputManager.onCrouchPerformed += OnCrouch; - inputManager.onCrouchCanceled += OnCrouch; - inputManager.onZoomPerformed += OnZoom; - inputManager.onZoomCanceled += OnZoomCanceled; localCameraHeight = inputManager.transform.localPosition.y; localGunHolderX = gunHolder.transform.localPosition.x; localGunHolderHeight = gunHolder.transform.localPosition.y; @@ -177,6 +172,16 @@ public void SetPlayerInput(InputManager player) MatchController.Singleton.onRoundEnd += ResetZoom; } + public void ReassignPlayerInput(InputManager input) + { + inputManager = input; + inputManager.onSelect += OnJump; + inputManager.onCrouchPerformed += OnCrouch; + inputManager.onCrouchCanceled += OnCrouch; + inputManager.onZoomPerformed += OnZoom; + inputManager.onZoomCanceled += OnZoomCanceled; + } + public void SetInitialRotation(float radians) { aimAngle = new Vector2(radians, aimAngle.y); @@ -212,7 +217,7 @@ private void OnZoomCanceled(InputAction.CallbackContext ctx) CancelZoom(); } - private void CancelZoom() + public void CancelZoom() { LeanTween.value(gameObject, (fov) => playerCamera.fieldOfView = fov, playerCamera.fieldOfView, startingFov, 0.2f).setEaseInOutCubic(); gunHolder.LeanMoveLocalX(localGunHolderX, 0.2f); diff --git a/Assets/Scripts/Gamestate/PlayerManager.cs b/Assets/Scripts/Gamestate/PlayerManager.cs index c5b02d916..065d6d4e4 100644 --- a/Assets/Scripts/Gamestate/PlayerManager.cs +++ b/Assets/Scripts/Gamestate/PlayerManager.cs @@ -203,11 +203,25 @@ protected void TurnIntoRagdoll(DamageInfo info) /// public void SetPlayerInput(InputManager playerInput) { - inputManager = playerInput; - identity = inputManager.GetComponent(); + ListenToPlayerInput(playerInput); + var playerMovement = GetComponent(); playerMovement.SetPlayerInput(inputManager); playerMovement.onMove += UpdateHudOnMove; + + // Set camera on canvas + var canvas = hudController.GetComponent(); + canvas.worldCamera = inputManager.GetComponentInChildren(); + canvas.planeDistance = 0.11f; + + // Set player color + meshBase.GetComponentInChildren().material.color = identity.color; + } + + private void ListenToPlayerInput(InputManager playerInput) + { + inputManager = playerInput; + identity = inputManager.GetComponent(); // Subscribe relevant input events inputManager.onFirePerformed += Fire; inputManager.onFireCanceled += FireEnd; @@ -215,13 +229,14 @@ public void SetPlayerInput(InputManager playerInput) inputManager.onFirePerformed += TryPlaceBid; inputManager.onInteract += Interact; inputManager.onExit += OnPause; - // Set camera on canvas - var canvas = hudController.GetComponent(); - canvas.worldCamera = inputManager.GetComponentInChildren(); - canvas.planeDistance = 0.11f; + } - // Set player color - var meshRenderer = meshBase.GetComponentInChildren().material.color = identity.color; + public void ReassignPlayerInput(InputManager playerInput) + { + ListenToPlayerInput(playerInput); + + var playerMovement = GetComponent(); + playerMovement.ReassignPlayerInput(inputManager); } private void OnDestroy() diff --git a/Assets/Scripts/UI/PauseMenu.cs b/Assets/Scripts/UI/PauseMenu.cs index 2315e7db9..c161f016b 100644 --- a/Assets/Scripts/UI/PauseMenu.cs +++ b/Assets/Scripts/UI/PauseMenu.cs @@ -16,19 +16,24 @@ public void SetPlayerInput(InputManager input, PlayerManager player) this.player = player; this.input = input; gameObject.SetActive(true); + + var playerMovement = player.GetComponent(); + playerMovement.ShouldNotRespondToInputs = true; + playerMovement.CancelZoom(); + 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; + player.ReassignPlayerInput(input); + var playerMovement = player.GetComponent(); + playerMovement.ShouldNotRespondToInputs = false; } private void Resume(InputAction.CallbackContext ctx)