/*
       INITLEVEL: restarts the current level, resets ball status and position; respawns any destructibles.
       */
    public void initLevel()
    {
        print("Level initialized");
        GameMenuLose = GameObject.Find("LoseMenu");
        GameMenuWin = GameObject.Find("WinMenu");
        RespawnableObjects = GameObject.FindGameObjectsWithTag("BuildOnEnd");
        RespawnableObjectsWithParticles = GameObject.FindGameObjectsWithTag("BuildOnEndParticleChild");

        // Initlevel may have an external call
        objectBall = GameObject.Find("RollerBall");
        theBall = (Ball)objectBall.GetComponent(typeof(Ball));

        //Default parameters
        Resume();
        GameMenuWin.SetActive(false);
        GameMenuLose.SetActive(false);
        theBall.Respawn();
        CountText.text = (lvl_timer).ToString();
        theBall.setStatus(0);
        CurrentTime = 0;

        for (int i = 0; i< RespawnableObjects.Length; i++)
        {
            print(RespawnableObjects[i].name);
            RespawnableObjects[i].GetComponent<Collider>().enabled = true;
            RespawnableObjects[i].GetComponent<Renderer>().enabled = true;

        }

        /*
        VERY IMPORTANT THE STRUCTURE OF A PARTICLE POWERUP MUST BE OF THE STRUCTURE
            POWERUP_
                .CHILD PARTICLE 1  ->SPACE(0)
                .CHILD PARTICLE 2  ->SPACE(1)

        */

        for (int i = 0; i <RespawnableObjectsWithParticles.Length; i++)
        {
            print("Respanwed: "+RespawnableObjectsWithParticles[i].name);
            RespawnableObjectsWithParticles[i].GetComponent<Collider>().enabled = true;
            RespawnableObjectsWithParticles[i].transform.GetChild(0).GetComponent<ParticleSystem>().enableEmission = true;
            RespawnableObjectsWithParticles[i].transform.GetChild(1).GetComponent<ParticleSystem>().enableEmission = true;

        }
    }