Advertisement
gandalfbialy

Untitled

May 10th, 2025
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.SceneManagement;
  3. using System.Collections.Generic;
  4.  
  5. public class GameManager : MonoBehaviour
  6. {
  7. public static GameManager instance;
  8. public List<GameObject> bricks = new List<GameObject>();
  9. public ArcanoidBall ball;
  10. bool isGameRunning = false;
  11.  
  12. void Start()
  13. {
  14. if (instance == null)
  15. {
  16. instance = this.gameObject.GetComponent<GameManager>();
  17. }
  18.  
  19. bricks.AddRange(GameObject.FindGameObjectsWithTag("Brick"));
  20. }
  21.  
  22. void Update()
  23. {
  24. if (Input.GetKey(KeyCode.Space) && !isGameRunning)
  25. {
  26. ball.RunBall();
  27. isGameRunning = true;
  28. }
  29.  
  30. if (isGameRunning && bricks.Count <= 0)
  31. {
  32. EndGame(true);
  33. }
  34. }
  35.  
  36. public void EndGame(bool isWin)
  37. {
  38. isGameRunning = false;
  39. string endGameText = isWin ? "Wygrana!" : "Przegrana!";
  40. Debug.Log(endGameText);
  41. ball.StopBall();
  42. }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement