コード例 #1
0
ファイル: MainWindow.cs プロジェクト: minishmaker/minishmaker
        public void ChangeRoom(int areaId, int roomId)
        {
            statusRoomIdText.Text = "Room Id:" + roomId.Hex().PadLeft(2, '0');
            statusAreaIdText.Text = "Area Id:" + areaId.Hex().PadLeft(2, '0');

            var isDifferentArea = currentArea != areaId;
            var room            = FindRoom(areaId, roomId);


            try
            {
                mapLayers = room.DrawRoom(areaId, true, true);
            }
            catch (PaletteException exception)
            {
                Notify(exception.Message, "Invalid Room");
                statusText.Text = "Room load aborted.";
                return;
            }

            currentArea = areaId;
            currentRoom = room;

            selectedTileData             = -1;
            tileTabControl.SelectedIndex = 1; // Reset to bg2

            //0= bg1 (treetops and such)
            //1= bg2 (flooring)
            mapGridBox.Image        = OverlayImage(mapLayers[1], mapLayers[0]);
            tileMaps                = room.DrawTilesetImages(16, currentArea);
            bottomTileGridBox.Image = tileMaps[1];
            topTileGridBox.Image    = tileMaps[0];

            mapGridBox.Selectable        = true;
            mapGridBox.SelectedIndex     = -1;
            bottomTileGridBox.Selectable = true;
            topTileGridBox.Selectable    = true;

            if (chestEditor != null)
            {
                var chestData = currentRoom.GetChestData();
                chestEditor.SetData(chestData);
            }

            if (metatileEditor != null)
            {
                metatileEditor.currentArea = currentArea;
                room = MapManager.Instance.MapAreas.Single(a => a.Index == currentArea).Rooms.First();
                if (!room.Loaded)
                {
                    room.LoadRoom(currentArea);
                }
                metatileEditor.RedrawTiles(currentRoom);
            }

            if (areaEditor != null && isDifferentArea)//still in the same area? dont reload
            {
                areaEditor.LoadArea(areaId);
            }

            /*if(enemyPlacementEditor != null)
             * {
             *  enemyPlacementEditor.LoadData();
             * }*/

            if (warpEditor != null)
            {
                warpEditor.LoadData();
            }

            if (objectPlacementEditor != null)
            {
                objectPlacementEditor.LoadData();
            }
        }