IAMColumbia / NationalSpaceship

Advanced Game Engine Scripting SP15-NJ Repo
3 stars 17 forks source link

EJ_NextLevelScript #170

Closed EthanJohnson126 closed 9 years ago

EthanJohnson126 commented 9 years ago

Description

Takes in decrementing values from destruction of the blocks, as per #64 and brings the player to the next level once they have successfully solved the puzzle.

Requirement

There must be a waiting period before loading the next level, giving the palyer some indication that they have won.

New Code

//The amount of pieces in each individual puzzle.
public int amountinPuzzle;

//Calls the next level after the current one.
public int nextLevel;

//On win, activate GUI.
public bool buttonAppear = false;

//On win, destroy music and play, victory sound.
public AudioClip victoryClip;
public AudioSource woodSource;

public AudioSource musicSource;

void Update () {

    //When all pieces are destroyed, load the next level.
    if (amountinPuzzle <= 0 && Time.timeScale != 0)
    {
        //Destroy the current music source.
        Destroy(musicSource.gameObject);

        //Play victory sound.
        woodSource.clip = victoryClip;
        woodSource.Play ();

        //Make the GUI for the next level appear.
        buttonAppear = true;
    }

}

void OnGUI(){
    if(buttonAppear == true){
        //Upon completion of the level, a button appears which allows the player to move to the next level.
        if(GUI.Button(new Rect (Screen.width/3, (Screen.height/3)*2, 100, 50), "Next Level"))
            Application.LoadLevel(nextLevel);
    }
}

Old Code

//The amount of pieces in each individual puzzle.
public int amountinPuzzle;

//Calls the next level after the current one.
public int nextLevel;

void Update () {

    //When all pieces are destroyed, load the next level.
    if (amountinPuzzle <= 0)
    {
        Application.LoadLevel(nextLevel);
    }

}

Previous Work

Up to date.

Other Notes

Possibly have a menu which allows the player to choose whether to go to the next level or reset the current one, displaying the values from #69 whenever that gets done.

EthanJohnson126 commented 9 years ago

https://github.com/EthanJohnson126/EthanJohnson_Fallmo

EthanJohnson126 commented 9 years ago

https://github.com/EthanJohnson126/FallmoV2