コード例 #1
0
        public bool BuildWorld(
            AsyncRPGDataContext db_context,
            int game_id,
            out World world,
            out string result)
        {
            bool          success       = true;
            WorldTemplate worldTemplate = null;
            DungeonLayout layout        = null;

            world  = null;
            result = SuccessMessages.GENERAL_SUCCESS;

            // Get the world generation parameters from the DB
            worldTemplate =
                WorldQueries.GetWorldGenerationParameters(
                    db_context,
                    game_id);

            // Create the initial set of rooms for the world
            if (success)
            {
                layout = new DungeonLayout(game_id, worldTemplate, m_roomTemplateSet, m_mobSpawnTableSet);

                if (!layout.BuildRoomLayout(out result))
                {
                    success = false;
                }
            }

            // Copy the rooms and portals from the layout into the world
            if (success)
            {
                world = new World(this, layout.LayoutWorldTemplate, game_id);
                world.ApplyLayout(layout);
            }

            // TODO: WorldBuilder: Generate the environment objects, etc

            // Save the cached world into the database
            if (success)
            {
                WorldQueries.InsertWorld(db_context, world);
            }

            return(success);
        }
コード例 #2
0
        public void ApplyLayout(
            DungeonLayout layout)
        {
            // Copy over all the rooms in the layout into the world
            for (DungeonLayout.RoomIndexIterator iterator = new DungeonLayout.RoomIndexIterator(layout.RoomGrid);
                 iterator.Valid;
                 iterator.Next())
            {
                DungeonLayout.RoomIndex roomIndex = iterator.Current;
                RoomLayout   room         = layout.GetRoomByIndex(roomIndex);
                RoomTemplate roomTemplate = layout.LayoutRoomTemplateSet.GetTemplateByName(room.static_room_data.room_template_name);

                room.runtime_nav_mesh = new NavMesh(room.room_key, roomTemplate.NavMeshTemplate);

                m_rooms.Add(room.room_key, room);
            }
        }