void CheckAddBuilding_Right(int i, int j, QueueFloor floor) { //Debug.Log ("CheckAddBuilding_Right("+floor.floorObj.name+")"); int index = 0; while (index < building_Pref.Count) { //Debug.Log ("zzzzzzzzzzzzzzz"); //Debug.Log("xxxxxxxxxxxxx "+patternBuilding[randomPattern].stateBuilding_Right[j]); //Debug.Log("yyyyyyyyyyyyy "+floor.floorClass.floor_Slot_Right[j]); if (patternBuilding[randomPattern].stateBuilding_Right[j] == index + 1 && floor.floorClass.floor_Slot_Right[j] == false) { //Debug.Log ("aaaaaaa "+building_Script[i].buildingActive+" xxx "+ building_Script[i].buildIndex); if (building_Script [i].buildingActive == false && building_Script [i].buildIndex == index) { //Debug.Log ("bbbbbbbb " + floor.floorObj.name); SetPosBuilding_Right(i, j, floor); index = building_Pref.Count; } //else { //Debug.Log ("fffffff"+building_Script [i].buildingActive); //Debug.Log ("zzzzz"+building_Script [i].buildIndex); //} } index++; } }
void SetPosBuilding_Left(int i, int j, QueueFloor floor) { building_Script[i].transform.parent = floor.floorObj.transform; building_Script[i].transform.localPosition = defaultPosBuilding_Left[j]; building_Script[i].transform.eulerAngles = angleLeft; building_Script[i].buildingActive = true; floor.floorClass.floor_Slot_Left[j] = true; floor.getBuilding.Add(building_Script[i]); }
void SetPosItem_Left_For_Type(int i, int j, int countItem, QueueFloor floor) { item_Type_Script[j].itemList[countItem].transform.parent = floor.floorObj.transform; item_Type_Script[j].itemList[countItem].transform.localPosition = defaultPosItem_Left[i]; item_Type_Script[j].itemList[countItem].itemActive = true; floor.floorItemSlotClass.floor_Slot_Left[i] = true; floor.getItem.Add(item_Type_Script[j].itemList[countItem]); item_Type_Script[j].itemList.RemoveRange(countItem, 1); }
void SetPosBuilding_Right(int i, int j, QueueFloor floor) { //Debug.Log ("setPostRight("+ i +" "+j +" "+ floor.floorObj.name+")"); building_Script[i].transform.parent = floor.floorObj.transform; building_Script[i].transform.localPosition = defaultPosBuilding_Right[j]; building_Script[i].transform.eulerAngles = angleRight; building_Script[i].buildingActive = true; floor.floorClass.floor_Slot_Right[j] = true; floor.getBuilding.Add(building_Script[i]); }
void CheckAddBuilding_Left(int i, int j, QueueFloor floor) { int index = 0; while (index < building_Pref.Count) { if (patternBuilding[randomPattern].stateBuilding_Left[j] == index + 1 && floor.floorClass.floor_Slot_Left[j] == false) { if (building_Script[i].buildingActive == false && building_Script[i].buildIndex == index) { SetPosBuilding_Left(i, j, floor); index = building_Pref.Count; } } index++; } }
void AddItemWihtType_Right(QueueFloor floor, int slotIndex, int type) { if (patternItem[randomItem].itemType_Right[slotIndex].x == type) { int j = 0; while (j < amount_Item_Pattern_Right[type - 1]) { if (j < item_Type_Script[type - 1].itemList.Count) { if (item_Type_Script[type - 1].itemList[j].itemActive == false && floor.floorItemSlotClass.floor_Slot_Right[slotIndex] == false) { SetPosItem_Right_For_Type(slotIndex, type - 1, j, floor, patternItem[randomItem].itemType_Right[slotIndex].y); j = 0; } } j++; } } }
IEnumerator AddBuilding() { QueueFloor qFloor = queneFloor[0]; queneFloor.RemoveRange(0, 1); int i = 0; randomPattern = Random.Range(0, patternBuilding.Count); randomItem = Random.Range(0, patternItem.Count); while (i < building_Script.Count) { int j = 0; while (j < patternBuilding[randomPattern].stateBuilding_Left.Length) { CheckAddBuilding_Left(i, j, qFloor); j++; } j = 0; while (j < patternBuilding[randomPattern].stateBuilding_Right.Length) { CheckAddBuilding_Right(i, j, qFloor); j++; } i++; } yield return(0); i = 0; CheckTypeItemFormAdd(qFloor, i); yield return(0); qFloor.floorObj.transform.position = posFloorLast; posFloorLast.z += nextPosFloor; queneFloor.Add(qFloor); StartCoroutine(WaitCheckFloor()); yield return(0); }
void CheckTypeItemFormAdd(QueueFloor floor, int i) { while (i < patternItem[randomItem].itemType_Left.Length) { int j = 0; while (j < amount_Item_Pattern_Left.Count) { if (patternItem[randomItem].itemType_Left[i].x == j + 1) { amount_Item_Pattern_Left[j] += 1; } j++; } i++; } i = 0; while (i < patternItem[randomItem].itemType_SubLeft.Length) { int j = 0; while (j < amount_Item_Pattern_SubLeft.Count) { if (patternItem[randomItem].itemType_SubLeft[i].x == j + 1) { amount_Item_Pattern_SubLeft[j] += 1; } j++; } i++; } i = 0; while (i < patternItem[randomItem].itemType_Middle.Length) { int j = 0; while (j < amount_Item_Pattern_Middle.Count) { if (patternItem[randomItem].itemType_Middle[i].x == j + 1) { amount_Item_Pattern_Middle[j] += 1; } j++; } i++; } i = 0; while (i < patternItem[randomItem].itemType_SubRight.Length) { int j = 0; while (j < amount_Item_Pattern_SubRight.Count) { if (patternItem[randomItem].itemType_SubRight[i].x == j + 1) { amount_Item_Pattern_SubRight[j] += 1; } j++; } i++; } i = 0; while (i < patternItem[randomItem].itemType_Right.Length) { int j = 0; while (j < amount_Item_Pattern_Right.Count) { if (patternItem[randomItem].itemType_Right[i].x == j + 1) { amount_Item_Pattern_Right[j] += 1; } j++; } i++; } i = 0; //Add Item To Floor Left while (i < patternItem[randomItem].itemType_Left.Length) { int s = 0; while (s < amountItemSpawn.Length) { AddItemWihtType_Left(floor, i, s + 1); s++; } i++; } i = 0; while (i < patternItem[randomItem].itemType_SubLeft.Length) { int s = 0; while (s < amountItemSpawn.Length) { AddItemWihtType_SubLeft(floor, i, s + 1); s++; } i++; } i = 0; //Add Item To Floor Middle while (i < patternItem[randomItem].itemType_Middle.Length) { int s = 0; while (s < amountItemSpawn.Length) { AddItemWihtType_Middle(floor, i, s + 1); s++; } i++; } i = 0; while (i < patternItem[randomItem].itemType_SubRight.Length) { int s = 0; while (s < amountItemSpawn.Length) { AddItemWihtType_SubRight(floor, i, s + 1); s++; } i++; } i = 0; //Add Item To Floor Right while (i < patternItem[randomItem].itemType_Right.Length) { int s = 0; while (s < amountItemSpawn.Length) { AddItemWihtType_Right(floor, i, s + 1); s++; } i++; } i = 0; }
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()); }
void SetPosBuilding_Right(int i, int j, QueueFloor floor) { building_Script[i].transform.parent = floor.floorObj.transform; building_Script[i].transform.localPosition = defaultPosBuilding_Right[j]; building_Script[i].transform.eulerAngles = angleRight; building_Script[i].buildingActive = true; floor.floorClass.floor_Slot_Right[j] = true; floor.getBuilding.Add(building_Script[i]); }
void SetPosItem_SubRight_For_Type(int i, int j, int countItem, QueueFloor floor, float height) { item_Type_Script[j].itemList[countItem].transform.parent = floor.floorObj.transform; item_Type_Script[j].itemList[countItem].transform.localPosition = new Vector3( defaultPosItem_SubRight[i].x, defaultPosItem_SubRight[i].y + height, defaultPosItem_SubRight[i].z); item_Type_Script[j].itemList[countItem].itemActive = true; floor.floorItemSlotClass.floor_Slot_SubRight[i] = true; floor.getItem.Add(item_Type_Script[j].itemList[countItem]); item_Type_Script[j].itemList.RemoveRange(countItem,1); }
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()); }
void CheckTypeItemFormAdd(QueueFloor floor, int i) { while(i < patternItem[randomItem].itemType_Left.Length){ int j = 0; while(j < amount_Item_Pattern_Left.Count){ if(patternItem[randomItem].itemType_Left[i].x == j+1){ amount_Item_Pattern_Left[j] += 1; } j++; } i++; } i = 0; while(i < patternItem[randomItem].itemType_SubLeft.Length){ int j = 0; while(j < amount_Item_Pattern_SubLeft.Count){ if(patternItem[randomItem].itemType_SubLeft[i].x == j+1){ amount_Item_Pattern_SubLeft[j] += 1; } j++; } i++; } i = 0; while(i < patternItem[randomItem].itemType_Middle.Length){ int j = 0; while(j < amount_Item_Pattern_Middle.Count){ if(patternItem[randomItem].itemType_Middle[i].x == j+1){ amount_Item_Pattern_Middle[j] += 1; } j++; } i++; } i = 0; while(i < patternItem[randomItem].itemType_SubRight.Length){ int j = 0; while(j < amount_Item_Pattern_SubRight.Count){ if(patternItem[randomItem].itemType_SubRight[i].x == j+1){ amount_Item_Pattern_SubRight[j] += 1; } j++; } i++; } i = 0; while(i < patternItem[randomItem].itemType_Right.Length){ int j = 0; while(j < amount_Item_Pattern_Right.Count){ if(patternItem[randomItem].itemType_Right[i].x == j+1){ amount_Item_Pattern_Right[j] += 1; } j++; } i++; } i = 0; //Add Item To Floor Left while(i < patternItem[randomItem].itemType_Left.Length){ int s = 0; while(s < amountItemSpawn.Length){ AddItemWihtType_Left(floor, i, s+1); s++; } i++; } i = 0; while(i < patternItem[randomItem].itemType_SubLeft.Length){ int s = 0; while(s < amountItemSpawn.Length){ AddItemWihtType_SubLeft(floor, i, s+1); s++; } i++; } i = 0; //Add Item To Floor Middle while(i < patternItem[randomItem].itemType_Middle.Length){ int s = 0; while(s < amountItemSpawn.Length){ AddItemWihtType_Middle(floor, i, s+1); s++; } i++; } i = 0; while(i < patternItem[randomItem].itemType_SubRight.Length){ int s = 0; while(s < amountItemSpawn.Length){ AddItemWihtType_SubRight(floor, i, s+1); s++; } i++; } i = 0; //Add Item To Floor Right while(i < patternItem[randomItem].itemType_Right.Length){ int s = 0; while(s < amountItemSpawn.Length){ AddItemWihtType_Right(floor, i, s+1); s++; } i++; } i = 0; }
void CheckAddBuilding_Right(int i, int j, QueueFloor floor) { int index = 0; while(index < building_Pref.Count){ if(patternBuilding[randomPattern].stateBuilding_Right[j] == index+1 && floor.floorClass.floor_Slot_Right[j] == false){ if(building_Script[i].buildingActive == false && building_Script[i].buildIndex == index){ SetPosBuilding_Right(i,j,floor); index = building_Pref.Count; } } index++; } }
void AddItemWihtType_SubRight(QueueFloor floor, int slotIndex,int type) { if(patternItem[randomItem].itemType_SubRight[slotIndex].x == type){ int j = 0; while(j < amount_Item_Pattern_SubRight[type-1]){ if(j < item_Type_Script[type-1].itemList.Count){ if(item_Type_Script[type-1].itemList[j].itemActive == false && floor.floorItemSlotClass.floor_Slot_SubRight[slotIndex] == false){ SetPosItem_SubRight_For_Type(slotIndex,type-1,j,floor, patternItem[randomItem].itemType_SubRight[slotIndex].y); j = 0; } } j++; } } }
void AddBuildingToFloor(QueueFloor floor) { int i = 0; randomPattern = Random.Range(0, patternBuilding.Count); randomItem = Random.Range(0, patternItem.Count); while(i < building_Script.Count){ int j = 0; while(j < patternBuilding[randomPattern].stateBuilding_Left.Length){ CheckAddBuilding_Left(i,j,floor); j++; } j = 0; while(j < patternBuilding[randomPattern].stateBuilding_Right.Length){ CheckAddBuilding_Right(i,j,floor); j++; } i++; } i = 0; CheckTypeItemFormAdd(floor, i); }