コード例 #1
0
    public void generateDungeon(float difficulty)
    {
        Debug.Log(difficulty);
        int floors = DifficultyToFloors(difficulty);

        dungeonFloors.Clear();
        activeFloor = 0;
        float floorDifficulty = (difficulty / floors) * 2;

        Debug.Log(floorDifficulty);

        for (int i = 0; i < floors; i++)
        {
            TileBase[,] floorWallTiles = digger.MakeDungeonFloor(
                DungeonPresets.difficultyToDungeonParams(floorDifficulty));
            List <Rect> floorRoomRects     = digger.rooms.ToList();
            List <Rect> floorCorridorRects = digger.corridors.ToList();
            List <Room> rooms = RoomBuilder.BuildRooms(
                floorDifficulty,
                floorWallTiles,
                floorRoomRects,
                floorCorridorRects);

            DungeonFloor dungeonFloor = new DungeonFloor(
                floorWallTiles,
                floorRoomRects,
                floorCorridorRects,
                rooms);
            dungeonFloors.Add(dungeonFloor);
        }
    }
コード例 #2
0
ファイル: Foreman.cs プロジェクト: soulzkeeper/portfolio
    void Start()
    {
        /*
         * 1. Build the quadrants
         * 2. Build the rooms
         * 3. Build the containers
         * 4. Set the current room
         * 5. Force the rooms to subscribe to events
         * 6. Fire events.
         * */


        // Presets.
        containerActiveLayer = 1 << LayerMask.NameToLayer("ActiveItems");

        // Set the camera.
        cameraScript = mainCamera.GetComponent <PositionCamera> ();

        // Build the rooms.
        RoomBuilder floorBuilderScript = GetComponent <RoomBuilder> ();

        rooms = floorBuilderScript.BuildRooms();

        // Add in containers.
        ContainerBuilder containerBuilder = GetComponent <ContainerBuilder> ();

        containerBuilder.BuildContainers(rooms);

        // Activate the current room.
        SetRoom(floorBuilderScript.currentRoomIndex);

        // Move the camera, and action!
        cameraScript.SnapTo(rooms[currentRoomIndex].transform);
        Subscribe();
    }