From 5a94688fe778a6cfe25751907ad504a271874312 Mon Sep 17 00:00:00 2001 From: Ali Sharoz Date: Fri, 17 Jan 2025 16:24:10 +0500 Subject: [PATCH] Input Enabling after starting timer, Spawning Players in Center. --- .../DOTween/Modules/DOTween.Modules.asmdef | 3 + .../Modules/DOTween.Modules.asmdef.meta | 7 + .../Modules/DOTweenModuleEPOOutline.cs | 2 +- .../DOTween/Modules/DOTweenModuleUI.cs | 2 +- Assets/Resources/DOTweenSettings.asset | 4 +- Assets/Scenes/BossRoom.unity | 120 ++++++++++++++---- .../{ => Scripts/Gameplay}/StartingTimer.cs | 20 +-- .../Gameplay}/StartingTimer.cs.meta | 0 .../Gameplay/UserInput/ClientInputSender.cs | 43 +++++-- 9 files changed, 150 insertions(+), 51 deletions(-) create mode 100644 Assets/Plugins/Demigiant/DOTween/Modules/DOTween.Modules.asmdef create mode 100644 Assets/Plugins/Demigiant/DOTween/Modules/DOTween.Modules.asmdef.meta rename Assets/{ => Scripts/Gameplay}/StartingTimer.cs (82%) rename Assets/{ => Scripts/Gameplay}/StartingTimer.cs.meta (100%) diff --git a/Assets/Plugins/Demigiant/DOTween/Modules/DOTween.Modules.asmdef b/Assets/Plugins/Demigiant/DOTween/Modules/DOTween.Modules.asmdef new file mode 100644 index 0000000..42ef5ab --- /dev/null +++ b/Assets/Plugins/Demigiant/DOTween/Modules/DOTween.Modules.asmdef @@ -0,0 +1,3 @@ +{ + "name": "DOTween.Modules" +} diff --git a/Assets/Plugins/Demigiant/DOTween/Modules/DOTween.Modules.asmdef.meta b/Assets/Plugins/Demigiant/DOTween/Modules/DOTween.Modules.asmdef.meta new file mode 100644 index 0000000..7ded291 --- /dev/null +++ b/Assets/Plugins/Demigiant/DOTween/Modules/DOTween.Modules.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ff4724f625c200e41898c4c243029c10 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleEPOOutline.cs b/Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleEPOOutline.cs index 2ab3775..e806b3b 100644 --- a/Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleEPOOutline.cs +++ b/Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleEPOOutline.cs @@ -1,4 +1,4 @@ -using UnityEngine; +using UnityEngine; #if false || EPO_DOTWEEN // MODULE_MARKER diff --git a/Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleUI.cs b/Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleUI.cs index 2381f4c..7fe2fa4 100644 --- a/Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleUI.cs +++ b/Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleUI.cs @@ -1,4 +1,4 @@ -// Author: Daniele Giardini - http://www.demigiant.com +// Author: Daniele Giardini - http://www.demigiant.com // Created: 2018/07/13 #if true // MODULE_MARKER diff --git a/Assets/Resources/DOTweenSettings.asset b/Assets/Resources/DOTweenSettings.asset index 62ebbaf..831ef92 100644 --- a/Assets/Resources/DOTweenSettings.asset +++ b/Assets/Resources/DOTweenSettings.asset @@ -22,7 +22,7 @@ MonoBehaviour: maxSmoothUnscaledTime: 0.15 rewindCallbackMode: 0 showUnityEditorReport: 0 - logBehaviour: 0 + logBehaviour: 2 drawGizmos: 1 defaultRecyclable: 0 defaultAutoPlay: 3 @@ -49,6 +49,6 @@ MonoBehaviour: deAudioEnabled: 0 deUnityExtendedEnabled: 0 epoOutlineEnabled: 0 - createASMDEF: 0 + createASMDEF: 1 showPlayingTweens: 0 showPausedTweens: 0 diff --git a/Assets/Scenes/BossRoom.unity b/Assets/Scenes/BossRoom.unity index 10b0cac..8a9a499 100644 --- a/Assets/Scenes/BossRoom.unity +++ b/Assets/Scenes/BossRoom.unity @@ -8641,7 +8641,7 @@ PrefabInstance: m_Modifications: - target: {fileID: 205271637847874222, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.x - value: 0.59 + value: 0 objectReference: {fileID: 0} - target: {fileID: 205271637847874222, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.y @@ -8649,7 +8649,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 205271637847874222, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.z - value: -2.35 + value: -1 + objectReference: {fileID: 0} + - target: {fileID: 205271637847874222, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalRotation.w + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 205271637847874222, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalRotation.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 205271637847874222, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 180 objectReference: {fileID: 0} - target: {fileID: 297185343939699586, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_Name @@ -8657,7 +8669,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 374135395555381814, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.x - value: 0.87 + value: 1 objectReference: {fileID: 0} - target: {fileID: 374135395555381814, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.y @@ -8665,11 +8677,23 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 374135395555381814, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.z - value: 6.65 + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 374135395555381814, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalRotation.w + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 374135395555381814, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalRotation.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 374135395555381814, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 180 objectReference: {fileID: 0} - target: {fileID: 1041503493158943442, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.x - value: 4 + value: 0 objectReference: {fileID: 0} - target: {fileID: 1041503493158943442, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.y @@ -8677,7 +8701,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1041503493158943442, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.z - value: 4.5 + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1041503493158943442, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalRotation.w + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1041503493158943442, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalRotation.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1041503493158943442, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 180 objectReference: {fileID: 0} - target: {fileID: 3608714310874968837, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: GlobalObjectIdHash @@ -8765,7 +8801,7 @@ PrefabInstance: objectReference: {fileID: 1690610727} - target: {fileID: 6314369147267609336, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.x - value: -3.11 + value: 1 objectReference: {fileID: 0} - target: {fileID: 6314369147267609336, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.y @@ -8773,11 +8809,23 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6314369147267609336, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.z - value: -0.6 + value: -1 + objectReference: {fileID: 0} + - target: {fileID: 6314369147267609336, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalRotation.w + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6314369147267609336, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalRotation.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6314369147267609336, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 180 objectReference: {fileID: 0} - target: {fileID: 6319832178442273571, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.x - value: -2.52 + value: 0 objectReference: {fileID: 0} - target: {fileID: 6319832178442273571, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.y @@ -8785,11 +8833,23 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6319832178442273571, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.z - value: 4.39 + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6319832178442273571, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalRotation.w + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6319832178442273571, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalRotation.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6319832178442273571, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 180 objectReference: {fileID: 0} - target: {fileID: 7456333582246237812, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.x - value: 4.31 + value: -1 objectReference: {fileID: 0} - target: {fileID: 7456333582246237812, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.y @@ -8797,7 +8857,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7456333582246237812, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} propertyPath: m_LocalPosition.z - value: -0.68 + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7456333582246237812, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalRotation.w + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7456333582246237812, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalRotation.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7456333582246237812, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 180 objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: @@ -9305,11 +9377,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.y - value: 0.28987613 + value: 0.28987604 objectReference: {fileID: 0} - target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.z - value: -0.18152039 + value: -0.1815203 objectReference: {fileID: 0} - target: {fileID: 1676734516302391364, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_UpdateMethod @@ -9337,19 +9409,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1676734516695783279, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.w - value: 0.79006946 + value: 0.7900695 objectReference: {fileID: 0} - target: {fileID: 1676734516695783279, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.x - value: 0.50873625 + value: 0.5087362 objectReference: {fileID: 0} - target: {fileID: 1676734516695783279, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.y - value: 0.2875618 + value: 0.2875617 objectReference: {fileID: 0} - target: {fileID: 1676734516695783279, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.z - value: -0.18516485 + value: -0.18516475 objectReference: {fileID: 0} - target: {fileID: 1676734516724634599, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalPosition.y @@ -9602,19 +9674,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalRotation.w - value: 0.79006934 + value: 0.7900696 objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalRotation.x - value: 0.5087363 + value: 0.50873613 objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalRotation.y - value: 0.28756183 + value: 0.2875617 objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalRotation.z - value: -0.18516491 + value: -0.18516473 objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -10524,7 +10596,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0, g: 0, b: 0, a: 1} + m_Color: {r: 0, g: 0, b: 0, a: 0.78431374} m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 @@ -10698,7 +10770,7 @@ Transform: m_GameObject: {fileID: 1640132953} serializedVersion: 2 m_LocalRotation: {x: 0, y: 1, z: 0, w: 0} - m_LocalPosition: {x: 0.65, y: 0, z: 1.64} + m_LocalPosition: {x: -1, y: 0, z: 1} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] diff --git a/Assets/StartingTimer.cs b/Assets/Scripts/Gameplay/StartingTimer.cs similarity index 82% rename from Assets/StartingTimer.cs rename to Assets/Scripts/Gameplay/StartingTimer.cs index 9d13818..a320511 100644 --- a/Assets/StartingTimer.cs +++ b/Assets/Scripts/Gameplay/StartingTimer.cs @@ -5,6 +5,8 @@ using TMPro; using DG.Tweening; using Unity.Netcode; using Unity.Multiplayer.Samples.Utilities; +using UnityEngine.Events; +using System; public class StartingTimer : NetworkBehaviour { @@ -14,6 +16,7 @@ public class StartingTimer : NetworkBehaviour private NetworkVariable timerValue = new NetworkVariable(0, NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Server); private bool coroutineStartedBool = false; + public static event Action StartingTimerEnded; private void Start() { @@ -26,11 +29,10 @@ public class StartingTimer : NetworkBehaviour { if (IsServer) { - coroutineStartedBool = true; + coroutineStartedBool = true; StartCoroutine(ServerTimerCoroutine()); } } - // Update the UI on all clients UpdateTimerUI(); } @@ -38,16 +40,14 @@ public class StartingTimer : NetworkBehaviour private IEnumerator ServerTimerCoroutine() { const int countdownStart = 3; - for (int i = countdownStart; i > 0; i--) { timerValue.Value = i; yield return new WaitForSeconds(1); } - timerValue.Value = -1; // Indicate "GO" yield return new WaitForSeconds(0.5f); - + StartingTimerEnded?.Invoke(); // Notify clients to disable the black screen BlackScreenAlphaDisablerClientRpc(); } @@ -67,9 +67,11 @@ public class StartingTimer : NetworkBehaviour [ClientRpc] private void BlackScreenAlphaDisablerClientRpc() { - BlackScreen.DOFade(0, 0.25f).OnComplete(() => - { - gameObject.SetActive(false); - }); + BlackScreen.gameObject.SetActive(false); + gameObject.SetActive(false); + //BlackScreen.DOFade(0, 0.25f).OnComplete(() => + //{ + // gameObject.SetActive(false); + //}); } } diff --git a/Assets/StartingTimer.cs.meta b/Assets/Scripts/Gameplay/StartingTimer.cs.meta similarity index 100% rename from Assets/StartingTimer.cs.meta rename to Assets/Scripts/Gameplay/StartingTimer.cs.meta diff --git a/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs b/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs index 8da68da..ed4f525 100644 --- a/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs +++ b/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using Unity.BossRoom.Gameplay.Actions; using Unity.BossRoom.Gameplay.Configuration; using Unity.BossRoom.Gameplay.GameplayObjects; @@ -123,12 +124,32 @@ namespace Unity.BossRoom.Gameplay.UserInput public UIMessageFeed m_UIMessageFeed; ServerCharacter m_TargetServerCharacter; private bool IsSwapModeActive = false; - + bool m_InputAllower = false; void Awake() { m_MainCamera = Camera.main; } - + private void OnEnable() + { + StartingTimer.StartingTimerEnded += inputAllowerActivator; + } + private void OnDisable() + { + StartingTimer.StartingTimerEnded -= inputAllowerActivator; + } + void Update() + { + if (m_InputAllower) + { + HandleSwapInput(); + HandleAbilityInput(); + HandleMovementInput(); + } + } + void inputAllowerActivator() + { + m_InputAllower = true; + } public override void OnNetworkSpawn() { if (!IsClient || !IsOwner) @@ -159,8 +180,8 @@ namespace Unity.BossRoom.Gameplay.UserInput m_GroundLayerMask = LayerMask.GetMask(new[] { "Ground" }); m_ActionLayerMask = LayerMask.GetMask(new[] { "PCs", "NPCs", "Ground" }); - m_SwapInputLayerMask = LayerMask.GetMask(new[]{"PCs"}); - + m_SwapInputLayerMask = LayerMask.GetMask(new[] { "PCs" }); + m_RaycastHitComparer = new RaycastHitComparer(); m_UIMessageFeed = FindObjectOfType(); } @@ -479,12 +500,6 @@ namespace Unity.BossRoom.Gameplay.UserInput } } - void Update() - { - HandleSwapInput(); - HandleAbilityInput(); - HandleMovementInput(); - } private void HandleSwapInput() { @@ -602,7 +617,7 @@ namespace Unity.BossRoom.Gameplay.UserInput } } - + /// /// Handles the swap request when in swap mode. /// @@ -621,7 +636,7 @@ namespace Unity.BossRoom.Gameplay.UserInput if (targetNetObj.TryGetComponent(out ServerCharacter targetCharacter)) { // Initiate the swap - targetCharacter.NotifySwapRequestRpc(m_ServerCharacter.NetworkObjectId,m_ServerCharacter.uIStateDisplayHandler.m_UIState.playerName); + targetCharacter.NotifySwapRequestRpc(m_ServerCharacter.NetworkObjectId, m_ServerCharacter.uIStateDisplayHandler.m_UIState.playerName); Debug.Log($"Swap request sent to {targetCharacter.name}."); IsSwapModeActive = false; // Automatically deactivate swap mode after a successful request return; @@ -631,8 +646,8 @@ namespace Unity.BossRoom.Gameplay.UserInput } Debug.LogWarning("No valid target found for swapping."); } - - + + void UpdateAction1() { var isHoldingNetworkObject =