Hi All,
I’ve got a training excercise that I’m working on in which the trainee enters a number of samples (n) in an input field. The game should then select (n) numbers of serial numbers from a set range and display them.
Then, the student is to enter another number of samples (n2) that should be randomly selected from the serial numbers generated in (n). And display them.
Then, the student is to enter another number of samples (n3) that should be selected from the serials not selected in (n2) but left over from (n) and display them.
Then, it’s important that Unity keeps track of all of these serial numbers (n, n2, and n3) so we can check if the student actually went to the items whose serial numbers were presented.
I’ve got an OnGUI that asks for the inputs, and then generates the next input field, but am at a loss as to how to tackle the logic of these sequentially dependent random selections - and then even more perplexed as to how to store the randomly generated serials (a different number of them depending on the entry of the student) so they can be accessed accross game levels.
static var bigNDeclaration : String = "#";
static var nInput : String = "#";
static var n2Input : String = "#";
static var n3Input : String = "#";
private var shownInput : boolean;
private var shown2Input : boolean;
private var shown3Input : boolean;
function OnGUI () {
if (ToolFunctionality.samplingPlanToolActive){
bigNDeclaration = GUI.TextField (Rect (((Screen.width/2)-400), ((Screen.height/2)-270),100,20), bigNDeclaration, 25);
if (GUI.Button (Rect (((Screen.width/2)-280), ((Screen.height/2)-270),100,20), "Submit")){
show_nInput = true;
}
if (show_nInput){
nInput = GUI.TextField (Rect (((Screen.width/2)-400), ((Screen.height/2)-155),100,20), nInput, 25);
if (GUI.Button (Rect (((Screen.width/2)-280), ((Screen.height/2)-155),100,20), "Submit")){
shown2Input = true;
}
}
if (show_n2Input){
n2Input = GUI.TextField (Rect (((Screen.width/2)-400), ((Screen.height/2)-50),100,20), n2Input, 25);
if (GUI.Button (Rect (((Screen.width/2)-280), ((Screen.height/2)-50),100,20), "Submit")){
shown3Input = true;
}
}
if (show_n3Input){
n3Input = GUI.TextField (Rect (((Screen.width/2)-400), ((Screen.height/2)+55),100,20), n3Input, 25);
if (GUI.Button (Rect (((Screen.width/2)-280), ((Screen.height/2)+55),100,20), "Submit")){
shown3Input = true;
}
}
}
}
Any help on strategy would be greatly appreciated…