Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using System.Collections.Generic;
- public class GameManager : MonoBehaviour
- {
- public static GameManager instance;
- public List<GameObject> bricks = new List<GameObject>();
- public ArcanoidBall ball;
- bool isGameRunning = false;
- void Start()
- {
- if (instance == null)
- {
- instance = this.gameObject.GetComponent<GameManager>();
- }
- bricks.AddRange(GameObject.FindGameObjectsWithTag("Brick"));
- }
- void Update()
- {
- if (Input.GetKey(KeyCode.Space) && !isGameRunning)
- {
- ball.RunBall();
- isGameRunning = true;
- }
- if (isGameRunning && bricks.Count <= 0)
- {
- EndGame(true);
- }
- }
- public void EndGame(bool isWin)
- {
- isGameRunning = false;
- string endGameText = isWin ? "Wygrana!" : "Przegrana!";
- Debug.Log(endGameText);
- ball.StopBall();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement