public void SetWeapon(int next, int prev) { if (CheckWeapon()) { WeaponSystem weapon = GetCurWeapon(); weapon.CancelReload(); SetWeaponActive(weapon, false); } int cur = curWeapon; curWeapon = next; prevWeapon = prev; WeaponSystem nextWeapon = GetCurWeapon(); if (cur != next) { LoadoutManager.instance.SwitchWeapon(cur, next); } SetWeaponActive(nextWeapon, true); LoadoutManager.instance.UpdateWeapon(nextWeapon.GetCurAmmo(), nextWeapon.data.ammo); }
void Switch(WeaponSystem weapon, bool toSidearm) { if (curWeapon == 2 && toSidearm) { toSidearm = false; } nextWeapon = curWeapon; switch (curWeapon) { case 0: if (!toSidearm && weaponSecondary != null) { nextWeapon = 1; } else if (weaponSidearm != null) { prevWeapon = 0; nextWeapon = 2; } break; case 1: if (!toSidearm && weaponPrimary != null) { nextWeapon = 0; } else if (weaponSidearm != null) { prevWeapon = 1; nextWeapon = 2; } break; case 2: if (weaponPrimary != null && prevWeapon == 0 || prevWeapon != 1) { nextWeapon = 0; } else if (weaponSecondary != null && prevWeapon == 1 || prevWeapon != 0) { nextWeapon = 1; } break; default: nextWeapon = 0; break; } if (nextWeapon != curWeapon) { if (source.isPlaying) { source.Stop(); } if (weapon != null) { weapon.CancelReload(); } weapon.SwitchingWeapon(true); LoadoutManager.instance.SwitchWeapon(curWeapon, nextWeapon); switching = true; switchTimer = weapon.data.switchTime; } }