void Start() { w.seed = GameObject.Find("transfer").GetComponent <menu>().seed; w.momOff = GameObject.Find("transfer").GetComponent <menu>().rWM; w.seed = w.seed < 0 ? Random.Range(0, 9999999) : w.seed; Random.InitState(w.seed); file = Path.Combine(Application.dataPath, Generate.AddTimeStamp(w.seed + "_SimF") + ".csv"); file2 = Path.Combine(Application.dataPath, Generate.AddTimeStamp(w.seed + "_SimS") + ".csv"); fD = Path.Combine(Application.dataPath, Generate.AddTimeStamp(w.seed + "_F_Hist") + ".csv"); p = GameObject.Find("person"); v = GameObject.Find("friend"); bd = GameObject.Find("bus driver"); sun = GameObject.Find("Sun").GetComponent <Transform>(); roadAni = GameObject.Find("rLoop"); clockImg = GameObject.Find("clockImg").GetComponent <Image>(); clockTick = GameObject.Find("cTick").GetComponent <RectTransform>(); dayTxt = GameObject.Find("dTxt").GetComponent <Text>(); friendsTxt = GameObject.Find("fTxt").GetComponent <Text>(); tData = GameObject.Find("tData").GetComponent <Text>(); show = GameObject.Find("show").GetComponent <Image>(); show.transform.localPosition = Vector3.down * 650; // for (int i = 0; i < busPass.Length; i++) { busPass[i] = GameObject.Find("pass" + i); } // for (int i = 0; i < parkFolk.Length; i++) { parkFolk[i] = GameObject.Find("parkFolk" + i); } SetAppearance(bd, w.skinType[5], Color.gray, Color.blue, Color.black, Vector3.forward * 60 + Vector3.up * 60); AddAsFriend(new Friend("Mom", 4, 3, myCompat + w.momOff, w.skinType[0], new Color32(98, 0, 0, 255), Color.yellow, Color.green, Vector3.forward * 80)); SetAppearance(v, friends[0].skin, friends[0].hair, friends[0].shirt, friends[0].pants, friends[0].hairStyle); f = friends[0]; busStartPos = new Vector3[8]; parkStartPos = new Vector3[4]; // for (int i = 0; i < busStartPos.Length; i++) { busStartPos[i] = busPass[i].transform.position; } // for (int i = 0; i < parkStartPos.Length; i++) { parkStartPos[i] = parkFolk[i].transform.position; } // if (!File.Exists(file) && fullData) { StreamWriter sw = new StreamWriter(file); sw.Write(w.seed + "\nDay,Computer Science,Biology,Astrophysics,Visual Arts,Marketing\n"); sw.Close(); } if (!File.Exists(file2) && !fullData) { StreamWriter sw = new StreamWriter(file2); sw.Write(w.seed + "\nDay,Computer Science,Biology,Astrophysics,Visual Arts,Marketing\n"); sw.Close(); } StartCoroutine(IncreaseTime()); }
IEnumerator IncreaseTime() { time++; clockImg.color = hour < 19 && hour > 7 ? new Color32(255, 227, 51, 255) : new Color32(0, 17, 163, 255); sun.transform.eulerAngles = hour < 19 && hour > 7 ? timeDay : timeNight; bool newDay = (time % 24 == 1); float dice = Random.value; if (newDay) { dayTh = Random.Range(0, majors.Length); } dice = Random.value; float where = (local == 0) ? .8f : .7f; int store = local; Friend busPartner; if (dice > where) { local = Random.Range(0, w.location.Length); // if (store != 1 && local == 1) { GenerateBusStrangers(); // for (int i = 0; i < busSeat.Length; i++) { busSeat[i] = Random.Range(0, 2); busPass[i].transform.position = busStartPos[i] + (Vector3.down * busSeat[i] * 100); SetAppearance(busPass[i], busPeople[i].skin, busPeople[i].hair, busPeople[i].shirt, busPeople[i].pants, busPeople[i].hairStyle); } busPartner = (busSeat[spot] == 0) ? busPeople[spot] : null; if (busPartner != null) { float dice2 = Random.value; if (dice2 > friProb) { AddAsFriend(busPartner); } } f = busPartner; } else if (store != 2 && local == 2) { GenerateParkStrangers(); // for (int i = 0; i < parkSeat.Length; i++) { parkSeat[i] = Random.Range(0, 2); parkFolk[i].transform.position = parkStartPos[i] + (Vector3.down * parkSeat[i] * 100); SetAppearance(parkFolk[i], parkPeople[i].skin, parkPeople[i].hair, parkPeople[i].shirt, parkPeople[i].pants, parkPeople[i].hairStyle); } } else if (store != 3 && local == 3) { ChooseFriend(); } } if (local != 1) { spot = Random.Range(0, w.location[local].spot.Length); } if (local == 0) { f1 = null; f2 = null; if (spot == 5) { ChooseFriend(); v.transform.position = new Vector3(-14.05f, 0, -3.06f); v.transform.eulerAngles = Vector3.up * 270; if (f != friends[0]) { if (dice > .98f) { quickEasyLocation += day + "," + f.name + "," + LocalConvert(local) + "," + f.relationship + ",REM\n"; f.CancelFriendship(); AddToNotification(f); friends.Remove(f); } } } else { v.transform.position = Vector3.down * 10000; } } else if (local == 2) { if (spot == 0) { f = (parkSeat[0] == 0) ? parkPeople[0] : null; f1 = (parkSeat[1] == 1) ? parkPeople[1] : null; f2 = (parkSeat[2] == 2) ? parkPeople[2] : null; float[] dices = new float[3]; for (int i = 0; i < dices.Length; i++) { dices[i] = Random.value; if (dices[i] > friProb) { AddAsFriend(parkPeople[i]); } } } else if (spot == 2) { f = (parkSeat[parkSeat.Length - 1] == 0) ? parkPeople[parkPeople.Length - 1] : null; float dice2 = Random.value; if (dice2 > friProb) { AddAsFriend(parkPeople[parkPeople.Length - 1]); } } else { f = null; f1 = null; f2 = null; } } else if (local == 3) { f1 = null; f2 = null; if (spot == 0) { v.transform.position = new Vector3(195.17f, 1.34f, -205.18f); v.transform.eulerAngles = Vector3.up * 180; } else if (spot == 1) { v.transform.position = new Vector3(191.01f, 0.85f, -192.45f); v.transform.eulerAngles = Vector3.up * 0; } else { v.transform.position = Vector3.down * 10000; } } else { f1 = null; f2 = null; } addInterest(); clockTick.eulerAngles = new Vector3(0, 180, hour * 360 / 12); dayTxt.text = "Day:" + day; friendsTxt.text = "Friends:" + numbFriends; p.transform.position = w.location[local].spot[spot].pos; p.transform.eulerAngles = w.location[local].spot[spot].rot; Camera.main.transform.position = w.ReturnCanPos(local); Camera.main.orthographicSize = w.ReturnCamSize(local); tData.text = "Major Interests (" + secPerHour + ")SPH" + "\nSeed: " + w.seed + " - " + w.momOff + "\n-----" + "\nCpu Science: " + cpuSci + "\nBiology: " + bio + "\nAstrophysics: " + astrophys + "\nVis Arts: " + visArts + "\nMarketing: " + marketing ; w.fM.Add(friends); // if (fullData) { WriteData(true, string.Format("{0},{1},{2},{3},{4},{5},\n", day, (float)cpuSci / 1000, (float)bio / 1000, (float)astrophys / 1000, (float)visArts / 1000, (float)marketing / 1000)); } else if (!fullData & newDay) { WriteData(false, string.Format("{0},{1},{2},{3},{4},{5},\n", day, (float)cpuSci / 1000, (float)bio / 1000, (float)astrophys / 1000, (float)visArts / 1000, (float)marketing / 1000)); } // if (day < year) { yield return(new WaitForSeconds(secPerHour)); StartCoroutine(IncreaseTime()); } else { print("Clarissa declared " + mNames[ReturnHighest(majors)] + " as her major! This was probably due to all the time that she spent with "); StreamWriter sW = new StreamWriter(Path.Combine(Application.dataPath, Generate.AddTimeStamp("DayNameLocal") + ".csv")); sW.Write(quickEasyLocation); sW.Close(); // if (reRun) { Application.LoadLevel(Application.loadedLevel); } } }