示例#1
0
        private static DestinationDetails generateDestinationDetails(DestinationDefinition destinationDefinition)
        {
            //currently only allowing planets with normal atmospheric environment to have a governing race
            if (destinationDefinition.environmentState == DestinationDefinition.EnvironmentState.NORMAL)
            {
                //load the destination profile into a text object
                TextAsset destinationProfileJson = Resources.Load <TextAsset>(destinationsProfileFilePath);

                //deserialize the destination profile json into an object
                DestinationProfile destinationProfile = JsonConvert.DeserializeObject <DestinationProfile>(destinationProfileJson.text);

                //check if destination is occupied
                if (((WeightedBool)WeightedValueSelector.selectValue(destinationProfile.occupyingRaceWeights)).value)
                {
                    //randomly select an environment type for the destination
                    RaceDefinitions.Race race = ((WeightedRace)WeightedValueSelector.selectValue(destinationProfile.raceWeights)).value;

                    return(new DestinationDetails(destinationDefinition, race));
                }
            }

            //new destination without occupying race
            return(new DestinationDetails(destinationDefinition, RaceDefinitions.Race.NONE));
        }
 public DestinationDetails(DestinationDefinition destinationDefinition, RaceDefinitions.Race governingRace)
 {
     this.destinationDefinition = destinationDefinition;
     this.governingRace         = governingRace;
 }