예제 #1
0
    public void resetGame()
    {
        GameObject[] agents = GameObject.FindGameObjectsWithTag("agent");
        foreach (GameObject a in agents)
        {
            Destroy(a);
        }

        GameObject[] tunnels = GameObject.FindGameObjectsWithTag("tunnel");
        foreach (GameObject t in tunnels)
        {
            Destroy(t);
        }

        GameObject[] holes = GameObject.FindGameObjectsWithTag("hole");
        foreach (GameObject h in holes)
        {
            Destroy(h);
        }

        GameObject[] steps = GameObject.FindGameObjectsWithTag("step");
        foreach (GameObject s in steps)
        {
            Destroy(s);
        }

        GameObject[] exitPoints = GameObject.FindGameObjectsWithTag("exit");
        foreach (GameObject e in exitPoints)
        {
            exitPoint exitPointScript = e.GetComponent <exitPoint>();
            exitPointScript.Reset();
        }

        //respawn all the pickups
        RespawnPickups();

        //reset abilities count
        var abilityScript = abilityHandler.GetComponent <abilityHandler>();

        abilityScript.ResetUICount();

        //reset score
        var scoreScript = gameObject.GetComponent <uiScore>();

        scoreScript.resetScore();
        scoreScript.startTimer(abilityScript.TimeLimit);

        //reset spawners
        GameObject[] spawners = GameObject.FindGameObjectsWithTag("spawner");
        foreach (GameObject s in spawners)
        {
            spawner spawnerScript = s.GetComponent <spawner>();
            if (spawnerScript)
            {
                spawnerScript.ResetSpawner();
            }
        }

        if (!resultsScreen)
        {
            pauseGame();
        }
        else
        {
            resultsScreen = false;
            resultsPanel.SetActive(false);
            abilityPanel.SetActive(true);
            star1.SetActive(false);
            star2.SetActive(false);
            star3.SetActive(false);
            nextButton.SetActive(false);
            resetButton2.SetActive(false);
            homeButton2.SetActive(false);
            pauseButton.SetActive(true);
        }
    }