Пример #1
0
 private void ReloadWeapon()
 {
     if (InputManager.GetKeyDown(InputNames.reload) && (PlayerStat.pistolWield || PlayerStat.rifleWield))
     {
         if (PlayerStat.rifleWield)
         {
             if (rifleInfo.magazine < rifleInfo.maxMagazine)
             {
                 if (rifleInfo.carryingCapacity > rifleInfo.maxMagazine - rifleInfo.magazine || rifleInfo.carryingCapacity > 0)
                 {
                     anim.Reload();
                     WaitCoroutine(3f);
                     if (rifleInfo.carryingCapacity > rifleInfo.maxMagazine - rifleInfo.magazine)
                     {
                         rifleInfo.magazine         += rifleInfo.maxMagazine - rifleInfo.magazine;
                         rifleInfo.carryingCapacity -= rifleInfo.maxMagazine - rifleInfo.magazine;
                     }
                     else
                     {
                         rifleInfo.magazine         += rifleInfo.carryingCapacity;
                         rifleInfo.carryingCapacity -= rifleInfo.carryingCapacity;
                     }
                 }
             }
         }
         else if (PlayerStat.pistolWield)
         {
             if (pistolInfo.magazine < pistolInfo.maxMagazine)
             {
                 anim.Reload();
                 WaitCoroutine(2f);
                 if (pistolInfo.carryingCapacity > pistolInfo.maxMagazine - pistolInfo.magazine)
                 {
                     pistolInfo.magazine         += pistolInfo.maxMagazine - pistolInfo.magazine;
                     pistolInfo.carryingCapacity -= pistolInfo.maxMagazine - pistolInfo.magazine;
                 }
                 else
                 {
                     pistolInfo.magazine         += pistolInfo.carryingCapacity;
                     pistolInfo.carryingCapacity -= pistolInfo.carryingCapacity;
                 }
             }
         }
     }
 }