コード例 #1
0
    int CreatePassageway(ref List <RoomNode> rooms_list, ref int id_counter, int first, CardinalDirection dir, int count)
    {
        List <RoomNode> passage = new List <RoomNode>();

        //Route 1
        for (int i = 0; i < count; ++i)
        {
            RoomNode room = new RoomNode(id_counter++);
            room.room_prefab_ = (GameObject)FindRoomType(RandomRoom());

            if (i > 0)
            {
                RoomNode prev_room = passage[i - 1];
                switch (dir)
                {
                case CardinalDirection.North: prev_room.ConN(ref room); break;

                case CardinalDirection.South: prev_room.ConS(ref room); break;

                case CardinalDirection.East: prev_room.ConE(ref room); break;

                case CardinalDirection.West: prev_room.ConW(ref room); break;
                }

                passage[i - 1] = prev_room;
            }
            else
            {
                RoomNode prev_room = rooms_list[first];
                switch (dir)
                {
                case CardinalDirection.North: prev_room.ConN(ref room); break;

                case CardinalDirection.South: prev_room.ConS(ref room); break;

                case CardinalDirection.East: prev_room.ConE(ref room); break;

                case CardinalDirection.West: prev_room.ConW(ref room); break;
                }
                rooms_list[first] = prev_room;
            }
            passage.Add(room);
        }

        int first_room = rooms_list.Count;

        foreach (RoomNode room in passage)
        {
            rooms_list.Add(room);
        }

        return(first_room);
    }