//temporarily returning weapon list. Need to fix when implementing other drop types public WeaponDefinition[] generateLoot(string enemyId) { //check the enemy id matches a key in the enemy definitions if (!enemyDefinitions.definitions.ContainsKey(enemyId)) { throw new System.Exception("Missing enemy id."); } //retrieve the enemy details EnemyDefinition definition = enemyDefinitions.definitions[enemyId]; //create an array to store the loot drops WeaponDefinition[] generatedDefinitions = new WeaponDefinition[definition.lootDrops]; for (int i = 0; i < definition.lootDrops; i++) { //randomly select the loot drop type such as weapon, armour, resource etc. string dropType = ((WeightedString)WeightedValueSelector.selectValue(definition.lootDropTypes)).value; switch (dropType) { case "WEAPON": //using the selected loot drop type, randomly select the inner group of loot items such as assault_rifles WeaponLootDefinition weaponLootDefinition = ((WeaponLootDefinition)WeightedValueSelector.selectValue(definition.weaponWeights)); //randomly select the rarity type of the loot drop RarityObject.Rarity rarity = ((WeightedRarityObject)WeightedValueSelector.selectValue(weaponLootDefinition.rarityWeights)).value; //using the randomly selected information retrieve a weapon definition and add to loot list generatedDefinitions[i] = WeaponUtil.getWeapon(weaponLootDefinition.name, rarity); break; case "ARMOUR": break; case "INTEL": break; case "RESOURCE": break; case "NONE": break; } } //return the list of awarded loot types return(generatedDefinitions); }
public override int[,] generateMap(int width, int height) { int[,] tileMapping = new int[width, height]; for (int x = 0; x < width; x++) { bool canPlace = Random.Range(0, 100) < placementChance ? true : false; if (!canPlace) { continue; } //int y = (int)Mathf.Floor(Random.Range(0, height)); int y = ((WeightedInteger)WeightedValueSelector.selectValue(weightedValues)).getValue(); for (; y < height; y++) { tileMapping[x, y] = 1; } } return(tileMapping); }
private static string generateRandomDesignation() { string designation = "P"; System.Random random = new System.Random(); //generates 2 random characters for (int i = 0; i < 2; i++) { designation += ((WeightedString)WeightedValueSelector.selectValue(designationCharacters)).value; } //adds hyphon separator designation += "-"; //generates 3 random characters for (int i = 0; i < 3; i++) { designation += ((WeightedString)WeightedValueSelector.selectValue(designationCharacters)).value; } return(designation); }
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)); }
private static DestinationDefinition generateDestinationDefinition(string stringifiedAddress) { //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); //randomly select an environment type for the destination DestinationDefinition.EnvironmentState environmentState = ((WeightedEnvironmentState)WeightedValueSelector.selectValue(destinationProfile.environmentStateWeights)).value; return(new DestinationDefinition(stringifiedAddress, generateRandomDesignation(), environmentState)); }