IEnumerator AddGround() { SequenceGround qGround = queneGround[0]; queneGround.RemoveRange(0, 1); qGround.groundObj.transform.position = posGroundLast; posGroundLast.z += nextPosGround; queneGround.Add(qGround); StartCoroutine(WaitCheckGround()); yield return(0); }
IEnumerator InitializeGround() { int i = 0; while (i < amountGroundSpawn) { GameObject go = (GameObject)Instantiate(ground_Pref, posStart, Quaternion.identity); go.name = "Ground[" + i + "]"; ground_Obj.Add(go); SequenceGround qGround = new SequenceGround(); qGround.groundObj = ground_Obj[i]; queneGround.Add(qGround); i++; int startZ = -18; SpawnLeft = new Vector3[18]; SpawnRight = new Vector3[18]; SpawnMiddle = new Vector3[18]; for (int j = 0; j < SpawnLeft.Length; j++) { SpawnLeft[j] = new Vector3(-1.6f, 0, startZ); SpawnRight[j] = new Vector3(1.6f, 0, startZ); SpawnMiddle[j] = new Vector3(0, 0, startZ); GameObject item; if (Random.Range(0, 100) > 50) { randomItem = Random.Range(0, item_Pref.Count); if (checkRisk(randomItem)) { item = (GameObject) Instantiate(item_Pref[randomItem], SpawnLeft[j], item_Pref[randomItem].transform.rotation); item.name = "Item[" + j + "]-TYPE" + randomItem + "-Left"; item.transform.parent = go.transform.FindChild("WayItems"); item.transform.localPosition = SpawnLeft[j]; } } if (Random.Range(0, 100) > 50) { randomItem = Random.Range(0, item_Pref.Count); if (checkRisk(randomItem)) { item = (GameObject) Instantiate(item_Pref[randomItem], SpawnRight[j], item_Pref[randomItem].transform.rotation); item.name = "Item[" + j + "]-TYPE" + randomItem + "-Right"; item.transform.parent = go.transform.FindChild("WayItems"); item.transform.localPosition = SpawnRight[j]; } } if (Random.Range(0, 100) > 50) { randomItem = Random.Range(0, item_Pref.Count); if (checkRisk(randomItem)) { item = (GameObject) Instantiate(item_Pref[randomItem], SpawnMiddle[j], item_Pref[randomItem].transform.rotation); item.name = "Item[" + j + "]-TYPE" + randomItem + "-Middle"; item.transform.parent = go.transform.FindChild("WayItems"); item.transform.localPosition = SpawnMiddle[j]; } } startZ += 2; } yield return(0); } spawnObj_Obj = (GameObject)Instantiate(spawnObj_Pref, posStart, Quaternion.identity); checkSpawn = spawnObj_Obj.GetComponentInChildren <CheckSpawn>(); checkSpawn.headParent = spawnObj_Obj; StartCoroutine(SetStarter()); yield return(0); }