public void constructBuildings() { Building resouceBuilding = new ResourceBuilding(19, 19, 100, "Red", "$", "something", 10, 50); map[19, 19] = resouceBuilding.SymbolImage; buildingsOnMap.Add(resouceBuilding); Building factoryBuilding = new FactoryBuilding(0, 0, 100, "Blue", "@", 55, 50, 50); map[0, 0] = factoryBuilding.SymbolImage; buildingsOnMap.Add(factoryBuilding); }
public void readResourceBuilding() { FileStream inFile = null; StreamReader reader = null; string input; int xPosition; int yPosition; int health; string factionTeam; string symbolImage; string resourceType; int resourcesPerGameTick; int resourcesRemaining; try { inFile = new FileStream(@"Files\ResourceBuilding.txt", FileMode.Open, FileAccess.Read); reader = new StreamReader(inFile); input = reader.ReadLine(); while (input != null) { xPosition = int.Parse(input); yPosition = int.Parse(reader.ReadLine()); health = int.Parse(reader.ReadLine()); factionTeam = (reader.ReadLine()); symbolImage = (reader.ReadLine()); resourceType = (reader.ReadLine()); resourcesPerGameTick = int.Parse(reader.ReadLine()); resourcesRemaining = int.Parse(reader.ReadLine()); Building tmp = new ResourceBuilding(xPosition, yPosition, health, factionTeam, symbolImage, resourceType, resourcesPerGameTick, resourcesRemaining); map[tmp.XPosition, tmp.YPosition] = tmp.SymbolImage; buildingsOnMap.Add(tmp); input = reader.ReadLine(); } File.Delete(@"Files\ResourceBuilding.txt"); reader.Close(); inFile.Close(); } catch (Exception fe) { Debug.WriteLine(fe.Message); } finally { if (inFile != null) { reader.Close(); inFile.Close(); } } }