IEnumerator EnemyGenerator()
    {
        yield return(new WaitForSeconds(delay));

        if (active)
        {
            var newTransform = transform;
            GameObjectUtily.Instantiate(prefabs[Random.Range(0, prefabs.Length)], newTransform.position);
            ResetDelay();
        }
        StartCoroutine(EnemyGenerator());
    }
Exemple #2
0
    void ResetGame()
    {
        spawner.active = true;

        player = GameObjectUtily.Instantiate(playerPrefab, new Vector3(0, (Screen.height / PixelPerfectCamera.pixelsToUnits) / 2 + 100, 0));

        var playerDestroyScript = player.GetComponent <DestroyOffScreen>();

        playerDestroyScript.DestroyCallback += OnPlayerKilled;

        gameStarted = true;

        continueText.canvasRenderer.SetAlpha(0);

        timeElapsed = 0;

        beatBestTime = false;
    }