示例#1
0
        private void DrawTileLayerControls(GameTime gt, Vector2 cp)
        {
            if (MapBuilder.paintTile != default(BasicTile) && MapBuilder.bAllowEditing)
            {
                refMB.PaintLogic(cp);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Tab) && !Keyboard.GetState().IsKeyDown(Keys.LeftShift) && !KeyboardMouseUtility.AnyButtonsPressed())
            {
                switch (tileType)
                {
                case tileLayerType.normal:
                    tileType = tileLayerType.smartBrush;
                    break;

                case tileLayerType.smartBrush:
                    tileType = tileLayerType.normal;
                    break;
                }
            }

            switch (tileType)
            {
            case tileLayerType.normal:
                if (MapBuilder.paintTile != default(BasicTile))
                {
                    if (Keyboard.GetState().IsKeyDown(Keys.F) && MapBuilder.paintTile.HasDifferentSizeSource() && !Keyboard.GetState().IsKeyDown(Keys.LeftShift) && !KeyboardMouseUtility.AnyButtonsPressed())
                    {
                        if (MapBuilder.paintTile.drawSize == new Point(64))
                        {
                            MapBuilder.paintTile.drawSize = MapBuilder.paintTile.tileSource.tileAnimation.AnimSourceSize();
                        }
                        else
                        {
                            MapBuilder.paintTile.drawSize = new Point(64);
                        }
                    }

                    if (Keyboard.GetState().IsKeyDown(Keys.Space) && !KeyboardMouseUtility.AnyButtonsPressed())
                    {
                        MapBuilder.paintTile.offset = Point.Zero;
                    }

                    var t       = MapBuilder.paintTile.offset;
                    var tSource = MapBuilder.paintTile;
                    if (Keyboard.GetState().IsKeyDown(Keys.LeftShift))
                    {
                        if (Keyboard.GetState().IsKeyDown(Keys.Up) && t.Y > -tSource.drawSize.Y && !KeyboardMouseUtility.AnyButtonsPressed())
                        {
                            t.Y--;
                        }

                        if (Keyboard.GetState().IsKeyDown(Keys.Down) && t.Y < 64 && !KeyboardMouseUtility.AnyButtonsPressed())
                        {
                            t.Y++;
                        }

                        if (Keyboard.GetState().IsKeyDown(Keys.Left) && t.X > -tSource.drawSize.X && !KeyboardMouseUtility.AnyButtonsPressed())
                        {
                            t.X--;
                        }

                        if (Keyboard.GetState().IsKeyDown(Keys.Right) && t.X < 64 && !KeyboardMouseUtility.AnyButtonsPressed())
                        {
                            t.X++;
                        }
                    }
                    else if (!Keyboard.GetState().IsKeyDown(Keys.LeftShift))
                    {
                        if (Keyboard.GetState().IsKeyDown(Keys.Up) && t.Y > -tSource.drawSize.Y)
                        {
                            t.Y--;
                        }

                        if (Keyboard.GetState().IsKeyDown(Keys.Down) && t.Y < 64)
                        {
                            t.Y++;
                        }

                        if (Keyboard.GetState().IsKeyDown(Keys.Left) && t.X > -tSource.drawSize.X)
                        {
                            t.X--;
                        }

                        if (Keyboard.GetState().IsKeyDown(Keys.Right) && t.X < 64)
                        {
                            t.X++;
                        }
                    }

                    MapBuilder.paintTile.offset = t;
                }

                break;

            case tileLayerType.smartBrush:
                if (Keyboard.GetState().IsKeyDown(Keys.L) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    MapBuilder.memoryBrush.bLearnFromAllLayers = !MapBuilder.memoryBrush.bLearnFromAllLayers;
                }
                break;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.R) && !KeyboardMouseUtility.AnyButtonsPressed())
            {
                MapBuilder.paintTile.rotation++;
                if ((int)MapBuilder.paintTile.rotation >= Enum.GetNames(typeof(BasicTile.Rotation)).Length)
                {
                    MapBuilder.paintTile.rotation = 0;
                }
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Add) && !Keyboard.GetState().IsKeyDown(Keys.LeftShift) && !KeyboardMouseUtility.AnyButtonsPressed())
            {
                MapBuilder.brushSize++;
                MapBuilder.CalculateBrushSize();
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Subtract) && !Keyboard.GetState().IsKeyDown(Keys.LeftShift) && !KeyboardMouseUtility.AnyButtonsPressed())
            {
                if (MapBuilder.brushSize > 1)
                {
                    MapBuilder.brushSize--;
                    MapBuilder.CalculateBrushSize();
                }
            }
        }