Пример #1
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            lbxTilesetFiles.ClearSelected();

            var tileset = new Tileset
            {
                Name = "NewTileset",
            };

            Tilesets.Add(tileset);

            LoadTilesets();
            Editor.LoadTilesetList();

            lbxTilesets.SelectedIndex = Tilesets.IndexOf(tileset);
        }
        public void InitializeTileSet(Tileset tileset)
        {
            Tileset = tileset;

            if (Tileset != null && Tileset.TextureMap != null)
            {
                if (Tileset.TileSize > 0 && Tileset.Columns > 0)
                {
                    Columns = Tileset.Columns;
                    //TexturePreviewMatrix = new MapMatrix();
                    //TexturePreviewMatrix.Size = new Vector2(Tileset.TileSize, Tileset.TileSize);
                    //TexturePreviewMatrix.Width = Columns;
                    //TexturePreviewMatrix.Height = (int) Math.Ceiling((decimal) (Tileset.TextureMap.Height/TexturePreviewMatrix.Size.Y));
                    //LotusGameMaker.CurrentTileset.TextureMap.Height;
                }
            }
        }
Пример #3
0
        public void Draw(SpriteBatch spriteBatch, Tileset testTileSet, bool onlyDrawVisible, LayerDraw layerDraw, int focusLayer = -1)
        {
            Vector2 min;
            Vector2 max;

            if (onlyDrawVisible)
            {
                min = MapHelper.GetTileFromPixels(Camera.Position);
                max = MapHelper.GetTileFromPixels(
                    new Vector2(
                        Camera.Position.X + spriteBatch.GraphicsDevice.Viewport.Width + MapHelper.TileSize,
                        Camera.Position.Y + spriteBatch.GraphicsDevice.Viewport.Height + MapHelper.TileSize));
            }
            else
            {
                min = Vector2.Zero;
                max = new Vector2(
                    Width,
                    Height);
            }

            var layers = new List<MapLayer>();

            switch (layerDraw)
            {
                case LayerDraw.All:
                    layers = Layers;
                    break;
                case LayerDraw.Upper:
                    layers = Layers.FindAll(x => x.UpperLayer);
                    break;
                case LayerDraw.Lower:
                    layers = Layers.FindAll(x => !x.UpperLayer);
                    break;
            }

            Color color;
            for (int i = 0; i < layers.Count; i++)
            {
                if (focusLayer == -1)
                    color = Color.White;
                else
                {
                    if (focusLayer == i)
                        color = Color.White;
                    else
                        color = new Color(100, 100, 100, 100);
                }
                layers[i].Draw(spriteBatch, min, max, testTileSet, color, color.A);
            }
        }
Пример #4
0
        public void Draw(SpriteBatch batch, Vector2 min, Vector2 max, Tileset tileset, Color color, int opacity)
        {
            Opacity = opacity;

            min.X = (int) MathHelper.Max(min.X, 0);
            min.Y = (int) MathHelper.Max(min.Y, 0);
            max.X = (int) MathHelper.Min(max.X, Width);
            max.Y = (int) MathHelper.Min(max.Y, Height);

            for (var x = (int) min.X; x < max.X; x++)
            {
                for (var y = (int) min.Y; y < max.Y; y++)
                {
                    int textureId = Map[y, x];

                    if (textureId != -1 && tileset != null)
                    {
                        //Vector2 offset = Vector2.Zero;
                        Vector2 offset = new Vector2(1, 1);

                        batch.Draw(
                            tileset.TextureMap,
                            new Rectangle(
                                x*MapHelper.TileSize,
                                y*MapHelper.TileSize,
                                (int) (MapHelper.TileSize + offset.X),
                                (int) (MapHelper.TileSize + offset.Y)),
                            tileset.GetRectForTexture(textureId),
                            new Color(color.R, color.G, color.B, opacity));
                    }
                }
            }
        }
Пример #5
0
        private void lbxTilesets_SelectedIndexChanged(object sender, EventArgs e)
        {
            ClearFields();

            if (lbxTilesets.SelectedIndex != -1)
            {
                currentTileset = Tilesets[lbxTilesets.SelectedIndex];

                if (currentTileset != null)
                {
                    lbxTilesetFiles.Enabled = true;

                    txtName.Text = currentTileset.Name;
                    txtColumns.Text = currentTileset.Columns.ToString();
                    txtSize.Text = currentTileset.TileSize.ToString();

                    if (!string.IsNullOrEmpty(currentTileset.Filename))
                    {
                        lbxTilesetFiles.SelectedItem = currentTileset.Filename;
                    }
                }
            }
        }