Created
June 8, 2015 11:27
-
-
Save mmechtley/6c30d557e3d68c234b67 to your computer and use it in GitHub Desktop.
TouchKO Loading Level
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
#pragma implicit | |
#pragma downcast | |
var destroyOnLevelLoad:GameObject[]; | |
// For tracking sessions for Blurst | |
static var startRecorded:boolean = false; | |
function Start() | |
{ | |
System.GC.Collect(); | |
// Track Blurst session | |
if(!startRecorded && Blurst.instance) | |
{ | |
Blurst.instance.NewGame(); | |
startRecorded = true; | |
} | |
LoadLevel(); | |
} | |
function LoadLevel() | |
{ | |
yield; | |
var level:String = PlayerPrefs.GetString("Level After Loading", "Menu"); | |
// load a random level for quick play | |
if (level != "Menu" && level != "Training" && PlayerPrefs.GetInt("Is Quick Play Match", 0) == 1) | |
{ | |
var randomVenue:Venue = Random.Range (0, 3); | |
Application.LoadLevelAdditive(randomVenue.ToString()); | |
} | |
else | |
{ | |
Application.LoadLevelAdditive(level); | |
} | |
for(var go:GameObject in destroyOnLevelLoad) | |
Destroy(go); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment