Hi. I’m making a sort of tycoon game, I have got the basic drag and drop feature. When a button is pressed, I want it to load a level depending on how many of each object there is. For instance I have ads, talk shows and music, if there is a right balance of them load a certain level, if there is too many ads then load another etc… I have the basic code for loading A level but a specific one.
#pragma strict
public var Level = "2";
function LoadLevel(){
Application.LoadLevel(Level);
}
so yeah I just need it to choose a level depending on strings
c# so now tag the UI elements in inspector & make sure tags are same as you test in script :
public GameObject [] Music;
public GameObject [] Ads;
public GameObject [] Shows;
void Update(){
Music = GameObject.FindGameObjectsWithTag ("music");
Ads = GameObject.FindGameObjectsWithTag ("ads");
Shows = GameObject.FindGameObjectsWithTag ("shows");
}
public void ChoesLevel(){
//this test which object have the larger amount than others if you want certain NUMBER test only the array length like that if(Music.Length == 5) .
if (Music.Length > Ads.Length && Music.Length > Shows.Length) {
print ("music :" + Music.Length);
} else if (Ads.Length > Music.Length && Ads.Length > Shows.Length) {
print ("ads :" + Ads.Length);
} else if (Shows.Length > Music.Length && Shows.Length > Ads.Length) {
print ("show :" + Shows.Length);
} else {
print ("there is no one type is biger than others");
}
}