// ------------ Methods to initialize buildings, players and other details on to the map ------------\\ /// <summary> /// Initializes the buildings. Creates all buildings for a given economy. /// </summary> /// <param name="r">The red component.</param> private void InitBuildings(LandRegion r) { r.createEconomy(canWalk, new Economy(Economy.POOR)); foreach (OverworldBuilding building in r.GetBuildings()) { int x = (int)building.Origo.x; int y = (int)building.Origo.y; map[x, y] = building.GetSpriteID(); } }
/// <summary> /// Tests the paths between all buildings inside a given land-region. /// </summary> /// <returns><c>true</c>, if paths between buildings was accessable, <c>false</c> otherwise.</returns> /// <param name="region">Region.</param> /// <param name="canWalk">Can walk.</param> public bool TestPathsBetweenBuildings(LandRegion region, int[,] canWalk) { AStarAlgo aStar = new AStarAlgo(canWalk, canWalk.GetLength(0), canWalk.GetLength(1), false); Point castlePlacement = region.GetCastle().GetPosition(); foreach (OverworldBuilding building in region.GetBuildings()) { Point buildingPlacement = building.Origo; if (aStar.calculate(castlePlacement, buildingPlacement).Count == 0) { return(false); } } return(true); }