/
arti4
/
CourseWork
Обзор
Документация
Войти
/
arti4
/
CourseWork
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Scriptes/LevelEndTrigger.cs
77 строк
2 KB
arti4
Загрузить файлы в «Scriptes»
01 июн 2025, 11:57
01 июн 2025, 11:57
9c49e8f
Код
Авторство
О чём код?
using UnityEngine; public class LevelEndTrigger : MonoBehaviour { public GameObject levelCompleteUI; public int currentLevel; private bool isLevelCompleted = false; private bool skipIntro; private AudioManager audioManager; private MusicManager musicManager; public GameObject endScreen; private void Start() { audioManager = FindFirstObjectByType<AudioManager>(); musicManager = FindFirstObjectByType<MusicManager>(); bool skipIntro = PlayerPrefs.GetInt("SkipIntro", 0) == 1; if (audioManager != null) { audioManager.PauseAudioEffects(); audioManager.MuteGameSounds(); } if (skipIntro) { endScreen.SetActive(false); } } private void Update() { if (isLevelCompleted && Input.GetKeyDown(KeyCode.Return)) { levelCompleteUI.SetActive(true); endScreen.SetActive(false); } } //������� � �������� ����� ������ private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { if (audioManager != null) { musicManager.PlayVictoryMusic(); audioManager.PauseAudioEffects(); audioManager.MuteGameSounds(); } Time.timeScale = 0f; bool skipIntro = PlayerPrefs.GetInt("SkipIntro", 0) == 1; LevelProgress.SetReachedLevel(currentLevel + 1); if (!skipIntro) { Time.timeScale = 0f; endScreen.SetActive(true); MusicManager musicManager = FindFirstObjectByType<MusicManager>(); if (musicManager != null) { musicManager.PlayVictoryMusic(); } } else { levelCompleteUI.SetActive(true); } isLevelCompleted = true; } } }