Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. private void Start()
  2. {
  3. ens = GetComponent<EnemyScript>();
  4. sceneIndex = SceneManager.GetActiveScene().buildIndex;
  5. levelPassed = PlayerPrefs.GetInt("LevelPassed");
  6.  
  7. }
  8.  
  9.  
  10. void Awake()
  11. {
  12. SetUpSingleton();
  13. }
  14.  
  15. private void SetUpSingleton()
  16. {
  17. int numberGameManager = FindObjectsOfType<GameManager>().Length;
  18. if (numberGameManager > 1)
  19. {
  20. Destroy(gameObject);
  21. }
  22. else
  23. {
  24. DontDestroyOnLoad(gameObject);
  25. }
  26. }
  27.  
  28. public void GameOverCanvas()
  29. {
  30. gameOverCanvas.SetActive(true);
  31. }
  32.  
  33. public void YouWinCanvas()
  34. {
  35. youWinCanvas.SetActive(true);
  36. AfterWinning();
  37. }
  38.  
  39.  
  40. public void AfterWinning()
  41.  
  42. {
  43. FindObjectOfType<EnemySpawner>().StopSpawning();
  44. FindObjectOfType<EnemyScript>().AllDie();
  45. FindObjectOfType<SpawnManager>().OnPlayerWin();
  46. isYouWon = true;
  47. PlayerPrefs.SetInt("LevelPassed", sceneIndex);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement