IEnumerator InitBuilding() { //75% int i = 0; while (i < building_Pref.Count) { int j = 0; while (j < amountBuildingSpawn[i]) { GameObject go = (GameObject)Instantiate(building_Pref[i], posStart, Quaternion.identity); go.name = "Building[" + i + "][" + j + "]"; building_Obj.Add(go); Building building = go.GetComponent <Building>(); building.buildIndex = i; building_Script.Add(building); j++; yield return(0); } i++; yield return(0); } loadingPercent = 30; i = 0; while (i < item_Pref.Count) { int j = 0; item_Type_Script.Add(new Item_Type()); amount_Item_Pattern_Left.Add(0); amount_Item_Pattern_Middle.Add(0); amount_Item_Pattern_Right.Add(0); while (j < amountItemSpawn[i]) { GameObject go = (GameObject)Instantiate(item_Pref[i], posStart, Quaternion.identity); go.name = "Item[" + i + "][" + j + "]"; item_Obj.Add(go); item_Type_Script[i].itemList.Add(go.GetComponent <Item>()); j++; yield return(0); } i++; yield return(0); } i = 0; loadingPercent = 70; while (i < amountFloorSpawn) { GameObject go = (GameObject)Instantiate(floor_Pref, posStart, Quaternion.identity); go.name = "Floor[" + i + "]"; floor_Obj.Add(go); floor_Slot.Add(new Floor()); floor_Slot[i].floor_Slot_Left = new bool[defaultPosBuilding_Left.Count]; floor_Slot[i].floor_Slot_Right = new bool[defaultPosBuilding_Right.Count]; floor_item_Slot.Add(new FloorItemSlot()); floor_item_Slot[i].floor_Slot_Left = new bool[defaultPosItem_Left.Count]; floor_item_Slot[i].floor_Slot_Middle = new bool[defaultPosItem_Middle.Count]; floor_item_Slot[i].floor_Slot_Right = new bool[defaultPosItem_Right.Count]; QueueFloor qFloor = new QueueFloor(); qFloor.floorObj = floor_Obj[i]; qFloor.floorClass = floor_Slot[i]; qFloor.floorItemSlotClass = floor_item_Slot[i]; queneFloor.Add(qFloor); i++; yield return(0); } loadingPercent = 100; spawnObj_Obj = (GameObject)Instantiate(spawnObj_Pref, posStart, Quaternion.identity); colSpawnCheck = spawnObj_Obj.GetComponentInChildren <ColliderSpawnCheck>(); colSpawnCheck.headParent = spawnObj_Obj; StartCoroutine(SetPosStarter()); }
IEnumerator InitBuilding() { //75% int i = 0; ItemManager.Instance.ClearAll(); GameObject builds = new GameObject(); builds.name = "Buildings"; while (i < building_Pref.Count) { int j = 0; while (j < amountBuildingSpawn[i]) { if (building_Pref [i] != null) { GameObject go = (GameObject)Instantiate(building_Pref [i], posStart, Quaternion.identity); go.name = "Building[" + i + "][" + j + "]"; go.transform.parent = builds.transform; building_Obj.Add(go); Building building = go.GetComponent <Building> (); building.buildIndex = i; building_Script.Add(building); } j++; yield return(0); } i++; yield return(0); } loadingPercent = 30; i = 0; GameObject items = new GameObject(); items.name = "Items"; while (i < item_Pref.Count) { int j = 0; item_Type_Script.Add(new Item_Type()); amount_Item_Pattern_Left.Add(0); amount_Item_Pattern_SubLeft.Add(0); amount_Item_Pattern_Middle.Add(0); amount_Item_Pattern_SubRight.Add(0); amount_Item_Pattern_Right.Add(0); while (j < amountItemSpawn[i]) { GameObject go = (GameObject)Instantiate(item_Pref[i], posStart, Quaternion.identity); go.name = "Item[" + i + "][" + j + "]"; go.transform.parent = items.transform; item_Obj.Add(go); ItemManager.Instance.Add(go); item_Type_Script[i].itemList.Add(go.GetComponent <Item>()); item_Type_Script[i].itemList[j].itemID = i + 1; j++; yield return(0); } i++; yield return(0); } i = 0; loadingPercent = 60; GameObject floors = new GameObject(); floors.name = "Floors"; while (i < floor_Pref.Count) { int j = 0; floor_Obj.Clear(); floor_Slot.Clear(); floor_item_Slot.Clear(); //Debug.Log (amountFloorSpawn.Length); //GameObject go = (GameObject)Instantiate (floor_Pref[i], posStart, Quaternion.identity); //go.name = "Floor["+i+"]["+j+"]"; //go.transform.parent = floors.transform; //Animator ani = go.GetComponentInChildren<Animator> (); //if (ani) { // GameObject seaj = ani.gameObject; // ItemManager.Instance.Add (seaj); //} //floor_Obj.Add (go); while (j < amountFloorSpawn[i]) { GameObject go = (GameObject)Instantiate(floor_Pref[i], posStart, Quaternion.identity); //go.name = "Floor["+i+"]["+j+"]"; go.transform.parent = floors.transform; Animator ani = go.GetComponentInChildren <Animator> (); if (ani) { GameObject seaj = ani.gameObject; ItemManager.Instance.Add(seaj); } floor_Obj.Add(go); floor_Slot.Add(new Floor()); floor_Slot [j].floor_Slot_Left = new bool[defaultPosBuilding_Left.Count]; floor_Slot [j].floor_Slot_Right = new bool[defaultPosBuilding_Right.Count]; floor_item_Slot.Add(new FloorItemSlot()); floor_item_Slot [j].floor_Slot_Left = new bool[defaultPosItem_Left.Count]; floor_item_Slot [j].floor_Slot_SubLeft = new bool[defaultPosItem_SubLeft.Count]; floor_item_Slot [j].floor_Slot_Middle = new bool[defaultPosItem_Middle.Count]; floor_item_Slot [j].floor_Slot_SubRight = new bool[defaultPosItem_SubRight.Count]; floor_item_Slot [j].floor_Slot_Right = new bool[defaultPosItem_Right.Count]; QueueFloor qfloor = new QueueFloor(); if (GameAttribute.Instance.isFinalLoop) { qfloor.floorObj = Instantiate(FinalFloor_Pref) as GameObject; } else { qfloor.floorObj = floor_Obj [j]; } qfloor.floorClass = floor_Slot [j]; qfloor.floorItemSlotClass = floor_item_Slot [j]; queneFloor.Add(qfloor); j++; yield return(0); } i++; yield return(0); } Shuffle(queneFloor); i = 0; loadingPercent = 90; GameObject waters = new GameObject(); waters.name = "Waters"; while (i < xxxFloorSpawn) { if (water_Pref != null) { GameObject go = (GameObject)Instantiate(water_Pref, posStart, Quaternion.identity); go.name = "Water[" + i + "]"; go.transform.parent = waters.transform; water_Obj.Add(go); } i++; yield return(0); } loadingPercent = 100; spawnObj_Obj = (GameObject)Instantiate(spawnObj_Pref, posStart, Quaternion.identity); colSpawnCheck = spawnObj_Obj.GetComponentInChildren <ColliderSpawnCheck>(); colSpawnCheck.headParent = spawnObj_Obj; //SoundManager.Instance.PlayBGM ("main", true); StartCoroutine(SetPosStarter()); }
IEnumerator InitBuilding() { //75% int i = 0; while(i < building_Pref.Count){ int j = 0; while(j < amountBuildingSpawn[i]){ GameObject go = (GameObject)Instantiate(building_Pref[i], posStart, Quaternion.identity); go.name = "Building["+i+"]["+j+"]"; building_Obj.Add(go); Building building = go.GetComponent<Building>(); building.buildIndex = i; building_Script.Add(building); j++; yield return 0; } i++; yield return 0; } loadingPercent = 30; i = 0; while(i < item_Pref.Count){ int j = 0; item_Type_Script.Add(new Item_Type()); amount_Item_Pattern_Left.Add(0); amount_Item_Pattern_SubLeft.Add(0); amount_Item_Pattern_Middle.Add(0); amount_Item_Pattern_SubRight.Add(0); amount_Item_Pattern_Right.Add(0); while(j < amountItemSpawn[i]){ GameObject go = (GameObject)Instantiate(item_Pref[i], posStart, Quaternion.identity); go.name = "Item["+i+"]["+j+"]"; item_Obj.Add(go); item_Type_Script[i].itemList.Add(go.GetComponent<Item>()); item_Type_Script[i].itemList[j].itemID = i+1; j++; yield return 0; } i++; yield return 0; } i = 0; loadingPercent = 70; while(i < amountFloorSpawn){ GameObject go = (GameObject)Instantiate(floor_Pref, posStart, Quaternion.identity); go.name = "Floor["+i+"]"; floor_Obj.Add(go); floor_Slot.Add(new Floor()); floor_Slot[i].floor_Slot_Left = new bool[defaultPosBuilding_Left.Count]; floor_Slot[i].floor_Slot_Right = new bool[defaultPosBuilding_Right.Count]; floor_item_Slot.Add(new FloorItemSlot()); floor_item_Slot[i].floor_Slot_Left = new bool[defaultPosItem_Left.Count]; floor_item_Slot[i].floor_Slot_SubLeft = new bool[defaultPosItem_SubLeft.Count]; floor_item_Slot[i].floor_Slot_Middle = new bool[defaultPosItem_Middle.Count]; floor_item_Slot[i].floor_Slot_SubRight = new bool[defaultPosItem_SubRight.Count]; floor_item_Slot[i].floor_Slot_Right = new bool[defaultPosItem_Right.Count]; QueueFloor qFloor = new QueueFloor(); qFloor.floorObj = floor_Obj[i]; qFloor.floorClass = floor_Slot[i]; qFloor.floorItemSlotClass = floor_item_Slot[i]; queneFloor.Add(qFloor); i++; yield return 0; } loadingPercent = 100; spawnObj_Obj = (GameObject)Instantiate(spawnObj_Pref, posStart, Quaternion.identity); colSpawnCheck = spawnObj_Obj.GetComponentInChildren<ColliderSpawnCheck>(); colSpawnCheck.headParent = spawnObj_Obj; StartCoroutine(SetPosStarter()); }