dronkowitz

GoalRing.cs

Mar 15th, 2021 (edited)
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6. public class GoalRing : MonoBehaviour
  7. {
  8.     public GameObject LevelEndHUD;
  9.     public string NextLevelName;
  10.     private bool LoadingNextScene = false;
  11.     public AudioClip clip;
  12.     private GameObject source;
  13.     // Start is called before the first frame update
  14.     void Start()
  15.     {
  16.         source = Resources.Load<GameObject>("Audio Object");
  17.     }
  18.  
  19.     // Update is called once per frame
  20.     void Update()
  21.     {
  22.  
  23.     }
  24.  
  25.     private void OnTriggerEnter(Collider other)
  26.     {
  27.         if (other.TryGetComponent(out UltimatePlayerMovement player) && LoadingNextScene == false)
  28.         {
  29.             LoadingNextScene = true;
  30.             GameObject ao = Instantiate(source, transform.position, Quaternion.identity);
  31.             ao.GetComponent<AudioObject>().Setup(clip, transform);
  32.             GameInstance.CreateSave();
  33.             StartCoroutine(EndOfLevel());
  34.         }
  35.     }
  36.  
  37.     public IEnumerator EndOfLevel()
  38.     {
  39.        
  40.         ScoreSystem sys = FindObjectOfType<ScoreSystem>();
  41.         sys.StartEndLevelSequence();
  42.         //Displays Final Level Stats Here
  43.         yield return new WaitForSeconds(3);
  44.         SceneManager.LoadScene(NextLevelName);
  45.     }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment