private void DrawWeaponHud(EquippedWeaponState weapon, Vector2 position, Vector2 iconSize) { GUI.DrawTexture(new Rect(position, iconSize), weapon.Definition.Icon); GUI.Label( new Rect(position + new Vector2(0, iconSize.y), new Vector2(260, 50)), weapon.BulletsLeftInMagazine + " / " + weapon.BulletsLeftOutOfMagazine ); }
public int ServerAddBullets(EquippedWeaponState weaponState, int numBulletsToTryToAdd) { var numBulletsCanAdd = weaponState.Definition.MaxAmmo - weaponState.BulletsLeft; var bulletsToPickUp = Mathf.Min(numBulletsToTryToAdd, numBulletsCanAdd); var bulletsToAddInMagazine = Mathf.Min(bulletsToPickUp, weaponState.BulletsShotFromMagazine); weaponState.BulletsLeftInMagazine += (ushort)bulletsToAddInMagazine; weaponState.BulletsLeftOutOfMagazine += (ushort)(bulletsToPickUp - bulletsToAddInMagazine); return(bulletsToPickUp); }