void DrawMap() { foreach (RoomInfo room in chambers) { if (room == null) { continue; } Vector2 drawPos = room.gridPosition; RoomAssigner assigner = Instantiate(roomSprites, drawPos, Quaternion.identity, transform).GetComponent <RoomAssigner>(); assigner.type = room.type; assigner.up = room.doorTop; assigner.down = room.doorBot; assigner.left = room.doorLeft; assigner.right = room.doorRight; assignedRooms.Add(assigner); if (assigner.type == 1) { GameObject gameObject = Instantiate(player, assigner.transform.position, Quaternion.identity); RoomMovement roomMovement = gameObject.GetComponent <RoomMovement>(); roomMovement.spawner = this; } else if (assigner.type == 2) { StartCoroutine(SpawnBox(assigner)); } } }
IEnumerator LateStart() { yield return(new WaitForSeconds(.1f)); map = new RoomAssigner[spawner.gridSizeX * 50, spawner.gridSizeY * 50]; mapPosition = spawner.worldSize; foreach (RoomAssigner room in spawner.assignedRooms) { if (room.type == 1) { map[(int)spawner.worldSize.x, (int)spawner.worldSize.y] = room; } map[(int)room.pos.x, (int)room.pos.y] = room; //Debug.Log(room.transform.position.ToString()); } RoomAssigner ra = map[(int)mapPosition.x, (int)mapPosition.y].gameObject.GetComponent <RoomAssigner>(); currentRoom = ra.room; }
IEnumerator SpawnBox(RoomAssigner assigner) { yield return(new WaitForSeconds(.1f)); Instantiate(nextFloor, assigner.room.transform.position, Quaternion.identity); }