Esempio n. 1
0
        // BRUSHES FUNCTIONS
        private void MarqueeTerrain(object sender, MouseEventArgs e, MarqueeData marqueeData)
        {
            // Note:
            // MarqueeWidth and MarqueeHeight values are expressed in tile numbers

            XNA.Point selected_tile = HelperClass.TileSnapToGrid(Camera.WorldPosition(e.Location));
            Tile tile_in_map = GLB_Data.TileMap[0, selected_tile.X, selected_tile.Y];

            if (selected_tile == tile_in_map.grid_location)
            {
                TerrainType selected_terrain = (TerrainType)toolbar_terrain_combo.SelectedItem;
                // Paint the marquee selection
                for (int id_y = 0; id_y < GLB_Data.MarqueeSelection.Height; id_y++)
                {
                    for (int id_x = 0; id_x < GLB_Data.MarqueeSelection.Width; id_x++)
                    {
                        int sel_tiles_x = id_x % (GLB_Data.SelectedTiles.GetLength(0));
                        int sel_tiles_y = id_y % (GLB_Data.SelectedTiles.GetLength(1));

                        int offset_x = GLB_Data.MarqueeSelection.InitialTile.X + id_x;
                        int offset_y = GLB_Data.MarqueeSelection.InitialTile.Y + id_y;

                        if (GLB_Data.TerrainLayout[offset_x, offset_y] == selected_terrain.Id)
                        {
                            GLB_Data.TerrainLayout[offset_x, offset_y] = Constants.TERRAIN_NORMAL;
                        }
                        else
                        {
                            GLB_Data.TerrainLayout[offset_x, offset_y] = selected_terrain.Id;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void MarqueeWalk(object sender, MouseEventArgs e, MarqueeData marqueeData)
        {
            // Note:
            // MarqueeWidth and MarqueeHeight values are expressed in tile numbers

            XNA.Point selected_tile = HelperClass.TileSnapToGrid(Camera.WorldPosition(e.Location));
            Tile tile_in_map = GLB_Data.TileMap[0, selected_tile.X, selected_tile.Y];

            int walk_layer = GetWalkLayer();

            if (selected_tile == tile_in_map.grid_location)
            {
                // Paint the marquee selection
                for (int id_y = 0; id_y < GLB_Data.MarqueeSelection.Height; id_y++)
                {
                    for (int id_x = 0; id_x < GLB_Data.MarqueeSelection.Width; id_x++)
                    {
                        int sel_tiles_x = id_x % (GLB_Data.SelectedTiles.GetLength(0));
                        int sel_tiles_y = id_y % (GLB_Data.SelectedTiles.GetLength(1));

                        int offset_x = GLB_Data.MarqueeSelection.InitialTile.X + id_x;
                        int offset_y = GLB_Data.MarqueeSelection.InitialTile.Y + id_y;

                        if (GLB_Data.TileMap[GetWalkLayer(), offset_x, offset_y].walkable == true)
                        {
                            GLB_Data.TileMap[GetWalkLayer(), offset_x, offset_y].walkable = false;
                        }
                        else
                        {
                            GLB_Data.TileMap[GetWalkLayer(), offset_x, offset_y].walkable = true;
                        }

                        if ((Control.ModifierKeys & System.Windows.Forms.Keys.Shift) != 0)
                            GLB_Data.TileMap[walk_layer, selected_tile.X, selected_tile.Y].terrain_type = 2;
                        else
                            GLB_Data.TileMap[walk_layer, selected_tile.X, selected_tile.Y].terrain_type = 0;
                    }
                }
            }
        }
Esempio n. 3
0
        private void MarqueePaint(object sender, MouseEventArgs e, MarqueeData Selection)
        {
            // Note:
            // MarqueeWidth and MarqueeHeight values are expressed in tile numbers

            XNA.Point selected_tile = HelperClass.TileSnapToGrid(Camera.WorldPosition(e.Location));
            Tile tile_in_map = GLB_Data.TileMap[0, selected_tile.X, selected_tile.Y];

            if (selected_tile == tile_in_map.grid_location)
            {
                if (selected_tile == tile_in_map.grid_location)
                {
                    // Paint the marquee selection
                    for (int id_y = 0; id_y < GLB_Data.MarqueeSelection.Height; id_y++)
                    {
                        for (int id_x = 0; id_x < GLB_Data.MarqueeSelection.Width; id_x++)
                        {
                            int sel_tiles_x = id_x % (GLB_Data.SelectedTiles.GetLength(0));
                            int sel_tiles_y = id_y % (GLB_Data.SelectedTiles.GetLength(1));

                            int offset_x = GLB_Data.MarqueeSelection.InitialTile.X + id_x;
                            int offset_y = GLB_Data.MarqueeSelection.InitialTile.Y + id_y;

                            GLB_Data.TileMap[GLB_Data.SelectedLayer, offset_x, offset_y].id = GLB_Data.SelectedTiles[sel_tiles_x, sel_tiles_y].id;
                            GLB_Data.TileMap[GLB_Data.SelectedLayer, offset_x, offset_y].texture_location = GLB_Data.SelectedTiles[sel_tiles_x, sel_tiles_y].grid_location;
                            GLB_Data.TileMap[GetWalkLayer(), offset_x, offset_y].walkable = GLB_Data.SelectedTiles[sel_tiles_x, sel_tiles_y].walkable;
                        }
                    }
                }
            }
        }