private void activePower(int index) { if (GlobalRegistry.CheckKey("Mechanic" + index)) { keyMechanics[index].Activate(); } if (GlobalRegistry.CheckKeyUp("Mechanic" + index)) { keyMechanics[index].Release(); } }
// Update is called once per frame void Update() { //Check the STATIC OBJECT ARRAY, which is an array of PowerSlot Objects, and if either 0, 1 or 2 has a keycode that is being //pressed, get its power attached and do it. for (int i = 0; i < MECHANIC_SLOTS; i++) { //Open a Power-choosing menu if (GlobalRegistry.CheckKey("PowerMenu" + i)) { mechanicMenu[i] = true; //If the Image is currently shrinking, stop it from doing that! Timing.KillCoroutines("PowerUI" + i); //Start new routine Timing.RunCoroutine(resizeUIImage(UISlots[i], 75), "PowerUI" + i); Player.GetPlayer().SetMobility(false); } if (GlobalRegistry.CheckKeyUp("PowerMenu" + i)) { mechanicMenu[i] = false; //If the Image is currently growing, stop it from doing that! Timing.KillCoroutines("PowerUI" + i); //Start new routine Timing.RunCoroutine(resizeUIImage(UISlots[i], 50), "PowerUI" + i); //If all other mechanicMenu variables are false as well, reactivate mobility //Start by reactivating mobility... Player.GetPlayer().SetMobility(true); for (int j = 0; j < MECHANIC_SLOTS; j++) { //...But if any other mechanicMenu variables ARE true, reset it to false! if (mechanicMenu[j] == true) { Player.GetPlayer().SetMobility(false); } } } //Activating a Power if (mechanicMenu[i] == false) { activePower(i); } else { activeMenu(i); } } }