Esempio n. 1
0
 public bool Supply(UNIT_SUPPLY type)
 {
     bool supplied = this.SupplyIntern(type);
     if (supplied)
     {
         /* no other actions allowed */
         this.unused = false;
         this.cur_mov = 0;
         this.cur_atk_count = 0;
     }
     return supplied;
 }
Esempio n. 2
0
 /*
 ====================================================================
 Supply percentage of maximum fuel/ammo/both
 Return True if unit was supplied.
 ====================================================================
 */
 public bool SupplyIntern(UNIT_SUPPLY type)
 {
     int amount_ammo, amount_fuel, max, supply_amount;
     bool supplied = false;
     /* ammo */
     if (type == UNIT_SUPPLY.UNIT_SUPPLY_AMMO || type == UNIT_SUPPLY.UNIT_SUPPLY_ALL)
         if (this.CheckSupply(UNIT_SUPPLY.UNIT_SUPPLY_AMMO, out amount_ammo, out amount_fuel))
         {
             max = this.cur_ammo + amount_ammo;
             supply_amount = this.supply_level * max / 100;
             if (supply_amount == 0) supply_amount = 1; /* at least one */
             this.cur_ammo += supply_amount;
             if (this.cur_ammo > max) this.cur_ammo = max;
             supplied = true;
         }
     /* fuel */
     if (type == UNIT_SUPPLY.UNIT_SUPPLY_FUEL || type == UNIT_SUPPLY.UNIT_SUPPLY_ALL)
         if (this.CheckSupply(UNIT_SUPPLY.UNIT_SUPPLY_FUEL, out amount_ammo, out amount_fuel))
         {
             max = this.cur_fuel + amount_fuel;
             supply_amount = this.supply_level * max / 100;
             if (supply_amount == 0) supply_amount = 1; /* at least one */
             this.cur_fuel += supply_amount;
             if (this.cur_fuel > max) this.cur_fuel = max;
             supplied = true;
         }
     return supplied;
 }
Esempio n. 3
0
 public bool CheckSupply(UNIT_SUPPLY type, out int missing_ammo, out int missing_fuel)
 {
     bool ret = false;
     int max_fuel = this.sel_prop.fuel;
     missing_ammo = 0;
     missing_fuel = 0;
     /* no supply near or already moved? */
     if (this.embark == UnitEmbarkTypes.EMBARK_SEA || this.embark == UnitEmbarkTypes.EMBARK_AIR) return false;
     if (this.supply_level == 0) return false;
     if (!this.unused) return false;
     /* supply ammo? */
     if (type == UNIT_SUPPLY.UNIT_SUPPLY_AMMO || type == UNIT_SUPPLY.UNIT_SUPPLY_ANYTHING)
         if (this.cur_ammo < this.prop.ammo)
         {
             ret = true;
             missing_ammo = this.prop.ammo - this.cur_ammo;
         }
     if (type == UNIT_SUPPLY.UNIT_SUPPLY_AMMO) return ret;
     /* if we have a ground transporter assigned we need to use it's fuel as max */
     if (this.CheckFuelUsage() && max_fuel == 0)
         max_fuel = this.trsp_prop.fuel;
     /* supply fuel? */
     if (type == UNIT_SUPPLY.UNIT_SUPPLY_FUEL || type == UNIT_SUPPLY.UNIT_SUPPLY_ANYTHING)
         if (this.cur_fuel < max_fuel)
         {
             ret = true;
             missing_fuel = max_fuel - this.cur_fuel;
         }
     return ret;
 }