void Start() { foreach (Weapon w in GetComponentsInChildren <Weapon>()) { w.gameObject.SetActive(false); weapons.Add(w); } for (int i = 0; i < weapons.Count; i++) { if (i == 0) { weapons[i].gameObject.SetActive(true); } else { WeaponZoom weaponZoom = weapons[activeWeaponIndex].GetComponent <WeaponZoom>(); if (weaponZoom != null) { weaponZoom.ZoomOut(); } weapons[i].gameObject.SetActive(false); } } }
private void CycleToNextWeapon() { WeaponZoom weaponZoom = weapons[activeWeaponIndex].GetComponent <WeaponZoom>(); if (weaponZoom != null) { weaponZoom.ZoomOut(); } weapons[activeWeaponIndex].gameObject.SetActive(false); if (weapons.Count == activeWeaponIndex + 1) { activeWeaponIndex = 0; } else { activeWeaponIndex++; } weapons[activeWeaponIndex].gameObject.SetActive(true); }
private void ActivateWeapon(int index) { if (index >= weapons.Count) { return; } if (index == activeWeaponIndex) { return; } WeaponZoom weaponZoom = weapons[activeWeaponIndex].GetComponent <WeaponZoom>(); if (weaponZoom != null) { weaponZoom.ZoomOut(); } weapons[activeWeaponIndex].gameObject.SetActive(false); activeWeaponIndex = index; weapons[activeWeaponIndex].gameObject.SetActive(true); }
private void CycleToPreviousWeapon() { WeaponZoom weaponZoom = weapons[activeWeaponIndex].GetComponent <WeaponZoom>(); if (weaponZoom != null) { weaponZoom.ZoomOut(); } weapons[activeWeaponIndex].gameObject.SetActive(false); if (activeWeaponIndex == 0) { activeWeaponIndex = weapons.Count - 1; } else { activeWeaponIndex--; } weapons[activeWeaponIndex].gameObject.SetActive(true); }
void Start() { weaponZoom = GetComponent <WeaponZoom>(); weapon = GetComponent <Weapon>(); }