chore: clean up

This commit is contained in:
2025-05-17 15:16:30 +02:00
parent 0e70858ce9
commit b48e17882c
17 changed files with 147 additions and 30 deletions

View File

@ -50,7 +50,10 @@ public class LevelsLoader : MonoBehaviour
private void SaveLevelCurrent()
{
if (levelCurrent == null) return;
if (levelCurrent == null)
{
return;
}
LevelStat levelStat = new()
{
@ -68,7 +71,10 @@ public class LevelsLoader : MonoBehaviour
public void NextLevel()
{
if (levels.Count == 0) return;
if (levels.Count == 0)
{
return;
}
int currentIndex = levels.IndexOf(levelCurrent);
levelCurrent = levels[(currentIndex + 1) % levels.Count];
@ -76,7 +82,10 @@ public class LevelsLoader : MonoBehaviour
public void PreviousLevel()
{
if (levels.Count == 0) return;
if (levels.Count == 0)
{
return;
}
int currentIndex = levels.IndexOf(levelCurrent);
levelCurrent = levels[(currentIndex - 1 + levels.Count) % levels.Count];
@ -84,7 +93,10 @@ public class LevelsLoader : MonoBehaviour
public void IncreaseTotalJumps()
{
if (levelCurrent == null) return;
if (levelCurrent == null)
{
return;
}
levelCurrent.TotalJumps += 1;
SaveLevelCurrent();
@ -92,7 +104,10 @@ public class LevelsLoader : MonoBehaviour
public void IncreaseTotalAttempts()
{
if (levelCurrent == null) return;
if (levelCurrent == null)
{
return;
}
levelCurrent.TotalAttempts += 1;
SaveLevelCurrent();
@ -100,7 +115,10 @@ public class LevelsLoader : MonoBehaviour
public int CalculateCurrentProgressionPercent(Vector3 playerPosition)
{
if (levelCurrent == null) return 0;
if (levelCurrent == null)
{
return 0;
}
float lastX = levelCurrent.LastX;
GameObject winnerWallPrefab = Resources.Load<GameObject>("Prefabs/WinnerWall");
@ -125,6 +143,8 @@ public class LevelsLoader : MonoBehaviour
levels.Clear();
LoadAllLevels();
if (levels.Count > 0)
{
levelCurrent = levels[0];
}
}
}

View File

@ -10,6 +10,7 @@ public class LevelHomeButton : MonoBehaviour
public static IEnumerator PlaySoundAndLoadScene(AudioSource sfxSource, string scene)
{
yield return new WaitWhile(() => sfxSource.isPlaying);
Time.timeScale = 1;
SceneManager.LoadScene(scene);
}

View File

@ -105,11 +105,10 @@ public class Player : MonoBehaviour
if (collision.gameObject.CompareTag("Kill"))
{
Time.timeScale = 0;
sfxSource.clip = Resources.Load<AudioClip>(Path.Combine("Sounds", "death"));
sfxSource.Play();
StartCoroutine(LevelHomeButton.PlaySoundAndLoadScene(sfxSource, SceneManager.GetActiveScene().name));
}
if (collision.gameObject.CompareTag("Win"))

View File

@ -50,7 +50,6 @@ public class SelectDifficulty : MonoBehaviour
public void PreviousDifficulty()
{
Debug.Log("PreviousDifficulty called");
if (currentDifficulty > MinDiff)
{
currentDifficulty--;
@ -60,7 +59,6 @@ public class SelectDifficulty : MonoBehaviour
public void NextDifficulty()
{
Debug.Log("NextDifficulty called");
if (currentDifficulty < MaxDiff)
{
currentDifficulty++;

View File

@ -50,7 +50,6 @@ public class StarsRenderer : MonoBehaviour
{
useManualMode = true;
manualDifficulty = Mathf.Clamp(difficulty, 1, 5);
Debug.Log($"[StarsRenderer] SetManualDifficulty → manualDifficulty = {manualDifficulty}");
lastRenderedDifficulty = -1;
RenderStarsInternal(manualDifficulty);
}
@ -74,7 +73,6 @@ public class StarsRenderer : MonoBehaviour
private void RenderStarsInternal(int difficulty)
{
Debug.Log($"[StarsRenderer] RenderStarsInternal → difficulté = {difficulty}", this);
for (int i = starsContainer.childCount - 1; i >= 0; i--)
{
var child = starsContainer.GetChild(i);