コード例 #1
0
    void DetermineDungeon(List <RoomBuilder> roomBuilders)
    {
        List <RoomBuilder> maxDepth = roomBuilders.Where(o => o.depth == depth).ToList().OrderByDescending(o => o.sizeX * o.sizeY).ToList();

        maxDepth[0].AddRoomFiller(new BossOneFiller(maxDepth[0].position, maxDepth[0].sizeX, maxDepth[0].sizeY, maxDepth[0].room, maxDepth[0].doors));
        //maxDepth[1].AddRoomFiller(new BossOneFiller(maxDepth[1].position, maxDepth[1].sizeX, maxDepth[1].sizeY, maxDepth[1].room, maxDepth[1].doors));

        RoomBuilder      portalRoom        = maxDepth[maxDepth.Count - 1];
        RoomBuilder      portalRoom2       = maxDepth[maxDepth.Count - 2];
        PortalRoomFiller portalRoomFiller1 = new PortalRoomFiller(portalRoom.position, portalRoom.sizeX, portalRoom.sizeY, portalRoom.room, portalRoom.doors);
        PortalRoomFiller portalRoomFiller2 = new PortalRoomFiller(portalRoom2.position, portalRoom2.sizeX, portalRoom2.sizeY, portalRoom2.room, portalRoom2.doors);

        portalRoomFiller1.destinationRoom = portalRoomFiller2;
        portalRoomFiller2.destinationRoom = portalRoomFiller1;
        portalRoom.AddRoomFiller(portalRoomFiller1);
        portalRoom2.AddRoomFiller(portalRoomFiller2);

        List <RoomBuilder> depthSorted = roomBuilders.OrderByDescending(o => o.depth).ToList();
        List <RoomBuilder> sizeSorted  = roomBuilders.OrderBy(o => o.depth).ToList();

        int numStores = Random.Range(1, 4);
        int stores    = 0;

        foreach (RoomBuilder builder in depthSorted)
        {
            if (!builder.hasRoomFiller)
            {
                if (Random.Range(0, 100) > 20)
                {
                    builder.AddRoomFiller(new StoreRoomFiller(builder.position, builder.sizeX, builder.sizeY, builder.room, builder.doors));
                }
                stores++;
                if (stores >= numStores)
                {
                    break;
                }
            }
        }

        foreach (RoomBuilder builder in depthSorted)
        {
            if (!builder.hasRoomFiller)
            {
                if (Random.Range(0, 100) > 10)
                {
                    builder.AddRoomFiller(new GraveYardRoom(builder.position, builder.sizeX, builder.sizeY, builder.room, builder.doors));
                }
                else if (Random.Range(0, 100) > 32)
                {
                    builder.AddRoomFiller(new LakeRoomFiller(builder.position, builder.sizeX, builder.sizeY, builder.room, builder.doors));
                }
                else
                {
                    builder.AddRoomFiller(new GraveYardRoom(builder.position, builder.sizeX, builder.sizeY, builder.room, builder.doors));
                }
            }
            //Debug.Log(builder.depth);
        }
    }