public bool SetDestination(IInventoryTourist tourist, TouristRegion touristRegion) { if (tourist == null) { errorHandler.ReportError("Unable to Set Tourist Destination.", ErrorState.restart_scene); return(false); } if (started == false) { Start(); } bool destinationSet = false; //Get possible Provinces List <int> provinceChoices = GetProvinceDestinations(touristRegion, touristManager.RecentProvinceDestinations); //Get possible Landmarks List <string> landmarkChoices = GetLandmarkDestinations(touristRegion, touristManager.RecentLandmarkDestinations); //Get possible Countries List <int> countryChoices = GetCountryDestinations(touristRegion, touristManager.RecentCountryDestinations); //Treat all three lists as a combined list and get a random number that points to an element from one of them destinationIndex = Random.Range(0, provinceChoices.Count + landmarkChoices.Count + countryChoices.Count); if (destinationIndex < provinceChoices.Count) { destinationSet = SetProvinceDestination(provinceChoices[destinationIndex], tourist); } else if ((destinationIndex >= provinceChoices.Count) && (destinationIndex < (landmarkChoices.Count + provinceChoices.Count))) { destinationIndex = destinationIndex - provinceChoices.Count; destinationSet = SetLandmarkDestination(landmarkChoices[destinationIndex], tourist); } else if (destinationIndex >= provinceChoices.Count + landmarkChoices.Count) { destinationIndex = destinationIndex - provinceChoices.Count - landmarkChoices.Count; destinationSet = SetCountryDestination(countryChoices[destinationIndex], tourist); } else { errorHandler.ReportError("Unable to Set Tourist Destination.", ErrorState.restart_scene); } return(destinationSet); }
/// <summary> /// Gets possible province destinations from a given tourist region /// </summary> /// <param name="touristRegion"> The tourist region the province is being selected from</param> /// <param name="recentProvinceDestinations"> A list of recent province destinations used to avoid picking a /// recent destination</param> private List <int> GetProvinceDestinations(TouristRegion touristRegion, List <int> recentProvinceDestinations) { if (recentProvinceDestinations == null) { errorHandler.ReportError("Recent province destinations missing", ErrorState.restart_scene); return(null); } if (touristRegion.provinces == null) { errorHandler.ReportError("Tourist region provinces missing", ErrorState.restart_scene); return(null); } List <int> provinceDestinations = new List <int>(); foreach (int province in touristRegion.provinces) { //Get Time Multiplier int timeMultiplier = recentProvinceDestinations.IndexOf(province); //Check if destination is no longer being tracked if (timeMultiplier < 0) { timeMultiplier = touristManager.TrackingTime; } int totalMultiplier = timeMultiplier * PROVINCE_MULTIPLIER; //Add Province a Number of Times Equal to Total Multiplier for (int n = 0; n < totalMultiplier; n++) { provinceDestinations.Add(province); } } return(provinceDestinations); }
/// <summary> /// Gets possible landmark destinations from a given tourist region /// </summary> /// <param name="touristRegion"> The tourist region the landmark is being selected from</param> /// <param name="recentLandmarkDestinations"> A list of recent landmark destinations used to avoid picking a /// recent destination</param> private List <string> GetLandmarkDestinations(TouristRegion touristRegion, List <string> recentLandmarkDestinations) { if (recentLandmarkDestinations == null) { errorHandler.ReportError("Recent landmark destinations missing", ErrorState.restart_scene); return(null); } if (touristRegion.landmarks == null) { errorHandler.ReportError("Tourist region landmarks missing", ErrorState.restart_scene); return(null); } List <string> landmarkDestinations = new List <string>(); foreach (string landmark in touristRegion.landmarks) { //Get Time Multiplier int timeMultiplier = recentLandmarkDestinations.IndexOf(landmark); //Check if destination is no longer being tracked if (timeMultiplier < 0) { timeMultiplier = touristManager.TrackingTime; } int totalMultiplier = timeMultiplier * LANDMARK_MULTIPLIER; //Add Landmark a Number of Times Equal to Total Multiplier for (int n = 0; n < totalMultiplier; n++) { landmarkDestinations.Add(landmark); } } return(landmarkDestinations); }
/// <summary> /// Gets possible country destinations from a given tourist region /// </summary> /// <param name="touristRegion"> The tourist region the country is being selected from</param> /// <param name="recentProvinceDestinations"> A list of recent country destinations used to avoid picking a /// recent destination</param> private List <int> GetCountryDestinations(TouristRegion touristRegion, List <int> recentCountryDestinations) { if (recentCountryDestinations == null) { errorHandler.ReportError("Recent country destinations missing", ErrorState.restart_scene); return(null); } if (touristRegion.countries == null) { errorHandler.ReportError("Tourist region countries missing", ErrorState.restart_scene); return(null); } List <int> countryDestinations = new List <int>(); foreach (int country in touristManager.CurrentRegion.countries) { //Get Time Multiplier int timeMultiplier = touristManager.RecentCountryDestinations.IndexOf(country); //Check if destination is no longer being tracked if (timeMultiplier < 0) { timeMultiplier = touristManager.TrackingTime; } int totalMultiplier = timeMultiplier * COUNTRY_MULTIPLIER; //Add Country a Number of Times Equal to Total Multiplier for (int n = 0; n < totalMultiplier; n++) { countryDestinations.Add(country); } } return(countryDestinations); }
/// <summary> /// Instantiate all tourist regions and set initial region /// </summary> private void InitTouristRegions() { #region Create North East Region TouristRegion northAmericaNorthEast = new TouristRegion(); touristRegions.Add(northAmericaNorthEast); northAmericaNorthEast.regionName = "North America: North East"; //Provinces northAmericaNorthEast.provinces.Add(494); //Newfoundland and Labrador northAmericaNorthEast.provinces.Add(491); //Québec northAmericaNorthEast.provinces.Add(490); //Ontario northAmericaNorthEast.provinces.Add(493); //Nova Scotia northAmericaNorthEast.provinces.Add(492); //New Brunswick //Prince Edward Island (495) Not being included due to small size northAmericaNorthEast.provinces.Add(3917); //Maine northAmericaNorthEast.provinces.Add(3894); //New Hampshire northAmericaNorthEast.provinces.Add(3896); //Vermont northAmericaNorthEast.provinces.Add(3869); //Massachusetts northAmericaNorthEast.provinces.Add(3895); //Rhode Island northAmericaNorthEast.provinces.Add(3893); //Connecticut northAmericaNorthEast.provinces.Add(3915); //New York //Landmarks northAmericaNorthEast.landmarks.Add("Statue Of Liberty"); northAmericaNorthEast.landmarks.Add("CN Tower"); northAmericaNorthEast.landmarks.Add("Parliament Hill"); northAmericaNorthEast.landmarks.Add("Fairmont Le Château Frontenac"); #endregion #region Create US Mid West Regions TouristRegion northAmericaUSMidWestMidAtlantic = new TouristRegion(); touristRegions.Add(northAmericaUSMidWestMidAtlantic); northAmericaUSMidWestMidAtlantic.regionName = "North America: US Mid West & Mid Atlantic"; //Provinces northAmericaUSMidWestMidAtlantic.provinces.Add(490); //Ontario northAmericaUSMidWestMidAtlantic.provinces.Add(3915); //New York northAmericaUSMidWestMidAtlantic.provinces.Add(3914); //New Jersey northAmericaUSMidWestMidAtlantic.provinces.Add(3916); //Pennsylvania northAmericaUSMidWestMidAtlantic.provinces.Add(3911); //Delaware northAmericaUSMidWestMidAtlantic.provinces.Add(3913); //Maryland northAmericaUSMidWestMidAtlantic.provinces.Add(3906); //Ohio northAmericaUSMidWestMidAtlantic.provinces.Add(3910); //West Virginia northAmericaUSMidWestMidAtlantic.provinces.Add(3908); //Virginia northAmericaUSMidWestMidAtlantic.provinces.Add(3904); //Kentucky northAmericaUSMidWestMidAtlantic.provinces.Add(3918); //Michigan northAmericaUSMidWestMidAtlantic.provinces.Add(3903); //Indiana northAmericaUSMidWestMidAtlantic.provinces.Add(3902); //Illinois northAmericaUSMidWestMidAtlantic.provinces.Add(3909); //Wisconsin northAmericaUSMidWestMidAtlantic.provinces.Add(3870); //Minnesota northAmericaUSMidWestMidAtlantic.provinces.Add(3885); //Iowa northAmericaUSMidWestMidAtlantic.provinces.Add(3887); //Missouri //Landmarks northAmericaUSMidWestMidAtlantic.landmarks.Add("Statue Of Liberty"); northAmericaUSMidWestMidAtlantic.landmarks.Add("Washington Monument"); northAmericaUSMidWestMidAtlantic.landmarks.Add("Lincoln Memorial"); northAmericaUSMidWestMidAtlantic.landmarks.Add("Gateway Arch"); northAmericaUSMidWestMidAtlantic.landmarks.Add("CN Tower"); northAmericaUSMidWestMidAtlantic.landmarks.Add("Parliament Hill"); #endregion #region Create US South East TouristRegion northAmericaUSSouthEast = new TouristRegion(); touristRegions.Add(northAmericaUSSouthEast); northAmericaUSSouthEast.regionName = "North America: US South East"; //Provinces northAmericaUSSouthEast.provinces.Add(3911); //Delaware northAmericaUSSouthEast.provinces.Add(3913); //Maryland northAmericaUSSouthEast.provinces.Add(3910); //West Virginia northAmericaUSSouthEast.provinces.Add(3908); //Virginia northAmericaUSSouthEast.provinces.Add(3904); //Kentucky northAmericaUSSouthEast.provinces.Add(3905); //North Carolina northAmericaUSSouthEast.provinces.Add(3907); //Tennessee northAmericaUSSouthEast.provinces.Add(3901); //South Carolina northAmericaUSSouthEast.provinces.Add(3899); //Georgia northAmericaUSSouthEast.provinces.Add(3897); //Alabama northAmericaUSSouthEast.provinces.Add(3898); //Florida northAmericaUSSouthEast.provinces.Add(3900); //Mississippi northAmericaUSSouthEast.provinces.Add(3891); //Louisiana northAmericaUSSouthEast.provinces.Add(3884); //Arkansas northAmericaUSSouthEast.provinces.Add(3892); //Texas northAmericaUSSouthEast.provinces.Add(3889); //Oklahoma //Landmarks northAmericaUSSouthEast.landmarks.Add("Washington Monument"); northAmericaUSSouthEast.landmarks.Add("Lincoln Memorial"); #endregion #region Create US South West TouristRegion northAmericaSouthWest = new TouristRegion(); touristRegions.Add(northAmericaSouthWest); northAmericaSouthWest.regionName = "North America: South West"; //Provinces northAmericaSouthWest.provinces.Add(3892); //Texas northAmericaSouthWest.provinces.Add(3889); //Oklahoma northAmericaSouthWest.provinces.Add(3886); //Kansas northAmericaSouthWest.provinces.Add(3878); //Colorado northAmericaSouthWest.provinces.Add(3880); //New Mexico northAmericaSouthWest.provinces.Add(3876); //Arizona northAmericaSouthWest.provinces.Add(3882); //Utah northAmericaSouthWest.provinces.Add(3879); //Nevada northAmericaSouthWest.provinces.Add(3877); //California //Landmarks northAmericaSouthWest.landmarks.Add("Hoover Dam"); northAmericaSouthWest.landmarks.Add("Golden Gate Bridge"); northAmericaSouthWest.landmarks.Add("Mesa Verde National Park"); //Countries northAmericaSouthWest.countries.Add(165); //Mexico #endregion #region Create North West US TouristRegion northAmericaNorthWestUS = new TouristRegion(); touristRegions.Add(northAmericaNorthWestUS); northAmericaNorthWestUS.regionName = "North America: North West US"; //Provinces northAmericaNorthWestUS.provinces.Add(3881); //Oregon northAmericaNorthWestUS.provinces.Add(3875); //Washington northAmericaNorthWestUS.provinces.Add(486); //British Columbia northAmericaNorthWestUS.provinces.Add(3874); //Idaho northAmericaNorthWestUS.provinces.Add(3883); //Wyoming northAmericaNorthWestUS.provinces.Add(3871); //Montana northAmericaNorthWestUS.provinces.Add(485); //Alberta northAmericaNorthWestUS.provinces.Add(484); //Saskatchewan northAmericaNorthWestUS.provinces.Add(3872); //North Dakota northAmericaNorthWestUS.provinces.Add(3890); //South Dakota northAmericaNorthWestUS.provinces.Add(3888); //Nebraska //Landmarks northAmericaNorthWestUS.landmarks.Add("Mount Rushmore"); northAmericaNorthWestUS.landmarks.Add("Space Needle"); #endregion #region Create North Western North America TouristRegion northAmericaNorthWest = new TouristRegion(); touristRegions.Add(northAmericaNorthWest); northAmericaNorthWest.regionName = "North America: North West"; //Provinces northAmericaNorthWest.provinces.Add(3875); //Washington northAmericaNorthWest.provinces.Add(486); //British Columbia northAmericaNorthWest.provinces.Add(485); //Alberta northAmericaNorthWest.provinces.Add(484); //Saskatchewan northAmericaNorthWest.provinces.Add(487); //Nunavut northAmericaNorthWest.provinces.Add(484); //Saskatchewan northAmericaNorthWest.provinces.Add(483); //Manitoba northAmericaNorthWest.provinces.Add(488); //Northwest Territories northAmericaNorthWest.provinces.Add(489); //Yukon northAmericaNorthWest.provinces.Add(3919); //Alaska //Landmarks northAmericaNorthWestUS.landmarks.Add("Space Needle"); #endregion #region Create Central America TouristRegion northAmericaCentralAmerica = new TouristRegion(); touristRegions.Add(northAmericaCentralAmerica); northAmericaCentralAmerica.regionName = "North America: Central America"; //Provinces northAmericaCentralAmerica.provinces.Add(3892); //Texas //Landmarks northAmericaCentralAmerica.landmarks.Add("Castillo of Chichen Itza"); northAmericaCentralAmerica.landmarks.Add("Ruins of Tikal"); northAmericaCentralAmerica.landmarks.Add("Angel of Mexican Independence"); northAmericaCentralAmerica.landmarks.Add("Panama Canal"); //Contries northAmericaCentralAmerica.countries.Add(165); //Mexico northAmericaCentralAmerica.countries.Add(21); //Belize northAmericaCentralAmerica.countries.Add(58); //Guatemala northAmericaCentralAmerica.countries.Add(23); //El Salvador northAmericaCentralAmerica.countries.Add(69); //Honduras northAmericaCentralAmerica.countries.Add(70); //Nicaragua northAmericaCentralAmerica.countries.Add(48); //Costa Rica northAmericaCentralAmerica.countries.Add(54); //Panama #endregion #region Set Tourist Region Neighbours //North East Region northAmericaNorthEast.neighbouringRegions.Add(northAmericaUSMidWestMidAtlantic); northAmericaNorthEast.neighbouringRegions.Add(northAmericaNorthWestUS); northAmericaNorthEast.neighbouringRegions.Add(northAmericaNorthWest); //US Mid West Region northAmericaUSMidWestMidAtlantic.neighbouringRegions.Add(northAmericaNorthEast); northAmericaUSMidWestMidAtlantic.neighbouringRegions.Add(northAmericaUSSouthEast); northAmericaUSMidWestMidAtlantic.neighbouringRegions.Add(northAmericaSouthWest); northAmericaUSMidWestMidAtlantic.neighbouringRegions.Add(northAmericaNorthWestUS); northAmericaUSMidWestMidAtlantic.neighbouringRegions.Add(northAmericaNorthWest); //US South East Region northAmericaUSSouthEast.neighbouringRegions.Add(northAmericaUSMidWestMidAtlantic); northAmericaUSSouthEast.neighbouringRegions.Add(northAmericaSouthWest); northAmericaUSSouthEast.neighbouringRegions.Add(northAmericaCentralAmerica); //US South West Region northAmericaSouthWest.neighbouringRegions.Add(northAmericaUSSouthEast); northAmericaSouthWest.neighbouringRegions.Add(northAmericaUSMidWestMidAtlantic); northAmericaSouthWest.neighbouringRegions.Add(northAmericaNorthWestUS); northAmericaSouthWest.neighbouringRegions.Add(northAmericaCentralAmerica); //US North West Region northAmericaNorthWestUS.neighbouringRegions.Add(northAmericaSouthWest); northAmericaNorthWestUS.neighbouringRegions.Add(northAmericaUSMidWestMidAtlantic); northAmericaNorthWestUS.neighbouringRegions.Add(northAmericaNorthEast); northAmericaNorthWestUS.neighbouringRegions.Add(northAmericaNorthWest); //North West Region northAmericaNorthWest.neighbouringRegions.Add(northAmericaNorthWestUS); northAmericaNorthWest.neighbouringRegions.Add(northAmericaNorthEast); northAmericaNorthWest.neighbouringRegions.Add(northAmericaUSMidWestMidAtlantic); //Central America Region northAmericaCentralAmerica.neighbouringRegions.Add(northAmericaSouthWest); northAmericaCentralAmerica.neighbouringRegions.Add(northAmericaUSSouthEast); #endregion CurrentRegion = northAmericaUSSouthEast; }