static void Main(string[] args) { Building FiveOneTwoEighth = new Building("512 8th Avenue") { Stories = 18, Width = 100, Depth = 90, }; Building SixEightNineCharlotte = new Building("689 Charlotte Avenue") { Stories = 9, Width = 400, Depth = 129, }; Building ThreeZeroOneWestEnd = new Building("301 West End Avenue") { Stories = 24, Width = 900, Depth = 567, }; FiveOneTwoEighth.Construct(); SixEightNineCharlotte.Construct(); ThreeZeroOneWestEnd.Construct(); FiveOneTwoEighth.Purchase("Steve Brownlee"); SixEightNineCharlotte.Purchase("Andy Collins"); ThreeZeroOneWestEnd.Purchase("Jenna Solis"); City nashville = new City("Nashville") { Mayor = "John Cooper" }; nashville.EstablishCity(1806); nashville.PrintCityInfo(); nashville.AddBuilding(FiveOneTwoEighth); nashville.AddBuilding(SixEightNineCharlotte); nashville.AddBuilding(ThreeZeroOneWestEnd); foreach (Building building in nashville.buildings) { building.PrintBuildingInfo(); } }
/// <summary> /// Instantiates a city marker and returns a reference to it. /// The "real" data is maintained in the marker's "City" component, which is also created here. /// </summary> public GameObject SpawnCityMarker(string cityName, Vector3 cityPosition, int wealth, List <Building> startingBuildings = null, Allegiance allegiance = Allegiance.NONE) { // TODO: Set allegiances to NONE by default GameObject marker = (GameObject)Instantiate(cityMarkerPrefab, cityPosition, Quaternion.identity); City city = marker.AddComponent <City>(); city.placeName = cityName; city.allegiance = allegiance; city.wealth = wealth; city.governor = new Governor(city.placeName + " Governor", city, AIStrategy.DEFAULT); if (startingBuildings != null) { foreach (Building building in startingBuildings) { city.AddBuilding(building); } } /// Keep track of the city in an array. /// Why? For connecting the cities with roads. cities.Add(city); return(marker); }
static void Main(string[] args) { City Nashville = new City("Nashville", "Holden Parker", 1706); Building FiveOneTwoEigth = new Building("512 8th Avenue") { Width = 100, Depth = 200, Stories = 8 }; Building ThreeSixFiveTwentyFourth = new Building("365 24th Avenue") { Width = 300, Depth = 150, Stories = 7 }; Building TwoOneJump = new Building("21 Jump St") { Width = 50, Depth = 200, Stories = 3 }; FiveOneTwoEigth.Design("Holden Parker"); ThreeSixFiveTwentyFourth.Design("Holden Parker"); TwoOneJump.Design("Holden Parker"); FiveOneTwoEigth.Construct(); ThreeSixFiveTwentyFourth.Construct(); TwoOneJump.Construct(); FiveOneTwoEigth.Purchase("Adam Sheaffer"); ThreeSixFiveTwentyFourth.Purchase("Brenda Long"); TwoOneJump.Purchase("Rose Wisotzky"); Nashville.AddBuilding(FiveOneTwoEigth); Nashville.AddBuilding(ThreeSixFiveTwentyFourth); Nashville.AddBuilding(TwoOneJump); foreach (Building building in Nashville.Buildings) { building.Print(); } }
/// <summary> /// If a building can be built in a particular city and a /// leader has enough money to buy it, perform the purchase. /// </summary> public void PurchaseBuilding(Building building, City city) { if ((city.CanBuild(building)) && (gold > building.cost)) { city.AddBuilding(building); this.gold -= building.cost; } }
public void City5With1EntAndTemple() { var unit = Game.Instance.GetUnits().First(x => x.Owner == playa.Civilization.Id); City acity = Game.Instance.AddCity(playa, 1, unit.X, unit.Y); acity.Size = 5; acity.ResetResourceTiles(); // setting city size doesn't allocate all resources MakeOneEntertainer(acity); acity.AddBuilding(Reflect.GetBuildings().First(b => b is Temple)); using (var foo = acity.Residents.GetEnumerator()) { foo.MoveNext(); var citizenTypes = foo.Current; // initial state Assert.Equal(0, citizenTypes.happy); Assert.Equal(2, citizenTypes.content); Assert.Equal(2, citizenTypes.unhappy); Assert.Equal(1, citizenTypes.elvis); foo.MoveNext(); citizenTypes = foo.Current; // luxury Assert.Equal(1, citizenTypes.happy); Assert.Equal(1, citizenTypes.content); Assert.Equal(2, citizenTypes.unhappy); Assert.Equal(1, citizenTypes.elvis); foo.MoveNext(); citizenTypes = foo.Current; // temple Assert.Equal(1, citizenTypes.happy); Assert.Equal(2, citizenTypes.content); Assert.Equal(1, citizenTypes.unhappy); Assert.Equal(1, citizenTypes.elvis); } }
private void BAccept(object sender, EventArgs args) { _selectedBldg = _buildings[_bldgSelect.ActiveItem + _index]; _selectedCity.AddBuilding(_selectedBldg); Destroy(); }