Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 13, 2007, 9:25:37 PM (16 years ago)
Author:
rgrieder
Message:
  • added a simple ammo dump
  • created BaseWeapon from WeaponManager
  • created the WeaponStation object
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/main_reto_vs05/src/weapon/ammunition_dump.cc

    r189 r198  
    3232namespace weapon {
    3333
    34   AmmunitionDump::AmmunitionDump()
     34  AmmunitionDump::AmmunitionDump(int capacity)
     35        : stock_(0), capacity_(capacity)
    3536  {
    3637  }
     
    4142  }
    4243
     44 
     45  void AmmunitionDump::store(int quantity)
     46  {
     47    stock_ += quantity;
     48    if (stock_ > capacity_)
     49      stock_ = capacity_;
     50  }
     51
     52
     53  int AmmunitionDump::getAmmunition(int quantity)
     54  {
     55    if (stock_ >= quantity)
     56    {
     57      stock_ -= quantity;
     58      return quantity;
     59    }
     60    else
     61    {
     62      quantity = stock_;
     63      stock_ = 0;
     64      return quantity;
     65    }
     66  }
     67
     68
     69  int AmmunitionDump::getStockSize()
     70  {
     71    return stock_;
     72  }
    4373}
    4474}
Note: See TracChangeset for help on using the changeset viewer.