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); }
// Use this for initialization void Start() { //Find objects in scene. gameManager = GameObject.FindObjectOfType <GameManager>(); areaCreator = GameObject.FindObjectOfType <AreaCreator>(); GameObject dynamicObjectHolder; if (GameObject.Find("Dynamic Object Holder") != null) { dynamicObjectHolder = GameObject.Find("Dynamic Object Holder"); } else { dynamicObjectHolder = new GameObject("Dynamic Object Holder"); } missionObjectHolder = new GameObject("Mission Object Holder"); missionObjectHolder.transform.parent = dynamicObjectHolder.transform; //Load in the mission weightings. string missionWeightingsCSV = (Resources.Load("Mission Weightings") as TextAsset).ToString(); missionWeightings = new VeCSV(missionWeightingsCSV, VeCSV.HeaderDirection.Horizontal); //Load in the possible mission names based on mission type. string missionNamesCSV = (Resources.Load("Mission Names") as TextAsset).ToString(); missionNames = new VeCSV(missionNamesCSV, VeCSV.HeaderDirection.Horizontal); }
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)); } }