Пример #1
0
 public static void RemoveObjects(LevelArea area, List <Managed3DObject> objList, IEnumerable <Managed3DObject> objs, ListView.ListViewItemCollection lvic, IEnumerable <ListViewItem> lvis)
 {
     for (int i = 0, loopTo = objs.Count() - 1; i <= loopTo; i++)
     {
         area.Objects.Remove(objs.ElementAtOrDefault(i).Command);
         objList.Remove(objs.ElementAtOrDefault(i));
         lvic.Remove(lvis.ElementAtOrDefault(i));
     }
 }
Пример #2
0
 public static void RemoveWarps(LevelArea area, List <IManagedLevelscriptCommand> objList, IEnumerable <IManagedLevelscriptCommand> objs, ListView.ListViewItemCollection lvic, IEnumerable <ListViewItem> lvis, Dictionary <ListViewItem, ListViewGroup> lviGroups)
 {
     for (int i = 0, loopTo = objs.Count() - 1; i <= loopTo; i++)
     {
         area.Objects.Remove(objs.ElementAtOrDefault(i).Command);
         objList.Remove(objs.ElementAtOrDefault(i));
         lvic.Remove(lvis.ElementAtOrDefault(i));
     }
 }
Пример #3
0
 public static void RevertObjects(LevelArea area, List <Managed3DObject> objList, IEnumerable <int> indicies, IEnumerable <Managed3DObject> objs)
 {
     for (int i = 0, loopTo = objs.Count() - 1; i <= loopTo; i++)
     {
         int index  = indicies.ElementAtOrDefault(i);
         var newobj = objs.ElementAtOrDefault(i);
         objList[index]      = newobj;
         area.Objects[index] = newobj.Command;
     }
 }
Пример #4
0
        public ScrollTexEditor(LevelArea area, LevelAreaConfig areaConfig)
        {
            base.Load += ScrollTexEditor_Load;

            // Dieser Aufruf ist für den Designer erforderlich.
            InitializeComponent();
            base.UpdateAmbientColors();

            // Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
            cArea           = area;
            this.areaConfig = areaConfig;
        }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        //Check if Swapped area
        if (player.transform.position.x > currentArea.rightExtent())
        {
            //Check if need to loop
            if (currentAreaIndex == areas.Count - 2)
            {
                //Move the first area to the last spot in list
                areas.Add(areas[0]);
                areas.RemoveAt(0);

                //Update currentArea reference
                currentArea = areas[currentAreaIndex];

                //Move the area in World Space
                position.x = currentArea.rightExtent() + (areas[areas.Count - 1].getWidth() / 2.0f);
                areas[areas.Count - 1].transform.position = position;
            }
            else
            {
                //Update current area
                currentAreaIndex++;
                currentArea = areas[currentAreaIndex];
            }
        }
        else if (player.transform.position.x < currentArea.leftExtent())
        {
            //Check if need to loop
            if (currentAreaIndex == 1)
            {
                //Move the first area to the last spot in list
                areas.Insert(0, areas[areas.Count - 1]);
                areas.RemoveAt(areas.Count - 1);

                //Update currentArea reference
                currentArea = areas[currentAreaIndex];

                //Move the area in World Space
                position.x = currentArea.leftExtent() - (areas[0].getWidth() / 2.0f);
                areas[0].transform.position = position;
            }
            else
            {
                //Update current area
                currentAreaIndex--;
                currentArea = areas[currentAreaIndex];
            }
        }
    }
Пример #6
0
 public static void RemoveAtObjects(LevelArea area, List <Managed3DObject> objList, ListView.ListViewItemCollection lvic, Dictionary <int, Managed3DObject> removedObjs, Dictionary <int, ListViewItem> removedlvis, Dictionary <int, LevelscriptCommand> removedCmds)
 {
     foreach (KeyValuePair <int, ListViewItem> kvp in removedlvis.OrderByDescending(n => n.Key))
     {
         lvic.RemoveAt(kvp.Key);
     }
     foreach (KeyValuePair <int, Managed3DObject> kvp in removedObjs.OrderByDescending(n => n.Key))
     {
         objList.RemoveAt(kvp.Key);
     }
     foreach (KeyValuePair <int, LevelscriptCommand> kvp in removedCmds.OrderByDescending(n => n.Key))
     {
         area.Objects.RemoveAt(kvp.Key);
     }
 }
Пример #7
0
 public static void RemoveAtWarps(LevelArea area, List <IManagedLevelscriptCommand> objList, ListView.ListViewItemCollection lvic, Dictionary <int, IManagedLevelscriptCommand> removedObjs, Dictionary <int, ListViewItem> removedlvis, Dictionary <int, LevelscriptCommand> removedCmds, Dictionary <ListViewItem, ListViewGroup> lviGroups)
 {
     foreach (KeyValuePair <int, ListViewItem> kvp in removedlvis.OrderByDescending(n => n.Key))
     {
         lvic.RemoveAt(kvp.Key);
     }
     foreach (KeyValuePair <int, IManagedLevelscriptCommand> kvp in removedObjs.OrderByDescending(n => n.Key))
     {
         objList.RemoveAt(kvp.Key);
     }
     foreach (KeyValuePair <int, LevelscriptCommand> kvp in removedCmds.OrderByDescending(n => n.Key))
     {
         area.Warps.RemoveAt(kvp.Key);
     }
 }
Пример #8
0
 public static void InsertWarps(LevelArea area, List <IManagedLevelscriptCommand> objList, ListView.ListViewItemCollection lvic, Dictionary <int, IManagedLevelscriptCommand> removedObjs, Dictionary <int, ListViewItem> removedlvis, Dictionary <int, LevelscriptCommand> removedCmds, Dictionary <ListViewItem, ListViewGroup> lviGroups)
 {
     foreach (KeyValuePair <int, IManagedLevelscriptCommand> kvp in removedObjs.OrderBy(n => n.Key))
     {
         objList.Insert(kvp.Key, kvp.Value);
     }
     foreach (KeyValuePair <int, LevelscriptCommand> kvp in removedCmds.OrderBy(n => n.Key))
     {
         area.Warps.Insert(kvp.Key, kvp.Value);
     }
     foreach (KeyValuePair <int, ListViewItem> kvp in removedlvis.OrderBy(n => n.Key))
     {
         kvp.Value.Group = lviGroups[kvp.Value];
         lvic.Insert(kvp.Key, kvp.Value);
     }
 }
Пример #9
0
        internal static Object3D LoadAreaVisualMapAsObject3D(RomManager rommgr, LevelArea area)
        {
            var obj = new Object3D();
            var dls = new List <DisplayList>();

            foreach (Geopointer geop in area.AreaModel.Fast3DBuffer.DLPointers)
            {
                var dl = new DisplayList();
                dl.FromStream(geop, rommgr, area.AreaID);
                dl.ToObject3D(obj, rommgr, area.AreaID);
                dls.Add(dl);
            }

            LoadedAreaVisualMapDisplayLists?.Invoke(dls.ToArray());

            return(obj);
        }
Пример #10
0
    // Use this for initialization
    void Start()
    {
        //Error Checking
        if (startArea == null)
        {
            Debug.LogError("LevelManager: Start Area Null");
        }

        if (!areas.Contains(startArea))
        {
            Debug.LogError("LevelManager: Start Area not listed in areas");
        }

        //Variable Initialization
        player = GameObject.FindGameObjectWithTag("Player").transform;

        //Initialize the positions
        currentAreaIndex = areas.IndexOf(startArea);
        currentArea      = startArea;

        position = new Vector3(0, 0, 0);
        startArea.transform.position = position;
        //Debug.Log("Index: " + currentAreaIndex + "; Width: " + currentArea.getWidth());


        //Panels to the right
        position.x = currentArea.getWidth() / 2.0f;
        for (int i = currentAreaIndex + 1; i < areas.Count; i++)
        {
            position.x += areas[i].getWidth() / 2.0f;
            areas[i].transform.position = position;
            position.x += areas[i].getWidth() / 2.0f;
            //Debug.Log("Index: " + areas[i].name + "; Width: " + areas[i].getWidth());
        }

        //Panels to the left
        position.x = 0 - currentArea.getWidth() / 2.0f;
        for (int i = currentAreaIndex - 1; i >= 0; i--)
        {
            position.x -= areas[i].getWidth() / 2.0f;
            areas[i].transform.position = position;
            position.x -= areas[i].getWidth() / 2.0f;
            //Debug.Log("Index: " + i + "; Width: " + areas[i].getWidth());
        }
    }
Пример #11
0
        /// <summary>
        /// 区域加载完成
        /// </summary>
        private void OnLoadedAreaHandler(LevelArea area)
        {
            Debug.Log("OnLoadedAreaHandler - > " + area.index);

            if (area.index == 1)
            {
                var points = levelInfo.GetHeroPoints(areaIndex);
                // 玩家出生
                hero.Born(points[0]);

                // 关卡设置hero transform
                levelInfo.SetHeroTransform(hero.actorGameObject.transform);

                // 设置相机
                heroCamera.SetLookAt(hero.actorGameObject.transform);

                // 摇杆初始化
                Game.virtualJoy.Initialize();
            }
        }
Пример #12
0
 /// <summary>
 /// 离开区域
 /// </summary>
 private void OnExitAreaHandler(LevelArea area)
 {
     Debug.Log("OnExitAreaHandler - > " + area.index);
 }
Пример #13
0
        /// <summary>
        /// 进入区域
        /// </summary>
        private void OnEnterAreaHandler(LevelArea area)
        {
            Debug.Log("OnEnterAreaHandler - > " + area.index);

            CreateMonster(100001);
        }
Пример #14
0
        internal static Task <Object3D> LoadAreaVisualMapAsObject3DAsync(RomManager rommgr, LevelArea area)
        {
            var t = new Task <Object3D>(() => LoadAreaVisualMapAsObject3D(rommgr, area));

            t.Start();
            return(t);
        }
Пример #15
0
 public Pylon(PylonName name, LevelArea levelArea)
 {
     this.Name      = name;
     this.LevelArea = levelArea;
 }
Пример #16
0
        private void Render(object sender, PaintEventArgs e)
        {
            try
            {
                int location = -1;

                if (engine != null)
                {
                    LevelArea level_area = Engine.Current.LevelArea;
                    if (level_area != null)
                    {
                        location = level_area.x044_SnoId;
                    }
                }

                if (last_location != location)
                {
                    if (auto_clear_navmesh)
                    {
                        m_Navmesh.Clear();
                        LoadDebugConfig();
                    }
                    last_location = location;
                }

                Matrix m = new Matrix();
                m.Scale(render_scale, render_scale);
                m.Translate((Width - 16) / (2 * render_scale), (Height - 30) / (2 * render_scale));

                // when Diablo is running display navmesh in the same manner as Diablo does
                if (engine != null)
                {
                    m.Rotate(135);
                    Matrix flip_x_m = new Matrix(1, 0, 0, -1, 0, 0);
                    m.Multiply(flip_x_m);
                }

                e.Graphics.Transform          = m;
                e.Graphics.CompositingQuality = CompositingQuality.GammaCorrected;
                e.Graphics.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                int cells_count      = 0;
                int grid_cells_count = 0;

                if (render_grids || render_cells)
                {
                    using (m_Navmesh.AquireReadDataLock())
                    {
                        List <GridCell> grid_cells = m_Navmesh.dbg_GetGridCells();

                        if (render_grids)
                        {
                            foreach (Nav.GridCell grid_cell in grid_cells)
                            {
                                RenderHelper.Render(grid_cell, render_center, e, render_connections, render_id);
                            }

                            grid_cells_count = grid_cells.Count;
                        }

                        if (render_cells)
                        {
                            float max_move_cost_mult = 1;

                            foreach (Nav.GridCell grid_cell in grid_cells)
                            {
                                foreach (Nav.Cell cell in grid_cell.Cells)
                                {
                                    RenderHelper.Render(cell, render_center, e, render_connections, render_id, m_LastMaxMoveCostMult);
                                    max_move_cost_mult = Math.Max(max_move_cost_mult, cell.MovementCostMult);
                                }

                                cells_count += grid_cell.Cells.Count;
                            }

                            m_LastMaxMoveCostMult = max_move_cost_mult;
                        }
                    }
                }

                if (render_explore_cells || render_explore_dist)
                {
                    using (m_Navmesh.Explorator.AquireReadDataLock())
                    {
                        List <ExploreCell> explore_cells = m_Navmesh.Explorator.dbg_GetExploreCells();

                        if (render_explore_cells)
                        {
                            foreach (Nav.ExploreCell explore_cell in explore_cells)
                            {
                                RenderHelper.Render(explore_cell, m_Navmesh.Navigator.ExploreCellPrecision, render_center, e, render_connections, render_id);
                            }
                        }

                        if (render_explore_dist)
                        {
                            if (explore_cells.Exists(c => c.Id == explore_cell_id_to_render_dists))
                            {
                                RenderHelper.Render(m_Navmesh, explore_cells.Find(c => c.Id == explore_cell_id_to_render_dists), render_center, e, render_id);
                            }
                        }
                    }
                }

                if (render_regions)
                {
                    var regions = m_Navmesh.Regions;

                    foreach (var region in regions)
                    {
                        RenderHelper.DrawRectangle(e.Graphics, Pens.Black, render_center, region.area.Min, region.area.Max);
                    }

                    //Vec3 safe_point = m_Navmesh.Navigator.GetNearestGridCellOutsideAvoidAreas();

                    //if (!safe_point.IsEmpty)
                    //    RenderHelper.DrawPoint(e.Graphics, Pens.Green, render_center, safe_point);
                }

                if (render_axis)
                {
                    e.Graphics.DrawString("X", new Font("Arial", 6 / render_scale), Brushes.Black, 25 / render_scale, 0);
                    e.Graphics.DrawLine(RenderHelper.AXIS_PEN, -25 / render_scale, 0, 25 / render_scale, 0);
                    e.Graphics.DrawString("Y", new Font("Arial", 6 / render_scale), Brushes.Black, 0, 25 / render_scale);
                    e.Graphics.DrawLine(RenderHelper.AXIS_PEN, 0, -25 / render_scale, 0, 25 / render_scale);
                }

                if (render_explore_cells && m_Navmesh.Explorator is Nav.ExploreEngine.TSP)
                {
                    ((Nav.ExploreEngine.TSP)m_Navmesh.Explorator).TryGetExplorePath(ref last_explore_path);
                    RenderHelper.DrawLines(e.Graphics, RenderHelper.EXPLORE_PATH_PEN, render_center, last_explore_path, 1);
                }

                if (!render_original_path && render_path)
                {
                    DestType last_path_dest_type = DestType.None;
                    if (m_Navmesh.Navigator.TryGetPath(ref last_path, ref last_path_dest_type))
                    {
                        last_path.Insert(0, m_Navmesh.Navigator.CurrentPos);
                    }
                    RenderHelper.DrawLines(e.Graphics, RenderHelper.PATH_PEN, render_center, last_path, 1);
                }

                if (render_backtrack_path)
                {
                    if (m_Navmesh.Navigator.TryGetBackTrackPath(ref last_back_track_path))
                    {
                        last_back_track_path.Insert(0, m_Navmesh.Navigator.CurrentPos);
                    }
                    RenderHelper.DrawLines(e.Graphics, Pens.Blue, render_center, last_back_track_path, 1);
                }

                if (render_positions_history)
                {
                    m_Navmesh.Navigator.TryGetDebugPositionsHistory(ref last_positions_history);
                    RenderHelper.DrawLines(e.Graphics, Pens.Green, render_center, last_positions_history, 1);
                }

                if (!m_Navmesh.Navigator.CurrentPos.IsEmpty)
                {
                    RenderHelper.DrawPoint(e.Graphics, Pens.Blue, render_center, m_Navmesh.Navigator.CurrentPos);
                }
                if (!m_Navmesh.Navigator.Destination.IsEmpty)
                {
                    RenderHelper.DrawPoint(e.Graphics, Pens.LightBlue, render_center, m_Navmesh.Navigator.Destination);
                }

                {
                    Vec3 curr = m_Navmesh.Navigator.CurrentPos;
                    Vec3 dest = m_Navmesh.Navigator.Destination;

                    if (!curr.IsEmpty && !dest.IsEmpty)
                    {
                        if (render_original_path)
                        {
                            List <Vec3> path = new List <Vec3>();
                            m_Navmesh.Navigator.FindPath(curr, dest, MovementFlag.Walk, ref path, -1, false, false, 0, false, 0, false);
                            path.Insert(0, curr);
                            RenderHelper.DrawLines(e.Graphics, Pens.Black, render_center, path, 1);
                        }

                        if (render_ray_cast)
                        {
                            RenderHelper.DrawLine(e.Graphics, m_Navmesh.RayCast2D(curr, dest, MovementFlag.Walk) ? Pens.Green : Pens.Red, render_center, curr, dest);
                        }
                    }
                }

                if (waypoints_paths.Count > 0)
                {
                    int waypoint_id = 1;
                    foreach (List <Vec3> p in waypoints_paths)
                    {
                        if (p.Count > 0)
                        {
                            RenderHelper.DrawCircle(e.Graphics, Pens.Black, render_center, p[0], 3);
                            RenderHelper.DrawString(e.Graphics, Brushes.Black, render_center, p[0], waypoint_id.ToString(), 10);
                        }
                        RenderHelper.DrawLines(e.Graphics, Pens.Red, render_center, p, 1);
                        ++waypoint_id;
                    }
                }

                if (bot != null)
                {
                    if (!bot.Paused && center_on_bot)
                    {
                        render_center = new PointF(bot.Position.X, bot.Position.Y);
                    }
                    bot.Render(e.Graphics, render_center);
                }

                e.Graphics.ResetTransform();

                Font legend_font = new Font("Arial", 8, FontStyle.Bold);
                Font stats_font  = new Font("Arial", 8);

                TextRenderer.DrawText(e.Graphics, "L: Toggle render legend", legend_font, new Point(10, 10), render_legend ? Color.White : Color.Black, render_legend ? Color.Black : Color.Transparent);

                if (render_legend)
                {
                    e.Graphics.DrawString("F1: Reload waypoints", legend_font, Brushes.Black, 10, 25);
                    e.Graphics.DrawString("F2: Reload nav data", legend_font, Brushes.Black, 10, 40);
                    e.Graphics.DrawString("F3: Dump nav data", legend_font, Brushes.Black, 10, 55);
                    e.Graphics.DrawString("F4: Clear nav data", legend_font, Brushes.Black, 10, 70);
                    e.Graphics.DrawString("F5: Serialize nav data", legend_font, Brushes.Black, 10, 85);
                    e.Graphics.DrawString("F6: Deserialize nav data", legend_font, Brushes.Black, 10, 100);
                    e.Graphics.DrawString("F10: Activate some test", legend_font, Brushes.Black, 10, 115);
                    TextRenderer.DrawText(e.Graphics, "1: Toggle render grid cells", legend_font, new Point(10, 130), render_grids ? Color.White : Color.Black, render_grids ? Color.Black : Color.Transparent);
                    TextRenderer.DrawText(e.Graphics, "2: Toggle render cells", legend_font, new Point(10, 145), render_cells ? Color.White : Color.Black, render_cells ? Color.Black : Color.Transparent);
                    TextRenderer.DrawText(e.Graphics, "3: Toggle render explore cells", legend_font, new Point(10, 160), render_explore_cells ? Color.White : Color.Black, render_explore_cells ? Color.Black : Color.Transparent);
                    TextRenderer.DrawText(e.Graphics, "4: Toggle render connections", legend_font, new Point(10, 175), render_connections ? Color.White : Color.Black, render_connections ? Color.Black : Color.Transparent);
                    TextRenderer.DrawText(e.Graphics, "5: Toggle render IDs", legend_font, new Point(10, 190), render_id ? Color.White : Color.Black, render_id ? Color.Black : Color.Transparent);
                    TextRenderer.DrawText(e.Graphics, "6: Toggle render axis", legend_font, new Point(10, 205), render_axis ? Color.White : Color.Black, render_axis ? Color.Black : Color.Transparent);
                    TextRenderer.DrawText(e.Graphics, "7: Toggle render regions", legend_font, new Point(10, 220), render_regions ? Color.White : Color.Black, render_regions ? Color.Black : Color.Transparent);
                    TextRenderer.DrawText(e.Graphics, "8: Toggle render original path", legend_font, new Point(10, 235), render_original_path ? Color.White : Color.Black, render_original_path ? Color.Black : Color.Transparent);
                    TextRenderer.DrawText(e.Graphics, "9: Toggle render ray cast", legend_font, new Point(10, 250), render_ray_cast ? Color.White : Color.Black, render_ray_cast ? Color.Black : Color.Transparent);
                    TextRenderer.DrawText(e.Graphics, "0: Toggle render back track path", legend_font, new Point(10, 265), render_backtrack_path ? Color.White : Color.Black, render_backtrack_path ? Color.Black : Color.Transparent);
                    e.Graphics.DrawString("S: Set current pos", legend_font, Brushes.Black, 10, 280);
                    e.Graphics.DrawString("E: Set destination pos", legend_font, Brushes.Black, 10, 295);
                    e.Graphics.DrawString("B: Run bot", legend_font, Brushes.Black, 10, 310);
                    TextRenderer.DrawText(e.Graphics, "A: Toggle auto clear navmesh", legend_font, new Point(10, 325), auto_clear_navmesh ? Color.White : Color.Black, auto_clear_navmesh ? Color.Black : Color.Transparent);
                    e.Graphics.DrawString("F7: Reload debug.ini", legend_font, Brushes.Black, 10, 340);
                    TextRenderer.DrawText(e.Graphics, "Ctrl+1: Toggle render path", legend_font, new Point(10, 355), render_path ? Color.White : Color.Black, render_path ? Color.Black : Color.Transparent);
                    TextRenderer.DrawText(e.Graphics, "Ctrl+2: Toggle regions", legend_font, new Point(10, 370), m_Navmesh.RegionsEnabled ? Color.White : Color.Black, m_Navmesh.RegionsEnabled ? Color.Black : Color.Transparent);
                    TextRenderer.DrawText(e.Graphics, "Ctrl+3: Toggle danger regions", legend_font, new Point(10, 385), m_Navmesh.DangerRegionsEnabled ? Color.White : Color.Black, m_Navmesh.DangerRegionsEnabled ? Color.Black : Color.Transparent);
                    TextRenderer.DrawText(e.Graphics, "Ctrl+4: Toggle render positions history", legend_font, new Point(10, 400), render_positions_history ? Color.White : Color.Black, render_positions_history ? Color.Black : Color.Transparent);
                }

                e.Graphics.DrawString("Cells count: " + cells_count, stats_font, Brushes.Black, 10, Height - 55);
            }
            catch (Exception)
            {
            }
        }
Пример #17
0
        private void ButtonX_Import_Click(object sender, EventArgs e)
        {
            var lvl = GetSelectedLevel();

            LevelInfoDataTabelList.Level levelinfo;
            if (lvl is object)
            {
                Level newLvl;
                void copySM64EArea(LevelArea a, LevelArea newArea)
                {
                    newArea.Background.Type  = a.Background.Type;
                    newArea.Background.Color = a.Background.Color;
                    // newArea.BGMusic = a.BGMusic
                    newArea.TerrainType = a.TerrainType;
                    newArea.Objects.AddRange(a.Objects.ToArray());
                    newArea.Warps.AddRange(a.Warps.ToArray());
                    newArea.WarpsForGame.AddRange(a.WarpsForGame.ToArray());
                    newArea.AreaModel = a.AreaModel;
                };
                if (addAreasOnly)
                {
                    var          areasToAsdd = new List <LevelArea>();
                    Stack <byte> availableAreaIDs;
                    newLvl = destLevel;

                    // Get all available area ids
                    availableAreaIDs = Publics.General.GetAllFreeAreaIDs(destLevel);

                    // Get selected Areas
                    var areasToCopy = new List <LevelArea>();
                    foreach (CheckBoxItem item in ItemPanel_Areas.Items)
                    {
                        if (item.Tag is LevelArea && item.Checked)
                        {
                            areasToCopy.Add((LevelArea)item.Tag);
                        }
                    }

                    if (availableAreaIDs.Count >= areasToCopy.Count)
                    {
                        // Copy areas
                        foreach (LevelArea fearea in areasToCopy)
                        {
                            LevelArea area = fearea;
                            if (openrom.IsSM64EditorMode)
                            {
                                var newArea = new SM64ELevelArea(availableAreaIDs.Pop());
                                copySM64EArea(area, newArea);
                                area = newArea;
                            }
                            else
                            {
                                area.AreaID = availableAreaIDs.Pop();
                            }

                            areasToAsdd.Add(area);
                        }

                        // Add areas
                        newLvl.Areas.AddRange(areasToAsdd);
                        AreasCopy = areasToAsdd.ToArray();

                        // Close Window
                        DialogResult = DialogResult.OK;
                    }
                    else if (!areasToCopy.Any())
                    {
                        MessageBoxEx.Show("You haven't selected any area to copy.", "No area selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBoxEx.Show("You have to many areas selected. The destination level hasn't enough free area slots.", "To many areas", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    var selector = new LevelSelectorDialog(rommgr);
                    if (selector.ShowDialog() == DialogResult.OK)
                    {
                        levelinfo = selector.SelectedLevel;
                        var switchExpr = openrom.IsSM64EditorMode;
                        switch (switchExpr)
                        {
                        case true:
                        {
                            // Create mew Level
                            newLvl = new RMLevel(levelinfo.ID, levelinfo.Index);

                            // Create new Areas & Copy Area Data
                            foreach (LevelArea a in lvl.Areas)
                            {
                                var newArea = new RMLevelArea(a.AreaID, Conversions.ToByte(newLvl.LevelID), false, false);
                                copySM64EArea(a, newArea);
                                newLvl.Areas.Add(newArea);
                            }

                            // Copy Level Data
                            newLvl.Background.Enabled      = lvl.Background.Enabled;
                            newLvl.Background.ID           = lvl.Background.ID;
                            newLvl.Background.ImageData    = lvl.Background.ImageData;
                            newLvl.Background.IsCustom     = lvl.Background.IsCustom;
                            newLvl.HardcodedCameraSettings = lvl.HardcodedCameraSettings;
                            newLvl.ActSelector             = lvl.ActSelector;
                            break;
                        }

                        case false:
                        {
                            newLvl         = lvl;
                            newLvl.LevelID = levelinfo.ID;
                            break;
                        }

                        default:
                        {
                            newLvl = null;
                            break;
                        }
                        }

                        if (newLvl is object)
                        {
                            // Add Level
                            rommgr.Levels.Add(newLvl);
                            LevelCopy = newLvl;

                            // Close Window
                            DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            MessageBoxEx.Show("The level can't be added.", "Add Level", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }