示例#1
0
        private bool CheckExists(string type)
        {
            if (!Brushes.ContainsKey(type))
            {
                System.Windows.MessageBox.Show("笔刷不存在!", "提示");
                return(false);
            }

            return(true);
        }
示例#2
0
        public void AddBrush(Brush brush)
        {
            string key = brush.Type.ToString();

            if (Brushes.ContainsKey(key))
            {
                System.Windows.MessageBox.Show("已存在该类型的笔刷!", "提示");
                return;
            }

            Brushes.Add(key, brush);

            isModified = true;

            OnBrushModified?.Invoke();
        }
示例#3
0
        public Tuple <Rectangle, Rectangle> AddTile(int x, int y, double z, string brush)
        {
            // Plz dont crash
            if (Width == 0 || Height == 0 || !Brushes.ContainsKey(brush))
            {
                y = (int)InvertHeight(y);
                Rectangle rekt = null;
                if (!Brushes.ContainsKey(brush))
                {
                    Point3D point3D = new Point3D(x, y, z);
                    if (Tiles.ContainsKey(point3D))
                    {
                        rekt = Tiles[point3D];
                        Tiles.Remove(point3D);
                    }
                }
                return(new Tuple <Rectangle, Rectangle>(null, rekt));
            }

            Rectangle rectangle = new Rectangle
            {
                Fill   = Brushes[brush].Clone(),
                Width  = TileSize,
                Height = TileSize
            };

            rectangle.SetCurrentValue(Canvas.ZIndexProperty, GameToCanvasZ((float)z));
            rectangle.RenderTransform = new TranslateTransform(x * TileSize, y * TileSize);

            Rectangle r   = null;
            Point3D   pos = new Point3D(x, (int)InvertHeight((float)y), z);

            if (Tiles.ContainsKey(pos))
            {
                r = Tiles[pos];
                Tiles.Remove(pos);
            }
            Tiles.Add(pos, rectangle);

            return(new Tuple <Rectangle, Rectangle>(rectangle, r));
        }
示例#4
0
        public Rectangle EntityRectangle(Entity entity)
        {
            Rectangle rectangle = new Rectangle()
            {
                Width  = TileSize,
                Height = TileSize,
                Stroke = new SolidColorBrush()
                {
                    Color = entity.player ? Colors.Orange : Colors.White, Opacity = 1.0
                }
            };

            rectangle.SetCurrentValue(Canvas.ZIndexProperty, GameToCanvasZ(entity.z));
            rectangle.RenderTransform = new TranslateTransform(entity.x * TileSize, InvertHeight(entity.y) * TileSize);
            if (Brushes.ContainsKey(entity.sprite))
            {
                rectangle.Fill = Brushes[entity.sprite].Clone();
            }

            return(rectangle);
        }