public void GoToThisScene()
    {
        switch (sceneName)
        {
        case "Level1":
            BGMMenu.Get().stopMenuMusic();
            LoaderManager.Get().LoadScene(sceneName);
            UILoadingScreen.Get().SetVisible(true);
            break;

        case "Level2":
            BGMMenu.Get().stopMenuMusic();
            LoaderManager.Get().LoadScene(sceneName);
            UILoadingScreen.Get().SetVisible(true);
            break;

        case "GameOver":
            SceneManager.LoadScene(sceneName);
            break;

        case "Menu":
            if (SceneManager.GetActiveScene().name == "GameOver")
            {
                BGMMenu.Get().playMenuMusic();
            }
            SceneManager.LoadScene(sceneName);
            break;

        case "Controls":
            SceneManager.LoadScene(sceneName);
            break;

        case "Credits":
            SceneManager.LoadScene(sceneName);
            break;

        default:
            if (isLevelRestartButton)
            {
                SceneManager.LoadScene(SaveLastLevel.Get().loadLevelName());
            }
            else
            {
                SceneManager.LoadScene(sceneName);
            }
            break;
        }
    }
Ejemplo n.º 2
0
    // Start is called before the first frame update
    private void Start()
    {
        Cursor.visible = false;
        squadSpawner   = squadSpawnerGameObject.GetComponent <SquadSpawner>();
        squadSpawner.addSquadToLevelSquads();

        for (int i = 0; i < enemySquads.Length; i++)
        {
            enemySquads[i].GetComponent <Enemy>().deActivateWaypoint();
            for (int f = 0; f < enemySquads[i].GetComponent <Enemy>().squadMembers.Count; f++)
            {
                enemySquads[i].GetComponent <Enemy>().squadMembers[f].GetComponent <Enemy>().onEnemyDeath     += deleteEnemyFromSquad;
                enemySquads[i].GetComponent <Enemy>().squadMembers[f].GetComponent <Enemy>().onEnemyDestroyed += deleteEnemyFromSquad;
                enemySquads[i].GetComponent <Enemy>().squadMembers[f].GetComponent <Enemy>().onEnemyDeath     += addPointsToPlayer;
            }

            enemySquads[i].SetActive(false);
        }

        playerController   = player.GetComponent <PlayerController>();
        distanceText       = distanceTextGameObject.GetComponent <UIDisplayNumbers>();
        roundEndMessage    = roundEndUI.GetComponent <UIRoundEnd>();
        startRoundAnimator = startRoundCanvas.GetComponent <Animator>();
        endRoundAnimator   = endRoundCanvas.GetComponent <Animator>();
        saveLevelName      = SaveLastLevel.Get();


        PlayerController.onPlayerDeath += roundEnd;
        PlayerController.onPlayerDeath += playerIsDead;
        currentSquadsOnScreen           = 2;

        for (int i = 0; i < enemySquads.Length; i++)
        {
            if (enemySquads[i] != null && currentSquadsOnScreen < maxSquadsOnScreen)
            {
                enemySquads[i].SetActive(true);
                enemySquads[i].GetComponent <Enemy>().activateWaypoint();
                currentSquadsOnScreen++;
            }
        }
    }