This commit is contained in:
Gerard Gascón 2025-04-24 14:30:07 +02:00
commit 102013b228
1443 changed files with 1065651 additions and 0 deletions

View file

@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EndGameController : MonoBehaviour
{
[SerializeField] CMCameraRail rail;
[SerializeField] CanvasGroup credits;
bool creditsAlpha = false;
// Start is called before the first frame update
void Start()
{
rail.StartRail();
StartCoroutine(AudioManager.instance.FadeIn("final_minijuego", 1));
StartCoroutine(PlayKidsSound(3, 6));
}
// Update is called once per frame
void Update()
{
if (creditsAlpha)
{
credits.alpha += Time.deltaTime;
if(credits.alpha >= 1)
{
creditsAlpha = false;
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
}
}
}
public void ShowCredits()
{
creditsAlpha = true;
}
private IEnumerator PlayKidsSound(float maxDelay, float minDelay)
{
float i = 0;
float delay = 0;
while (i < 100000)
{
delay = Random.Range(minDelay, maxDelay);
i += Time.deltaTime;
AudioManager.instance.PlayOneShot("SFX_cheering");
yield return new WaitForSecondsRealtime(delay);
}
}
}