public void InitialiseBuildings() //Creates the buildings { buildings = new Building[numBuildings]; for (int i = 0; i < buildings.Length; i++) { int x = r.Next(0, SIZE); int y = r.Next(0, SIZE); int buildingIndex = r.Next(0, 2); int buildingType = r.Next(0, 2); while (map[x, y] != null) { x = r.Next(0, SIZE); y = r.Next(0, SIZE); } if (buildingType == 0) { buildings[i] = new ResourceBuilding(x, y, teams[buildingIndex]); } else { buildings[i] = new FactoryBuilding(x, y, teams[buildingIndex]); } map[x, y] = buildings[i].Team[0] + "|" + buildings[i].Symbol; } }
void UpdateBuildings() { foreach (Building building in map.Buildings) { if (building is FactoryBuilding) { FactoryBuilding factoryBuilding = (FactoryBuilding)building; if (round % factoryBuilding.ProductionSpeed == 0) { Unit newUnit = factoryBuilding.SpawnUnit(); map.AddInUnits(newUnit); } } else if (building is ResourceBuilding) { ResourceBuilding resourceBuilding = (ResourceBuilding)building; resourceBuilding.GenerateResources(); } } }