// Reload missile weapon public void reload() { bool foundAmmo = false; float reloadTime = Time.time; if (missileWeapon != null) { foreach (ItemBS i in inventory) { //print(i.name); AmmoBS a = i.GetComponent <AmmoBS>(); // if a is Ammo, and a is compatible with the right weapon if ((a != null) && (a.isCompatible(missileWeapon)) && (a != missileWeapon.ClipItem)) { print("Reloading " + missileWeapon.name); missileWeapon.reload(a); foundAmmo = true; break; } } if (foundAmmo == true) { reloadTime += missileWeapon.reloadTime; } } // makes it so you cant move and reload busyState = reloadTime; canSprint = false; }
// reloads the weapon, returns the old clip public void reload(AmmoBS newClip) { //print("Reloading " + item.name + " with " + newClip.name); if (newClip.isCompatible(this)) { AmmoBS oldClip = ClipItem; ClipItem = newClip; nextAttack = Time.time + reloadTime; if (oldClip.rounds <= 0) { character.dropItem(oldClip.item); } } }
// return how many rounds left there are for the missile weapon public int getTotalRounds() { int total = 0; if (missileWeapon != null) { foreach (ItemBS i in inventory) { if (i != null) { AmmoBS a = i.GetComponent <AmmoBS>(); if (a != null && a.ammoType == missileWeapon.ammoType) { total += a.rounds; } } } } return(total); }