//show speed up loading private void spawnEnemys() { EnemyList = new List <Attacker>(); int roomIndex = 0; for (int i = 1; i < roomPositions.Count - 1; i++) { if (combatRoomIndexs.Contains(roomIndex)) { RoomPlacementLogic rp = roomList[i].GetComponent <RoomPlacementLogic>(); rp.SpawnEnemies(EnemyParent.transform, EnemyList); } roomIndex++; } /* * foreach(GameObject room in roomList) * { * * } */ }
void AddDoorLogic(RoomPlacementLogic room) { Vector3 roomPosition = room.transform.position; bool roomAbove = Physics2D.OverlapCircle(roomPosition + new Vector3(0, yOffset, 0), 0.2f, roomMask); bool roomBelow = Physics2D.OverlapCircle(roomPosition + new Vector3(0, -yOffset, 0), 0.2f, roomMask); bool roomLeft = Physics2D.OverlapCircle(roomPosition + new Vector3(-xOffset, 0, 0), 0.2f, roomMask); bool roomRight = Physics2D.OverlapCircle(roomPosition + new Vector3(xOffset, 0, 0), 0.2f, roomMask); for (int i = 0; i < roomList.Count; i++) { RoomPlacementLogic newRoom = roomList[i].GetComponent <RoomPlacementLogic>(); if (roomAbove) { if (roomList[i].gameObject.transform.localPosition == (roomPosition + new Vector3(0, yOffset, 0))) { if (room.upDoor == false && newRoom.downDoor == false && (room.getDoorRequest() + newRoom.getDoorRequest()) != 0) { room.upDoor = true; newRoom.downDoor = true; GameObject door = Instantiate(RoomObjPrefabs.DoubleDoorStraight, RoomProps.transform); door.GetComponent <Transform>().position = room.transform.position + new Vector3(0, yOffset / 2, 0); doorList.Add(door); } } } if (roomBelow) { if (roomList[i].gameObject.transform.localPosition == (roomPosition + new Vector3(0, -yOffset, 0))) { if (room.downDoor == false && newRoom.upDoor == false && (room.getDoorRequest() + newRoom.getDoorRequest()) != 0) { room.downDoor = true; newRoom.upDoor = true; GameObject door = Instantiate(RoomObjPrefabs.DoubleDoorStraight, RoomProps.transform); door.GetComponent <Transform>().position = room.transform.position + new Vector3(0, -yOffset / 2, 0); doorList.Add(door); } } } if (roomLeft) { if (roomList[i].gameObject.transform.localPosition == (roomPosition + new Vector3(-xOffset, 0, 0))) { if (room.leftDoor == false && newRoom.rightDoor == false && (room.getDoorRequest() + newRoom.getDoorRequest()) != 0) { room.leftDoor = true; newRoom.rightDoor = true; GameObject door = Instantiate(RoomObjPrefabs.DoubleDoorSide, RoomProps.transform); door.GetComponent <Transform>().position = room.transform.position + new Vector3(-xOffset / 2, 0, 0); doorList.Add(door); } } } if (roomRight) { if (roomList[i].gameObject.transform.localPosition == (roomPosition + new Vector3(xOffset, 0, 0))) { if (room.rightDoor == false && newRoom.leftDoor == false && (room.getDoorRequest() + newRoom.getDoorRequest()) != 0) { room.rightDoor = true; newRoom.leftDoor = true; GameObject door = Instantiate(RoomObjPrefabs.DoubleDoorSide, RoomProps.transform); door.GetComponent <Transform>().position = room.transform.position + new Vector3(xOffset / 2, 0, 0); doorList.Add(door); } } } } }
public void GenterateDungeon() { DungeonTracker.instance.finishedLoadingLevel = false; Debug.Log("GenterateDungeon: Entered"); roomList = new List <GameObject>(); int roomIndex = 0; //help to figure out if certain room should be special treasureRoomIndexs = new List <int>(); combatRoomIndexs = new List <int>(); calcuateSpecailRooms(); //build out the rooms CreateRoomsOutLine(Vector3.zero, RoomConditions.StairRoom); //starting room for (int i = 1; i < roomPositions.Count - 1; i++) { RoomConditions conditions = RoomConditions.DefaultRoom; if (treasureRoomIndexs.Contains(roomIndex)) { conditions = RoomConditions.TreasureRoom; } if (combatRoomIndexs.Contains(roomIndex)) { conditions = RoomConditions.CombatRoom; } CreateRoomsOutLine(roomPositions[i], conditions); roomIndex++; } CreateRoomsOutLine(endRoom.transform.position, RoomConditions.StairRoom); doorList = new List <GameObject>(); //creating props for the room for (int i = 0; i < roomList.Count; i++) { RoomPlacementLogic rp = roomList[i].GetComponent <RoomPlacementLogic>(); if (i == 0) //if (roomList[i].transform.position == Vector3.zero) { //start position upStairs = Instantiate(RoomObjPrefabs.StairsUp, RoomProps.transform).GetComponent <DungeonStairs>(); upStairs.transform.position = rp.StairPositions[0].position; } else if (i == roomList.Count - 1) //(roomList[i].transform.position == endRoom.transform.position) { //end room downStairs = Instantiate(RoomObjPrefabs.StairsDown, RoomProps.transform).GetComponent <DungeonStairs>(); downStairs.transform.position = rp.StairPositions[0].position; } else { //all other room types } //door logic //AddDoorLogic(rp); } //DungeonTracker.instance.finishedLoadingLevel = true; StartCoroutine(buildMesh()); //Debug.Log("levelGenerator: finished adding stairs and doors"); }