public void equip_gun(gun_type gun) { equipped_gun_index = (int)gun; if (gun != gun_type.none) { showAmmoInfo(); ArsenalItem new_item = arsenal[(int)gun]; if (new_item.is_in_arsenal) { Gun old_gun = equipped_gun; equipped_gun = new_item.gun; //Swap which game objects are active if (old_gun != null) { old_gun.gameObject.SetActive(false); } equipped_gun.gameObject.SetActive(true); ui_gun_icon.sprite = equipped_gun.gun_info.gun_sprite; } } else { if (equipped_gun != null) { equipped_gun.gameObject.SetActive(false); } hideAmmoInfo(); } }
public void EquipGun(GunType gun) { prevEquippedGunIndex = equippedGunIndex; equippedGunIndex = (int)gun; if (gun != GunType.none) { ShowAmmoInfo(); ArsenalItem new_item = arsenal[(int)gun]; if (new_item.isInArsenal) { Gun old_gun = equippedGun; equippedGun = new_item._gun; //Swap which game objects are active if (old_gun != null) { old_gun.gameObject.SetActive(false); } equippedGun.gameObject.SetActive(true); uiGunIcon.sprite = equippedGun.gunData.gun_sprite; } else { Debug.Log(gun.ToString() + " was not in arsenal."); EquipGun(GunType.none); } } else { if (equippedGun != null) { equippedGun.gameObject.SetActive(false); } HideAmmoInfo(); } }