IEnumerator Start() { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); if (GetComponent <PlayerControl>()) { updateUI.HighlightSlot(activeSlot); isPlayer = true; } else { isPlayer = false; } switchWeapon = GameObject.Find("Weapon").GetComponent <SwitchWeapon>(); }
void Update() { if (!updated && updateUI) { updateUI.HighlightSlot(activeSlot); updated = true; } if (weaponInventory.Count > 0 && done) { //If these buttons are smashed multiple guns can be spawned, implement a check to see if child count is greater than three and delete anything higher than that. if (one) { activeSlot = 0; activeSlot = Mathf.Clamp(activeSlot, 0, 4); if (weaponInventory[activeSlot].id == 15) { switchWeapon.Switch(15); } else if (weaponInventory[activeSlot].name != "Fists") { switchWeapon.Switch(weaponInventory[activeSlot].id); } else { switchWeapon.Switch(100); } if (hasAuthority) { if (isPlayer) { updateUI.HighlightSlot(activeSlot); } } one = false; } if (two) { activeSlot = 1; activeSlot = Mathf.Clamp(activeSlot, 0, 4); if (weaponInventory[activeSlot].name != "Fists") { switchWeapon.Switch(weaponInventory[activeSlot].id); } else { switchWeapon.Switch(100); } if (hasAuthority) { if (isPlayer) { updateUI.HighlightSlot(activeSlot); } } two = false; } if (three) { activeSlot = 2; activeSlot = Mathf.Clamp(activeSlot, 0, 4); if (weaponInventory[activeSlot].name != "Fists") { switchWeapon.Switch(weaponInventory[activeSlot].id); } else { switchWeapon.Switch(100); } if (hasAuthority) { if (isPlayer) { updateUI.HighlightSlot(activeSlot); } } three = false; } if (four) { activeSlot = 3; activeSlot = Mathf.Clamp(activeSlot, 0, 4); if (weaponInventory[activeSlot].name != "Fists") { switchWeapon.Switch(weaponInventory[activeSlot].id); } else { switchWeapon.Switch(100); } if (hasAuthority) { if (isPlayer) { updateUI.HighlightSlot(activeSlot); } } four = false; } if (weaponInventory[activeSlot].name != "Fists") { weaponHeld = true; } else { weaponHeld = false; } } }