diff --git a/Assets/game/Scripts/Save/PlayerSaving.cs b/Assets/game/Scripts/Save/PlayerSaving.cs index db98515..80e8b14 100644 --- a/Assets/game/Scripts/Save/PlayerSaving.cs +++ b/Assets/game/Scripts/Save/PlayerSaving.cs @@ -20,7 +20,7 @@ public class PlayerSaving : MonoBehaviour Debug.Log($"Saved level: {Level}, coins: {Coins}, tutorial: {HasCompletedTutorial}, cloudsMove: {MovingClouds}"); } - public static void LoadPlayer() + private static void LoadPlayer() { var data = SaveSystem.LoadPlayer(); diff --git a/Assets/game/Scripts/UI/Pause.cs b/Assets/game/Scripts/UI/Pause.cs index 7f2dc9b..41b3f91 100644 --- a/Assets/game/Scripts/UI/Pause.cs +++ b/Assets/game/Scripts/UI/Pause.cs @@ -17,7 +17,7 @@ public class Pause : MonoBehaviour public GameObject Fire; public GameObject Image; - private static readonly int IsCrouching = Animator.StringToHash("IsCrouchingAnimationID"); + private static readonly int IsCrouchingAnimationID = Animator.StringToHash("IsCrouching"); public void IsPauseing() { @@ -58,7 +58,7 @@ public class Pause : MonoBehaviour if(!IsPause) // if going back to the game { PlayerMovement.Crouch = false; - animator.SetBool(IsCrouching, false); + animator.SetBool(IsCrouchingAnimationID, false); } } } diff --git a/Assets/game/Scripts/UI/SoundBar.cs b/Assets/game/Scripts/UI/SoundBar.cs index 3258a48..32f9922 100644 --- a/Assets/game/Scripts/UI/SoundBar.cs +++ b/Assets/game/Scripts/UI/SoundBar.cs @@ -6,10 +6,10 @@ public class SoundBar : MonoBehaviour { public static float SoundVolume = 0.75f; public AudioSource BackgroundMusic; - public static float MusicTime = 0f; // Static variable to store the music time - public static bool SceneReloaded = false; // Static variable to track if scene is reloaded + private static float _musicTime; // Static variable to store the music time + public static bool SceneReloaded; // Static variable to track if scene is reloaded - void Start() + private void Start() { LoadSoundVolume(); ApplySoundVolume(); @@ -17,38 +17,38 @@ public class SoundBar : MonoBehaviour if (SceneReloaded) { // If the scene has been reloaded before, continue playing from where it stopped - BackgroundMusic.time = MusicTime; + BackgroundMusic.time = _musicTime; } SceneReloaded = false; } - void Update() + private void Update() { - if (SoundVolume != BackgroundMusic.volume) + if (!Mathf.Approximately(SoundVolume, BackgroundMusic.volume)) { SoundVolume = BackgroundMusic.volume; SaveSoundVolume(); } - MusicTime = BackgroundMusic.time; + _musicTime = BackgroundMusic.time; } - public static void SaveSoundVolume() + private static void SaveSoundVolume() { PlayerPrefs.SetFloat("SoundVolume", SoundVolume); PlayerPrefs.Save(); } - void LoadSoundVolume() + private static void LoadSoundVolume() { if (PlayerPrefs.HasKey("SoundVolume")) { - float savedVolume = PlayerPrefs.GetFloat("SoundVolume"); + var savedVolume = PlayerPrefs.GetFloat("SoundVolume"); SoundVolume = savedVolume; } } - void ApplySoundVolume() + private void ApplySoundVolume() { BackgroundMusic.volume = SoundVolume; }