void HandController_OnPickedUpRangedWeapon(Item item, HandLeftOrRight leftOrRight) { //We destroy the old ammo piece here though //Debug.Log ("Picked up a ranged weapon"); /*if (item.GetComponent <Rigidbody> () != null) { * item.GetComponent<Rigidbody> ().useGravity = true; * } * if (ammoObj != null) * Destroy (ammoObj); * heldWeapon = item; * //Debug.Log (heldWeapon); * SpawnCorrectAmmo ();*/ }
void HandController_OnPickedUpRangedWeapon(Item item, HandLeftOrRight leftOrRight) { GameObject temp; switch (heldWeapon.itemName) { case "Kalashnikov": if (PlayerInventory.Instance.sevensixtwoAmmo > 0) { temp = Instantiate(akMagPrefab); var mag = temp.GetComponent <Magazine> (); var rounds = PlayerInventory.Instance.sevensixtwoAmmo < mag.MaxAmmo ? PlayerInventory.Instance.sevensixtwoAmmo : mag.MaxAmmo; mag.currentAmmo = rounds; PlayerInventory.Instance.sevensixtwoAmmo -= rounds; Destroy(currentSnappedObject); ForceSnap(temp); } break; case "AK 2012": if (PlayerInventory.Instance.sevensixtwoAmmo > 0) { temp = Instantiate(ak2012MagPrefab); var mag = temp.GetComponent <Magazine> (); var rounds = PlayerInventory.Instance.sevensixtwoAmmo < mag.MaxAmmo ? PlayerInventory.Instance.sevensixtwoAmmo : mag.MaxAmmo; mag.currentAmmo = rounds; PlayerInventory.Instance.sevensixtwoAmmo -= rounds; Destroy(currentSnappedObject); ForceSnap(temp); } break; case "Shotgun": if (PlayerInventory.Instance.shotgunShells > 0) { temp = Instantiate(shotgunShellPrefab); PlayerInventory.Instance.shotgunShells -= 1; Destroy(currentSnappedObject); ForceSnap(temp); } break; } }