コード例 #1
0
ファイル: Client.cs プロジェクト: YeeB3Warned/OSFPS
 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
         );
 }
コード例 #2
0
ファイル: WeaponSystem.cs プロジェクト: YeeB3Warned/OSFPS
    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);
    }