private void Start() { player.OnPlayerDestroy += OnPlayerDestroy; scoreTextMeshPro.text = score.ToString(); activeAsteroidsCount = asteroidSpawner.SpawnAsteroids(OnAsteroidDestroy); }
// Check whether Asteroids should be spawned private void Update() { if (GameManager.SpawnFlag == true && DateTime.Now > GameManager.SpawnTime && GameManager.IsGameStarted) { GameManager.SpawnFlag = false; aSpawn.SpawnAsteroids(); } }
public void StartGame() { // 1. Destroy Asteroids var asteroids = gameObjectCounter.gameObjects.FindAll(obj => obj != null && obj.GetComponent <Asteroid>() != null); asteroids.ForEach(asteroid => Destroy(asteroid)); // 2. Spawn Ship Controller var playerShip = Instantiate(playerShipPrefab, Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.0f)) + new Vector3(0.0f, 0.0f, 10.0f), Quaternion.identity); // 3. Spawn Asteroids asteroidSpawner.StartCoroutine(asteroidSpawner.SpawnAsteroids()); // Begin Checking Game State here StartCoroutine(CheckForGameOver()); StartCoroutine(CheckForWinState()); }
public void StartGame() { asteroidSpawner.SpawnAsteroids(); }