コード例 #1
0
 private void AddBatteryDetails(Equipment modules, string slot, InventoryItem inventoryItem)
 {
     if (inventoryItem.item.GetTechType() == tier2.TechType)
     {
         var details = new BatteryDetails(modules, slot, inventoryItem.item.GetComponent <Battery>());
         batteries.Add(details);
     }
 }
コード例 #2
0
        public void RechargeBatteries(float surplusPower)
        {
            for (int i = 0; i < batteries.Count; i++)
            {
                BatteryDetails details = batteries[i];

                if (details.IsFull)
                {
                    continue;
                }

                Battery batteryToCharge = details.BatteryRef;
                batteryToCharge._charge = Mathf.Min(batteryToCharge._capacity, batteryToCharge._charge + surplusPower);
                surplusPower           -= (batteryToCharge._capacity - batteryToCharge._charge);
                break;
            }
        }