Game Development Reference
In-Depth Information
readonly Rect EQUIP_WEAPON_RECT = new Rect (237, 280,
360, 157);
readonly Rect EQUIP_STAT_RECT = new Rect (252, 81,
331, 142);
readonly Rect EQUIP_SKILL_RECT = new Rect (460, 121,
127, 125);
readonly Rect [] EQUIP_RECTS = { new Rect (252, 101,
180, 40), new Rect (252, 221, 180, 40), new Rect
(464, 125, 119, 117)};
bool[] _equipBooleans = new bool[4];
5. Then, we create EquipWindow() , which will contain the script that is used to
create the EQUIPMENT window's UI. In this function, we also check whether
each equipment label is clickable or not. Here, we use the switch-case state-
ment again to check which state we are in when the player clicks on each equip-
ment label in the box at the top of the screen. It will basically show the correct
equipments or skills in the box at the bottom of the screen, which also allows the
player to select a new equipment or skill. So, let's type the following code after
the ItemWindow() function:
// Unity JavaScript user:
private function ItemWindow() : void {
}
private function EquipWindow() : void {
GUI.Box (EQUIP_BOX_RECT, "");
GUI.Box (EQUIP_WEAPON_RECT, "");
GUI.DrawTexture(EQUIP_STAT_RECT, statBox2Texture);
GUI.DrawTexture(EQUIP_SKILL_RECT, skillBoxTexture);
var equipContent : GUIContent[] =
[weapons.guiContent, armors.guiContent,
accessories.guiContent, skills.guiContent];
for (var i : int = 0; i < _equipBooleans.Length;
i++) {
if (_equipBooleans[i] == true) {
GUI.Label(EQUIP_RECTS[i], equipContent[i],
Search WWH ::




Custom Search