/// <summary> /// To switch to a different weapon among the stored ones in <see cref="weapons"></see>. /// </summary> /// <param name="index">Used when the type is set to ByIndex.</param> public void SwitchWeapon(WeaponSwitchMode mode, int index = 0) { CheckWeaponsAvailability(); DisableAllWeapons(); switch (mode) { case WeaponSwitchMode.Next: currentWeaponIndex = ArraysHandler.GetNextIndex(currentWeaponIndex, weapons.Length); break; case WeaponSwitchMode.Previous: currentWeaponIndex = ArraysHandler.GetPreviousIndex(currentWeaponIndex, weapons.Length); break; case WeaponSwitchMode.ByIndex: if (index >= 0 && index <= weapons.Length - 1) { currentWeaponIndex = index; } break; default: break; } currentWeapon = weapons[currentWeaponIndex]; currentWeapon.gameObject.SetActive(true); }
public virtual void SwitchUseRate(SwitchUseRateType type, int index = 0) { if (useRateValues.Length == 0) { Debug.LogWarning(gameObject.name + ": Need to add at least one UseRate value!"); return; } switch (type) { case SwitchUseRateType.Next: useRateIndex = ArraysHandler.GetNextIndex(useRateIndex, useRateValues.Length); break; case SwitchUseRateType.Previous: useRateIndex = ArraysHandler.GetPreviousIndex(useRateIndex, useRateValues.Length); break; case SwitchUseRateType.ByIndex: if (index >= 0 && index <= useRateValues.Length - 1) { useRateIndex = index; } break; default: break; } _UseRate = useRateValues[useRateIndex]; if (debug) { Debug.Log(gameObject.name + " Weapon UseRate # " + useRateIndex + ": " + _UseRate); } }
private void SetActiveAfterImage() { AfterImages[_CurrentImageIndex].SetActive(); _CurrentImageIndex = ArraysHandler.GetNextIndex(_CurrentImageIndex, AfterImages.Length); }