public MissionData CreateMission() { //Type,Min Amount of Agents,Max Amount of Agents,Min Time Limit (Minutes),Max Time Limit (Minutes),Min Monetary Reward,Max Monetary Reward int typeSelectedIndex = Random.Range(1, missionWeightings.subValueCount); //Parse the mission details and create random missions from them. string type = missionWeightings.Get("Type", typeSelectedIndex); int amountOfAgents = Random.Range(int.Parse(missionWeightings.Get("Min Amount of Agents", typeSelectedIndex)), int.Parse(missionWeightings.Get("Max Amount of Agents", typeSelectedIndex))); float timeLimit = Random.Range(int.Parse(missionWeightings.Get("Min Time Limit (Minutes)", typeSelectedIndex)), int.Parse(missionWeightings.Get("Max Time Limit (Minutes)", typeSelectedIndex))) * 1000; int monetaryReward = Random.Range(int.Parse(missionWeightings.Get("Min Monetary Reward", typeSelectedIndex)), int.Parse(missionWeightings.Get("Max Monetary Reward", typeSelectedIndex))); Continent location = areaCreator.areas[Random.Range(0, areaCreator.areas.Length)].GetComponent <Continent>(); int[] skillValues = new int[11]; //Randomly assign skill requirements and then base them on the amount of agents. for (int i = 0; i < skillValues.Length; i++) { skillValues[i] = Random.Range(1, 100) * amountOfAgents; } SkillsHolder skills = new SkillsHolder(skillValues[0], skillValues[1], skillValues[2], skillValues[3], skillValues[4], skillValues[5], skillValues[6], skillValues[7], skillValues[8], skillValues[9], skillValues[10]); //Get a mission name based on the created details. string missionName = PopulateMissionNameWithRandomValues(missionNames.Get(type, Random.Range(1, missionNames.subValueCount))); //Return a new mission data object. return(new MissionData(missionName, skills, monetaryReward, location, type, amountOfAgents, timeLimit, "Client Name")); }
private string PopulateMissionNameWithRandomValues(string missionName) { string currentKey = ""; bool addingToKey = false; //Loop through all characters looking for keys ([KEY]). for (int i = 0; i < missionName.Length; i++) { if (missionName[i] == '[') { addingToKey = true; } else if (missionName[i] == ']') { string currentKeyCSV = (Resources.Load(currentKey) as TextAsset).ToString(); VeCSV possibleValues = new VeCSV(currentKeyCSV, VeCSV.HeaderDirection.Horizontal); missionName = missionName.Replace("[" + currentKey + "]", possibleValues.Get(0, Random.Range(0, possibleValues.subValueCount))); addingToKey = false; currentKey = ""; } else if (addingToKey) { currentKey += missionName[i]; } } return(missionName); }
public void ReadInGunData(TextAsset file, bool append) { VeCSV gunCSV = new VeCSV(file.text, VeCSV.HeaderDirection.Horizontal); //Initalize gun array. allGuns = new Gun[gunCSV.subValueCount - 1]; //Pull out the data using the parsed indexes. for (int i = 1; i < gunCSV.subValueCount; i++) { string name = gunCSV.Get("Name", i); string damage = gunCSV.Get("Damage", i); string accuracy = gunCSV.Get("Accuracy", i); string range = gunCSV.Get("Range (m)", i); string clipSize = gunCSV.Get("Clip Size", i); string fireRate = gunCSV.Get("Fire Rate (RPM)", i); string reloadTime = gunCSV.Get("Reload Time", i); string weight = gunCSV.Get("Weight (g)", i); string size = gunCSV.Get("Size", i); string price = gunCSV.Get("Price", i); string fearFactor = gunCSV.Get("Fear Factor", i); string noise = gunCSV.Get("Noise", i); string concealable = gunCSV.Get("Concealable", i); string moraleBoost = gunCSV.Get("Morale Boost", i); string rarity = gunCSV.Get("Rarity", i); string region = gunCSV.Get("Region of Origin", i); string storage = gunCSV.Get("Storage Units", i); allGuns[i - 1] = new Gun(name, int.Parse(damage), int.Parse(accuracy), int.Parse(range), int.Parse(clipSize), float.Parse(fireRate), float.Parse(reloadTime), float.Parse(weight), size, float.Parse(price), int.Parse(fearFactor), int.Parse(noise), BoolParse(concealable), int.Parse(moraleBoost), float.Parse(rarity), region, 0, int.Parse(storage)); } }