Skip to content

Instantly share code, notes, and snippets.

Created November 24, 2017 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9ba4dca6fed5031611688fc98b659888 to your computer and use it in GitHub Desktop.
Save anonymous/9ba4dca6fed5031611688fc98b659888 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class LevelManager : MonoBehaviour {
public float autoLoadNextLevelAfter;
private OptionsController optionsController;
void Start(){
if (autoLoadNextLevelAfter <= 0) {
Debug.Log ("No autoLoad, got it");
} else {
Invoke ("LoadNextLevel", autoLoadNextLevelAfter);
}
}
public void LoadLevel(string name){
Debug.Log ("Level load requested for: " + name);
Application.LoadLevel(name);
}
public void LoadSurvivalLevel (string name){
optionsController = GameObject.Find("OptionsController").GetComponent<OptionsController>();
if (optionsController.survivalSlider.value == 0f) {
Application.LoadLevel (Application.loadedLevel + 1);
}
else if (optionsController.survivalSlider.value == 1f) {
Application.LoadLevel ("04 Level_01 Survival");
// Debug.LogError ("Survival mode is on!");
}
SurvivalLoseCollider.livesSurvival = 10;
Debug.Log ("Level load requested for: " + name);
}
public void LoadNextLevel() {
Application.LoadLevel(Application.loadedLevel + 1);
}
public void QuitRequest(){
Debug.Log ("I want to quit!");
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment