IEnumerator WaitForRetrieve(WWW www) { yield return(www); // check for errors if (www.error == null) { int cvCount = TransferPanel.transform.childCount; int index = 1; string[] linesInFile = www.text.Split('\n'); foreach (string line in linesInFile) { if (line != "" && index < cvCount) { Debug.Log(line); Transform cv = TransferPanel.transform.GetChild(index); CVscript cvScript = cv.gameObject.GetComponent <CVscript>(); string[] data = line.Split(':'); cvScript.injectGenerationData(data[0], data[3], data[1], data[2], data[4], int.Parse(data[5]), int.Parse(data[6])); cv.position = new Vector3(cv.position.x, cv.position.y, 0); index++; } } } else { Debug.Log("WWW Error: " + www.error); } }
public void updateDiversity() { diversity = 0; CVscript cv = new CVscript(); foreach (Stats stat in charStats) { if (diversities[stat.gender] == 0) { diversities[stat.gender] += 1; diversity += 1; } } foreach (Stats stat in charStats) { if (diversities[stat.ethnicity] == 0) { diversities[stat.ethnicity] += 1; diversity += 1; } } }
private void setDiversities() { CVscript cv = new CVscript(); foreach (string gender in cv.genders) { diversities.Add(gender, 0); } foreach (string country in cv.ethnicites) { diversities.Add(country, 0); } }
public void transferFromHost() { TransferPanel = GameObject.Find("TransferPanel"); int cvCount = TransferPanel.transform.childCount; for (int x = 1; x < cvCount; x++) { Transform cv = TransferPanel.transform.GetChild(x); CVscript cvScript = cv.gameObject.GetComponent <CVscript>(); cvScript.injectGenerationData("loading...", "loading...", "loading...", "loading...", "loading...", -1, -1); cv.position = new Vector3(cv.position.x, cv.position.y, -200); } string url = "https://kerwinsuniscoolafamirite.000webhostapp.com/retrieveTransfer.php"; WWWForm form = new WWWForm(); WWW www = new WWW(url, form); StartCoroutine(WaitForRetrieve(www)); }
public void createProceduralNPC(string name, string gender, string age, string ethnicity, string position, int skill, int teamwork) { hireBoxPrefab = GameObject.Find("HirePanel"); GameObject randomNPC = Instantiate(Resources.Load("CharacterGeneration/CustomCharacter"), new Vector3(1, 0, 1), Quaternion.identity) as GameObject; //Stats statScript = randomNPC.GetComponent<Stats>(); string bodyName = ""; string hairName = ""; // Load the body switch (Random.Range(1, 3)) { case 1: bodyName = "body_pale"; break; case 2: bodyName = "body_dark"; break; } // Load the hair if (gender == "Male") { switch (Random.Range(1, 3)) { case 1: hairName = "hair_anime_white"; break; case 2: hairName = "hair_bob_white"; break; } } else { switch (Random.Range(1, 2)) { case 1: hairName = "hair_ponytail_white"; break; } } Color hairColor = new Color(Random.value, Random.value, Random.value, 1.0f); // Setup the shirt Color shirtColor = new Color(Random.value, Random.value, Random.value, 1.0f); // Setup the pants Color pantsColor = new Color(Random.value, Random.value, Random.value, 1.0f); // Set data into character stats Stats statsScript = randomNPC.GetComponent <Stats>(); statsScript.name = name; statsScript.pantsColor = pantsColor; statsScript.shirtColor = shirtColor; statsScript.hairColor = hairColor; statsScript.bodyName = bodyName; statsScript.hairName = hairName; statsScript.gender = gender; statsScript.ethnicity = ethnicity; statsScript.age = age; statsScript.position = position; statsScript.teamwork = teamwork; statsScript.skill = skill; CVscript cv = new CVscript(); statsScript.genderSeed = statsScript.getGenderSeed(); statsScript.ageSeed = statsScript.getAgeSeed(); statsScript.ethnicitySeed = statsScript.getEthnicitySeed(cv.ethnicites); charStats.Add(statsScript); setHappinessIncrement(); updateDiversity(); setSkillTeamwork(); randomNPC.name = name; randomNPC.transform.Find("Opperations Panel/Panel/Text").GetComponent <Text>().text = "Name: " + name + "\n" + "Gender " + gender + "\n" + "Age: " + age + "\n" + "Ethnicity: " + ethnicity + "\n" + "Position: " + position + "\n" + "Skill: " + skill.ToString() + "\n" + "Teamwork: " + teamwork.ToString() + "\n"; NPCList.Add(randomNPC); employeeNames.Add(name); employeeRelationships.addNode(statsScript); }