Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- public class GameManager : MonoBehaviour
- {
- public static GameManager Instance;
- public Transform bricks;
- public ArkanoidBall ball;
- bool gameRun = false;
- private void Awake()
- {
- if (Instance == null) Instance = this;
- }
- // Update is called once per frame
- void Update()
- {
- if (Input.GetKey(KeyCode.Space) && !gameRun)
- {
- ball.RunBall();
- gameRun = true;
- }
- Debug.Log(bricks.childCount);
- if(gameRun && bricks.childCount == 0)
- {
- EndGame(true);
- }
- if (!gameRun && Input.GetKeyDown(KeyCode.R))
- {
- SceneManager.LoadScene(0);
- }
- }
- public void EndGame(bool win)
- {
- gameRun = false;
- string text = win ? "Wygrana!" : "Przegrana!";
- Debug.Log(text);
- ball.StopBall();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement