39 lines
753 B
C#
39 lines
753 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class OnVictoryOrDefeat : MonoBehaviour
|
|
{
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (gameObject.scene.isLoaded)
|
|
{
|
|
UIManager.Instance.ShowEndScreen();
|
|
StartCoroutine(LerpTimeScale());
|
|
}
|
|
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
Time.timeScale = 1;
|
|
}
|
|
|
|
private IEnumerator LerpTimeScale()
|
|
{
|
|
float duration = 0;
|
|
float maxDuration = 1.5f;
|
|
|
|
while (duration < 1)
|
|
{
|
|
Time.timeScale = Mathf.Lerp(1, 0.1f, duration);
|
|
|
|
duration += Time.deltaTime / maxDuration;
|
|
yield return null;
|
|
}
|
|
|
|
Player.Instance.updatePlayer = false;
|
|
}
|
|
}
|