private void loadArea(int nArea) //this is a f****n mess, just dont even bother { GameObject wc = GameObject.FindGameObjectWithTag("WorldControl"); Transform[] objs = new Transform[wc.transform.childCount]; WorldCtrl ctrl = wc.GetComponent <WorldCtrl>(); int numOfFog = ctrl.fog.Length - 1; int size = 0; for (int x = 0; x < wc.transform.childCount; x++) { objs[x] = wc.transform.GetChild(x); } for (int x = 0; x < wc.transform.childCount; x++) { if (objs[x].transform.tag == "Fog") { size++; } } GameObject[] fog = new GameObject[size]; for (int i = 0; i <= size - 1; i++) { fog[i] = objs[i].gameObject; } GameObject f1; GameObject f2; if (fog[0].GetComponent <Fog>().areaNum == nArea) { f1 = fog[0]; } else { f1 = fog[1]; } if (fog[1].GetComponent <Fog>().areaNum == nArea) { f2 = fog[0]; } else { f2 = fog[1]; } f1.GetComponent <Fog>().active = false; //print(f1.name + " " + f1.GetComponent<Fog>().active); f2.GetComponent <Fog>().active = true; //print(f2.name + " " + f2.GetComponent<Fog>().active); transform.position = f1.transform.GetChild(1).transform.position; areaNum = f2.GetComponent <Fog>().areaNum; }
void Start() { worldCtrl = GameObject.Find("WorldCtrl").GetComponent <WorldCtrl>(); }