From 926cb4b6514e73f3b5b2fa848ce9cdfb1b465ac4 Mon Sep 17 00:00:00 2001 From: Tore Bergebakken Date: Wed, 29 May 2024 20:38:48 +0200 Subject: [PATCH] Fix loading screen animation --- Assets/Scenes/Menu.unity | 2 +- Assets/Scripts/Control&Input/Peer2PeerTransport.cs | 9 ++++++++- Assets/Scripts/LoadingScreen.cs | 8 +++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Assets/Scenes/Menu.unity b/Assets/Scenes/Menu.unity index 16697eff..6e446b1a 100644 --- a/Assets/Scenes/Menu.unity +++ b/Assets/Scenes/Menu.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 785370674} - m_IndirectSpecularColor: {r: 0.061073616, g: 0.21100084, b: 0.4741943, a: 1} + m_IndirectSpecularColor: {r: 0.062290687, g: 0.21925586, b: 0.49511063, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: diff --git a/Assets/Scripts/Control&Input/Peer2PeerTransport.cs b/Assets/Scripts/Control&Input/Peer2PeerTransport.cs index 7cf0de90..083eed52 100644 --- a/Assets/Scripts/Control&Input/Peer2PeerTransport.cs +++ b/Assets/Scripts/Control&Input/Peer2PeerTransport.cs @@ -304,10 +304,17 @@ public static void StartTrainingMode() private static IEnumerator WaitAndSwitchToTrainingMode() { LoadingScreen.Singleton.Show(); + + // Wait for player details to be populated while (!NetworkClient.isConnected && !singleton.isNetworkActive && players.Count < PlayerInputManagerController.Singleton.LocalPlayerInputs.Count) yield return new WaitForEndOfFrame(); singleton.ServerChangeScene(Scenes.TrainingMode); - // TODO until after spawned + + yield return new WaitForSeconds(LoadingScreen.Singleton.MandatoryDuration); + + // Wait for player(s) to have spawned + while (FindObjectsByType(FindObjectsSortMode.None).Count() < players.Count) + yield return new WaitForEndOfFrame(); LoadingScreen.Singleton.Hide(); } diff --git a/Assets/Scripts/LoadingScreen.cs b/Assets/Scripts/LoadingScreen.cs index b227ecbf..8c72b5ba 100644 --- a/Assets/Scripts/LoadingScreen.cs +++ b/Assets/Scripts/LoadingScreen.cs @@ -33,7 +33,6 @@ public class LoadingScreen : MonoBehaviour [SerializeField] private float normalRotationSpeed = 60; [SerializeField] private float fastRotationSpeed = 120; - private float incrementTimer = 360f; private float rotationSpeed = 60; private static int loadingCounter = 0; @@ -76,13 +75,16 @@ private void Start() private IEnumerator UpdateTimer(float duration) { var secondsPerChamber = duration / 6f; + var chamberCoverageAngle = 360f; rotationSpeed = normalRotationSpeed; + radialTimer.material.SetFloat("_Arc2", chamberCoverageAngle); + for (int i = 0; i < 6; i++) { yield return new WaitForSeconds(secondsPerChamber); - incrementTimer -= 60f; - radialTimer.material.SetFloat("_Arc2", incrementTimer); + chamberCoverageAngle -= 60f; + radialTimer.material.SetFloat("_Arc2", chamberCoverageAngle); if (i == 4) {