Game Development Reference
In-Depth Information
5. In the next funcion, we will see four funcion calls, which are SetupEquipBox() ,
ShowWeapon() , ShowArmor() , ShowAccess() , and ShowSkill() . The first
funcion is to set each equipment label as clickable or not. The other funcions are
enabled when the player clicks on each equipment label at the top box, and inside
each funcion will contain the script that allows the player to change and select new
equipment for weapon, armor, accessory, or skill. So, let's type the following code:
//Setting the ability to enabled or disable the button
private function SetupEquipBox () : void {
var equipContent : GUIContent[] = [gui_weaponCon, gui_armorCon,
gui_accessCon, gui_skillCon];
for (var i : int = 0; i < a_equipBoolean.length; i++) {
if (a_equipBoolean[i] == true) {
//Set up disabled Button
GUI.Label(r_equipRect[i], equipContent[i], "Disabled
Click");
//Show each equipment window
switch (i) {
case 0:
ShowWeapon();
break;
case 1:
ShowArmor();
break;
case 2:
ShowAccess();
break;
case 3:
ShowSkill();
break;
}
} else {
//Set up enabled Button
if (GUI.Button(r_equipRect[i], equipContent[i], "Selected
Item")) {
a_equipBoolean[i] = true;
//Set others to false
for (var j : int = 0; j < a_equipBoolean.length; j++) {
if (i != j) {
a_equipBoolean[j] = false;
}
}
}
}
}
}
 
Search WWH ::




Custom Search