public void SubtractTransport(Race race, int amount) { TransportShip transportShipToRemove = null; foreach (TransportShip transport in _transportShips) { if (transport.raceOnShip == race) { transport.amount -= amount; if (transport.amount <= 0) { transportShipToRemove = transport; } } } if (transportShipToRemove != null) { TransportShips.Remove(transportShipToRemove); } }
public void AddTransport(Race race, int amount) { bool added = false; foreach (TransportShip transport in _transportShips) { if (transport.raceOnShip == race) { transport.amount += amount; added = true; break; } } if (!added) { TransportShip transport = new TransportShip(); transport.raceOnShip = race; transport.amount = amount; _transportShips.Add(transport); } _maxSpeed = 1; }