private void InitializeBuildings() { buildings = new Building[numBuildings]; for (int i = 0; i < buildings.Length; i++) { int x = GameEngine.random.Next(0, SIZE); int y = GameEngine.random.Next(0, SIZE); int factionlndex = GameEngine.random.Next(0, 2); int buildingType = GameEngine.random.Next(0, 2); while (map[x, y] != null) { x = GameEngine.random.Next(0, SIZE); y = GameEngine.random.Next(0, SIZE); } if (buildingType == 0) { buildings[i] = new ResourceBuilding(x, y, factions[factionlndex]); } else { buildings[i] = new FactoryBuilding(x, y, factions[factionlndex]); } map[x, y] = buildings[i].Faction[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.AddUnit(newUnit); } } else if (building is ResourceBuilding) { ResourceBuilding resourceBuilding = (ResourceBuilding)building; resourceBuilding.GenerateResources(); } } }