public void populateMap() { size = rnd.Next(25, MAX_RANDOM_UNIT); for (int i = 0; i < 20; i++) { for (int j = 0; j < 20; j++) { map[i, j] = "."; } } FactoryBuilding tempPurple = new FactoryBuilding(19, 19, 500, "Purple", "P", 18, 18, 2, size); structuresOnMap.Add(tempPurple); map[19, 19] = structuresOnMap[0].Symbol; FactoryBuilding tempYellow = new FactoryBuilding(0, 0, 500, "Yellow", "Y", 1, 1, 2, size); structuresOnMap.Add(tempYellow); map[0, 0] = structuresOnMap[1].Symbol; ResourceBuilding teamPurple = new ResourceBuilding(18, 19, 200, "Purple", "$", "Gold", 2, 1000); resourcesOnMap.Add(teamPurple); map[18, 19] = resourcesOnMap[0].Symbol; ResourceBuilding teamYellow = new ResourceBuilding(0, 1, 200, "Yellow", "$", "Gold", 2, 1000); resourcesOnMap.Add(teamYellow); map[0, 1] = resourcesOnMap[1].Symbol; }
public void populateMap() { size = rnd.Next(25, MAX_RANDOM_UNIT); for (int i = 0; i < 20; i++) { for (int j = 0; j < 20; j++) { map[i, j] = "."; } } FactoryBuilding tempPurple = new FactoryBuilding(19, 19, 500, "Purple", "P", 18, 18, 2, size); structuresOnMap.Add(tempPurple); map[19, 19] = structuresOnMap[0].Symbol; FactoryBuilding tempYellow = new FactoryBuilding(0, 0, 500, "Yellow", "Y", 1, 1, 2, size); structuresOnMap.Add(tempYellow); map[0, 0] = structuresOnMap[1].Symbol; ResourceBuilding teamPurple = new ResourceBuilding(18, 19, 200, "Purple", "$", "Gold", 2, 1000); resourcesOnMap.Add(teamPurple); map[18, 19] = resourcesOnMap[0].Symbol; ResourceBuilding teamYellow = new ResourceBuilding(0, 1, 200, "Yellow", "$", "Gold", 2, 1000); resourcesOnMap.Add(teamYellow); map[0, 1] = resourcesOnMap[1].Symbol; NeutralCamp camp0 = new NeutralCamp(10, 19, 100, "Neutral", "N", 10, 18, 10); neutralCamps.Add(camp0); map[10, 19] = neutralCamps[0].Symbol; NeutralCamp camp1 = new NeutralCamp(0, 9, 100, "Neutral", "N", 1, 9, 10); neutralCamps.Add(camp1); map[0, 9] = neutralCamps[0].Symbol; NeutralCamp camp2 = new NeutralCamp(10, 0, 100, "Neutral", "N", 10, 1, 10); neutralCamps.Add(camp2); map[10, 0] = neutralCamps[0].Symbol; NeutralCamp camp3 = new NeutralCamp(19, 10, 100, "Neutral", "N", 18, 10, 10); neutralCamps.Add(camp3); map[19, 10] = neutralCamps[0].Symbol; Tower purpleTower = new Tower(17, 17, 100, "Purple", "T", true, 5); towers.Add(purpleTower); map[17, 17] = towers[0].Symbol; Tower yellowTower = new Tower(2, 2, 100, "Yellow", "T", true, 5); towers.Add(purpleTower); map[2, 2] = towers[1].Symbol; }
public void readFile() { FileStream inFile = null; StreamReader reader = null; string input; int x; int y; int health; int speed; bool attack; int range; string faction; string symbol; string name; Unit tmp = null; FactoryBuilding temp = null; ResourceBuilding temporary = null; try { inFile = new FileStream(@"Files\Units.txt", FileMode.Open, FileAccess.Read); reader = new StreamReader(inFile); input = reader.ReadLine(); while (input != null) { x = Convert.ToInt32(input); y = Convert.ToInt32(reader.ReadLine()); health = Convert.ToInt32(reader.ReadLine()); speed = Convert.ToInt32(reader.ReadLine()); attack = Convert.ToBoolean(reader.ReadLine()); range = Convert.ToInt32(reader.ReadLine()); faction = reader.ReadLine(); symbol = reader.ReadLine(); name = reader.ReadLine(); if (symbol == "M") { tmp = new MeleeUnit(x, y, health, speed, attack, range, faction, symbol, name); } else if (symbol == "R") { tmp = new RangeUnit(x, y, health, speed, attack, range, faction, symbol, name); } unitsOnMap.Add(tmp); map[x, y] = symbol; input = reader.ReadLine(); } reader.Close(); inFile.Close(); } catch (Exception e) { Debug.WriteLine(e); } finally { if (inFile != null) { reader.Close(); inFile.Close(); } } int minXBoundary; int maxXBoundary; int minYBoundary; int maxYBoundary; try { inFile = new FileStream(@"Files\CreepUnits.txt", FileMode.Open, FileAccess.Read); reader = new StreamReader(inFile); input = reader.ReadLine(); while (input != null) { x = Convert.ToInt32(input); y = Convert.ToInt32(reader.ReadLine()); health = Convert.ToInt32(reader.ReadLine()); speed = Convert.ToInt32(reader.ReadLine()); attack = Convert.ToBoolean(reader.ReadLine()); range = Convert.ToInt32(reader.ReadLine()); faction = reader.ReadLine(); symbol = reader.ReadLine(); name = reader.ReadLine(); minXBoundary = Convert.ToInt32(reader.ReadLine()); maxXBoundary = Convert.ToInt32(reader.ReadLine()); minYBoundary = Convert.ToInt32(reader.ReadLine()); maxYBoundary = Convert.ToInt32(reader.ReadLine()); tmp = new NeutralCreep(x, y, health, speed, attack, range, faction, symbol, name, minXBoundary, maxXBoundary, minYBoundary, maxYBoundary); unitsOnMap.Add(tmp); map[x, y] = symbol; input = reader.ReadLine(); } reader.Close(); inFile.Close(); } catch { } finally { if (inFile != null) { reader.Close(); inFile.Close(); } } int spawnPointX; int spawnPointY; int tickPerProduction; int unitsToProduce; try { inFile = new FileStream(@"Files\Structures.txt", FileMode.Open, FileAccess.Read); reader = new StreamReader(inFile); input = reader.ReadLine(); while (input != null) { x = Convert.ToInt32(input); y = Convert.ToInt32(reader.ReadLine()); health = Convert.ToInt32(reader.ReadLine()); faction = reader.ReadLine(); symbol = reader.ReadLine(); spawnPointX = Convert.ToInt32(reader.ReadLine()); spawnPointY = Convert.ToInt32(reader.ReadLine()); tickPerProduction = Convert.ToInt32(reader.ReadLine()); unitsToProduce = Convert.ToInt32(reader.ReadLine()); temp = new FactoryBuilding(x, y, health, faction, symbol, spawnPointX, spawnPointY, tickPerProduction, unitsToProduce); structuresOnMap.Add(temp); map[x, y] = symbol; input = reader.ReadLine(); } reader.Close(); inFile.Close(); } catch (Exception e) { Debug.WriteLine(e); } finally { if (inFile != null) { reader.Close(); inFile.Close(); } } string typeOfResource; int resourcesPerTick; int resourcesRemaining; try { inFile = new FileStream(@"Files\Resources.txt", FileMode.Open, FileAccess.Read); reader = new StreamReader(inFile); input = reader.ReadLine(); while (input != null) { x = Convert.ToInt32(input); y = Convert.ToInt32(reader.ReadLine()); health = Convert.ToInt32(reader.ReadLine()); faction = reader.ReadLine(); symbol = reader.ReadLine(); typeOfResource = reader.ReadLine(); resourcesPerTick = Convert.ToInt32(reader.ReadLine()); resourcesRemaining = Convert.ToInt32(reader.ReadLine()); temporary = new ResourceBuilding(x, y, health, faction, symbol, typeOfResource, resourcesPerTick, resourcesRemaining); resourcesOnMap.Add(temporary); map[x, y] = symbol; input = reader.ReadLine(); } reader.Close(); inFile.Close(); } catch (Exception e) { Debug.WriteLine(e); } finally { if (inFile != null) { reader.Close(); inFile.Close(); } } }