public void ManageBuildings() { for (int l = 0; l < map.buildings.Length; l++) { int amount = 0; if (map.buildings[l].Destroyed == false) { if (map.buildings[l].GetType() == factoryCheck.GetType()) { factoryCheck = (FactoryBuilding)map.buildings[l]; if (factoryCheck.Faction == 0) { if (rounds % factoryCheck.ProductionSpeed == 0 && teamResources0 >= 10) { Array.Resize(ref map.units, map.units.Length + 1); map.units[map.units.Length - 1] = factoryCheck.SpawnUnit(); teamResources0 -= 10; } } else { if (rounds % factoryCheck.ProductionSpeed == 0 && teamResources1 >= 10) { Array.Resize(ref map.units, map.units.Length + 1); map.units[map.units.Length - 1] = factoryCheck.SpawnUnit(); teamResources1 -= 10; } } } else if (map.buildings[l].GetType() == resourceCheck.GetType()) { resourceCheck = (ResourceBuilding)map.buildings[l]; amount = resourceCheck.Collect(); map.buildings[l] = resourceCheck; if (resourceCheck.Faction == 0) { teamResources0 += amount; } else { teamResources1 += amount; } } } } }
public override void Save(Building[] building) { FileStream outFile = new FileStream(FILE_NAME, FileMode.Create, FileAccess.Write); StreamWriter writer = new StreamWriter(outFile); FactoryBuilding fCheck = new FactoryBuilding(); for (int r = 0; r < building.Length; r++) { if (building[r].GetType() == fCheck.GetType()) { fCheck = (FactoryBuilding)building[r]; writer.WriteLine("" + fCheck.x + DELIMITER + fCheck.y + DELIMITER + fCheck.health + DELIMITER + fCheck.maxHealth + DELIMITER + fCheck.faction + DELIMITER + fCheck.symbol + DELIMITER + fCheck.unitType + DELIMITER + fCheck.productionSpeed + DELIMITER + fCheck.spawnX + DELIMITER + fCheck.spawnY); } } writer.Close(); outFile.Close(); }