Beispiel #1
0
 public virtual void RunTick(EditorRoomScene scene)
 {
     if (UIComponent.ComponentWithFocus != null)
     {
         return;
     }
 }
Beispiel #2
0
        public void PasteBlueprintByLayer(EditorRoomScene scene, Dictionary <string, Dictionary <string, ArrayList> > layerData, LayerEnum layerEnum, short x, short y, short xStart, short yStart)
        {
            // Get the value stored in this blueprint at correct tile position:
            ArrayList bpData = this.gridTrack[(byte)layerEnum, y, x];

            if (bpData == null)
            {
                return;
            }

            // Copy the blueprint at correct tile position in level editor:
            if (bpData.Count > 2)
            {
                Dictionary <string, short> paramsList;

                if (bpData[2] is IDictionary)
                {
                    paramsList = (Dictionary <string, short>)bpData[2];
                }
                else
                {
                    paramsList = JsonConvert.DeserializeObject <Dictionary <string, short> >(bpData[2].ToString());
                }

                scene.PlaceTile(layerData, layerEnum, (short)(xStart + x), (short)(yStart + y), byte.Parse(bpData[0].ToString()), byte.Parse(bpData[1].ToString()), paramsList);
            }
            else
            {
                scene.PlaceTile(layerData, layerEnum, (short)(xStart + x), (short)(yStart + y), byte.Parse(bpData[0].ToString()), byte.Parse(bpData[1].ToString()));
            }
        }
Beispiel #3
0
        public void PrepareBlueprint(EditorRoomScene scene, short xStart, short yStart, short xEnd, short yEnd, sbyte xOffset = 0, sbyte yOffset = 0)
        {
            this.isActive = true;

            short left = xStart <= xEnd ? xStart : xEnd;
            short top  = yStart <= yEnd ? yStart : yEnd;

            this.blueprintWidth  = (short)(Math.Abs(xEnd - xStart) + 1);
            this.blueprintHeight = (short)(Math.Abs(yEnd - yStart) + 1);
            this.xOffset         = xOffset;
            this.yOffset         = yOffset;

            RoomFormat roomData = scene.levelContent.data.rooms[scene.roomID];

            var mainData = roomData.main;
            var objData  = roomData.obj;
            var bgData   = roomData.bg;
            var fgData   = roomData.fg;

            // Loop through the blueprint:
            for (short y = 0; y < this.blueprintHeight; y++)
            {
                string yPos = (top + y).ToString();

                for (short x = 0; x < this.blueprintWidth; x++)
                {
                    string xPos = (left + x).ToString();

                    this.AddToBlueprintTile(mainData, LayerEnum.main, x, y, xPos, yPos);
                    this.AddToBlueprintTile(objData, LayerEnum.obj, x, y, xPos, yPos);
                    this.AddToBlueprintTile(bgData, LayerEnum.bg, x, y, xPos, yPos);
                    this.AddToBlueprintTile(fgData, LayerEnum.fg, x, y, xPos, yPos);
                }
            }
        }
Beispiel #4
0
        public static void ResizeHeight()
        {
            EditorRoomScene scene         = ((EditorScene)Systems.scene).CurrentRoom;
            int             currentHeight = scene.yCount;

            ConsoleTrack.possibleTabs = "Example: `resize height 180`";
            ConsoleTrack.helpText     = "Resize the level's height between " + (byte)TilemapEnum.MinHeight + " and " + (short)TilemapEnum.MaxTilesHigh + ". Currently at " + currentHeight + ".";

            // Prepare Height
            int getHeight = ConsoleTrack.GetArgAsInt();

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                if (getHeight < (byte)TilemapEnum.MinHeight)
                {
                    getHeight = (byte)TilemapEnum.MinHeight;
                }
                if (getHeight > (short)TilemapEnum.MaxTilesHigh)
                {
                    getHeight = (short)TilemapEnum.MaxTilesHigh;
                }
                scene.ResizeHeight((short)getHeight);
            }
        }
Beispiel #5
0
        public void PasteBlueprint(EditorRoomScene scene, short xStart, short yStart)
        {
            if (this.isActive == false)
            {
                return;
            }

            xStart = (short)(xStart + this.xOffset < 0 ? 0 : xStart + this.xOffset);
            yStart = (short)(yStart + this.yOffset < 0 ? 0 : yStart + this.yOffset);

            RoomFormat roomData = scene.levelContent.data.rooms[scene.roomID];

            var mainData = roomData.main;
            var objData  = roomData.obj;
            var bgData   = roomData.bg;
            var fgData   = roomData.fg;

            // Loop through the blueprint:
            for (short y = 0; y < this.blueprintHeight; y++)
            {
                for (short x = 0; x < this.blueprintWidth; x++)
                {
                    this.PasteBlueprintByLayer(scene, objData, LayerEnum.obj, x, y, xStart, yStart);
                    this.PasteBlueprintByLayer(scene, mainData, LayerEnum.main, x, y, xStart, yStart);
                    this.PasteBlueprintByLayer(scene, bgData, LayerEnum.bg, x, y, xStart, yStart);
                    this.PasteBlueprintByLayer(scene, fgData, LayerEnum.fg, x, y, xStart, yStart);
                }
            }
        }
Beispiel #6
0
        public static void ResizeWidth()
        {
            EditorRoomScene scene        = ((EditorScene)Systems.scene).CurrentRoom;
            int             currentWidth = scene.xCount;

            ConsoleTrack.possibleTabs = "Example: `resize width 250`";
            ConsoleTrack.helpText     = "Resize the level's width between " + (byte)TilemapEnum.MinWidth + " and " + (short)TilemapEnum.MaxTilesWide + ". Currently at " + currentWidth + ".";

            // Prepare Width
            int getWidth = ConsoleTrack.GetArgAsInt();

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                if (getWidth < (byte)TilemapEnum.MinWidth)
                {
                    getWidth = (byte)TilemapEnum.MinWidth;
                }
                if (getWidth > (short)TilemapEnum.MaxTilesWide)
                {
                    getWidth = (short)TilemapEnum.MaxTilesWide;
                }
                scene.ResizeWidth((short)getWidth);
            }
        }
Beispiel #7
0
        public override void RunTick(EditorRoomScene scene)
        {
            if (UIComponent.ComponentWithFocus != null)
            {
                return;
            }

            // Left Mouse Button
            if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked)
            {
                // Initialize the Wand Data for this Tile
                bool validWand = WandData.InitializeWandData(scene, Cursor.TileGridX, Cursor.TileGridY);
                if (validWand == false)
                {
                    return;
                }

                scene.scene.editorUI.moveParamMenu.LoadParamMenu();
                scene.scene.editorUI.actParamMenu.LoadParamMenu();
            }

            // Right Mouse Button (Clone Current Tile)
            else if (Cursor.RightMouseState == Cursor.MouseDownState.Clicked)
            {
                scene.CloneTile(Cursor.TileGridX, Cursor.TileGridY);
            }
        }
Beispiel #8
0
        public override void RunTick(EditorRoomScene scene)
        {
            if (UIComponent.ComponentWithFocus != null)
            {
                return;
            }

            // Left or Right Mouse Click
            if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked || Cursor.RightMouseState == Cursor.MouseDownState.Clicked)
            {
                scene.CloneTile(Cursor.TileGridX, Cursor.TileGridY);
            }
        }
Beispiel #9
0
        public static void ResizeOneScreen()
        {
            ConsoleTrack.possibleTabs = "Example: `resize one-screen`";
            ConsoleTrack.helpText     = "Resize a room to be one screen. WARNING: This will delete all tiles down to one room size.";

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                EditorRoomScene scene = ((EditorScene)Systems.scene).CurrentRoom;
                scene.ResizeHeight((byte)TilemapEnum.MinHeight);
                scene.ResizeWidth((byte)TilemapEnum.MinWidth);
            }
        }
Beispiel #10
0
        private void CutTiles(EditorRoomScene scene)
        {
            short left   = this.xStart <= this.xEnd ? this.xStart : this.xEnd;
            short top    = this.yStart <= this.yEnd ? this.yStart : this.yEnd;
            short right  = this.xStart <= this.xEnd ? this.xEnd : this.xStart;
            short bottom = this.yStart <= this.yEnd ? this.yEnd : this.yStart;

            for (short y = top; y <= bottom; y++)
            {
                for (short x = left; x <= right; x++)
                {
                    scene.DeleteTile(x, y);
                }
            }
        }
Beispiel #11
0
        public override void RunTick(EditorRoomScene scene)
        {
            if (UIComponent.ComponentWithFocus != null)
            {
                return;
            }

            // Left Mouse Button Down (Delete Current Tile)
            if (Cursor.mouseState.LeftButton == ButtonState.Pressed)
            {
                scene.DeleteTile(Cursor.TileGridX, Cursor.TileGridY);
            }

            // Right Mouse Button Clicked (Clone Current Tile)
            else if (Cursor.RightMouseState == Cursor.MouseDownState.Clicked)
            {
                scene.CloneTile(Cursor.TileGridX, Cursor.TileGridY);
            }
        }
Beispiel #12
0
        public override void RunTick(EditorRoomScene scene)
        {
            if (!this.isActive || UIComponent.ComponentWithFocus != null)
            {
                return;
            }

            // If Delete is pressed:
            if (Systems.input.LocalKeyPressed(Keys.Delete))
            {
                this.SwitchToSelectTool();
            }

            // If left-mouse clicks, start the selection:
            else if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked)
            {
                this.PasteBlueprint(scene, Cursor.TileGridX, Cursor.TileGridY);
                this.SwitchToSelectTool();
            }
        }
Beispiel #13
0
        private void RunCopyOrCut(EditorRoomScene scene, bool cut)
        {
            // Set the Blueprint FuncTool as active.
            FuncToolBlueprint bpFunc = (FuncToolBlueprint)FuncTool.funcToolMap[(byte)FuncToolEnum.Blueprint];

            EditorTools.SetFuncTool(bpFunc);

            // Handle Offsets
            sbyte xOffset = 0;
            sbyte yOffset = 0;

            short left   = this.xStart <= this.xEnd ? this.xStart : this.xEnd;
            short top    = this.yStart <= this.yEnd ? this.yStart : this.yEnd;
            short right  = this.xStart <= this.xEnd ? this.xEnd : this.xStart;
            short bottom = this.yStart <= this.yEnd ? this.yEnd : this.yStart;

            if (Cursor.TileGridX >= left && Cursor.TileGridX <= right)
            {
                xOffset = (sbyte)(left - Cursor.TileGridX);
            }
            if (Cursor.TileGridY >= top && Cursor.TileGridY <= bottom)
            {
                yOffset = (sbyte)(top - Cursor.TileGridY);
            }

            // Load Blueprint Tiles
            bpFunc.PrepareBlueprint(scene, this.xStart, this.yStart, this.xEnd, this.yEnd, xOffset, yOffset);

            // If the selection was cut, remove the tiles:
            if (cut)
            {
                this.CutTiles(scene);
            }

            this.ClearSelection();
        }
Beispiel #14
0
        public static void ResizeCustom()
        {
            int currentWidth  = ((EditorRoomScene)Systems.scene).xCount;
            int currentHeight = ((EditorRoomScene)Systems.scene).yCount;

            ConsoleTrack.possibleTabs = "Example: `resize custom 100 35`";
            ConsoleTrack.helpText     = "Resize a room to be a custom width and height (in that order). Currently at " + currentWidth + ", " + currentHeight + ".";

            // Prepare Height
            int getWidth  = ConsoleTrack.GetArgAsInt();
            int getHeight = ConsoleTrack.GetArgAsInt();

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                if (getWidth < (byte)TilemapEnum.MinWidth)
                {
                    getWidth = (byte)TilemapEnum.MinWidth;
                }
                if (getWidth > (short)TilemapEnum.MaxTilesWide)
                {
                    getWidth = (short)TilemapEnum.MaxTilesWide;
                }
                if (getHeight < (byte)TilemapEnum.MinHeight)
                {
                    getHeight = (byte)TilemapEnum.MinHeight;
                }
                if (getHeight > (short)TilemapEnum.MaxTilesHigh)
                {
                    getHeight = (short)TilemapEnum.MaxTilesHigh;
                }
                EditorRoomScene scene = ((EditorScene)Systems.scene).CurrentRoom;
                scene.ResizeHeight((short)getWidth);
                scene.ResizeWidth((short)getHeight);
            }
        }
Beispiel #15
0
        public override void RunTick(EditorRoomScene scene)
        {
            if (UIComponent.ComponentWithFocus != null)
            {
                return;
            }

            if (this.activity == SelectActivity.Working)
            {
                // If left-mouse is held down, update the selection:
                if (Cursor.LeftMouseState == Cursor.MouseDownState.HeldDown)
                {
                    this.UpdatePosition(Cursor.TileGridX, Cursor.TileGridY);
                }

                // If left-mouse is released, end the selection:
                else if (Cursor.LeftMouseState == Cursor.MouseDownState.Released)
                {
                    this.UpdatePosition(Cursor.TileGridX, Cursor.TileGridY);
                    this.EndSelection();
                }
            }

            else
            {
                // If left-mouse clicks, start the selection or drag an existing one:
                if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked)
                {
                    // Check if the mouse is within a selected area (allowing it to be dragged)
                    if (this.IsTileWithinSelection(Cursor.TileGridX, Cursor.TileGridY))
                    {
                        this.RunCopyOrCut(scene, true);
                    }
                    else
                    {
                        this.StartSelection(Cursor.TileGridX, Cursor.TileGridY);
                    }
                }
            }

            if (this.activity != SelectActivity.None)
            {
                // If Delete is pressed:
                if (Systems.input.LocalKeyPressed(Keys.Delete))
                {
                    this.CutTiles(scene);
                    this.ClearSelection();
                }

                // If Control is being held down:
                else if (Systems.input.LocalKeyDown(Keys.LeftControl) || Systems.input.LocalKeyDown(Keys.RightControl))
                {
                    // Copy + Cut
                    bool copy = Systems.input.LocalKeyPressed(Keys.C);
                    bool cut  = Systems.input.LocalKeyPressed(Keys.X);

                    if (copy || cut)
                    {
                        this.RunCopyOrCut(scene, cut);
                    }
                }
            }
        }
Beispiel #16
0
        // Initialize Wand Data
        public static bool InitializeWandData(EditorRoomScene scene, short gridX, short gridY)
        {
            // Get Scene References
            WandData.editorScene   = scene;
            WandData.moveParamMenu = WandData.editorScene.scene.editorUI.moveParamMenu;
            WandData.actParamMenu  = WandData.editorScene.scene.editorUI.actParamMenu;
            WandData.levelContent  = WandData.editorScene.levelContent;

            RoomFormat roomData = WandData.levelContent.data.rooms[WandData.editorScene.roomID];

            // Verify that Tile is Valid:
            WandData.validTile = false;

            if (LevelContent.VerifyTiles(roomData.main, gridX, gridY))
            {
                WandData.layerData = roomData.main;
                WandData.isObject  = false;
            }

            else if (LevelContent.VerifyTiles(roomData.fg, gridX, gridY))
            {
                WandData.layerData = roomData.fg;
                WandData.isObject  = false;
            }

            else if (LevelContent.VerifyTiles(roomData.obj, gridX, gridY))
            {
                WandData.layerData = roomData.obj;
                WandData.isObject  = true;
            }

            else
            {
                return(false);
            }

            WandData.validTile = true;

            WandData.gridX = gridX;
            WandData.gridY = gridY;

            // Get Tile Content Data
            WandData.wandTileData = LevelContent.GetTileDataWithParams(WandData.layerData, WandData.gridX, WandData.gridY);

            // Get the Param Set Used
            Params moveParamSet = null;
            Params actParamSet  = null;

            if (WandData.isObject)
            {
                moveParamSet = Systems.mapper.ObjectMetaData[byte.Parse(WandData.wandTileData[0].ToString())].moveParamSet;
                actParamSet  = Systems.mapper.ObjectMetaData[byte.Parse(WandData.wandTileData[0].ToString())].actParamSet;
            }
            else
            {
                TileObject wandTile = Systems.mapper.TileDict[byte.Parse(WandData.wandTileData[0].ToString())];
                moveParamSet = wandTile.moveParamSet;
                actParamSet  = wandTile.actParamSet;
            }

            // If the tile has param sets, it can be used here. Otherwise, return.
            WandData.validTile = (moveParamSet != null || actParamSet != null);
            if (WandData.validTile == false)
            {
                return(false);
            }

            WandData.moveParamSet = moveParamSet;
            WandData.actParamSet  = actParamSet;

            return(true);
        }