ArcadeRPG.BackRender.draw_back C# (CSharp) Метод

draw_back() приватный Метод

private draw_back ( SpriteBatch tile_batch, int xpos, int ypos ) : void
tile_batch Microsoft.Xna.Framework.Graphics.SpriteBatch
xpos int
ypos int
Результат void
        internal void draw_back(SpriteBatch tile_batch, int xpos, int ypos)
        {
            locx = xpos;
            locy = ypos;
            bool at_edge = false; // is the tile located at the border of the screen? no by default

            List<int> tile_pos = get_cur_tile_pos(); //(tile x,pos x,tile y,pos y)
            List<int> tile_bound = new System.Collections.Generic.List<int>(); //(xmin,xmax,ymin,ymax)

            //from this point until the draw function call, determine where to place the tiles

            if ( (locx < 400) || (locx > (map_size_x - 400)) ) // is the tile located on the border of the screen?
            {
                at_edge = true;
                if ((locx < 400))
                {
                    tile_bound.Add(0);
                    tile_bound.Add(25);
                }
                if ((locx > (map_size_x - 400)))
                {
                    tile_bound.Add(tile_map.Count-26);
                    tile_bound.Add(tile_map.Count-1);
                }
            }
            else
            {
                tile_bound.Add(tile_pos[0] - 13);
                tile_bound.Add(tile_pos[0] + 13);
            }
            if ((locy < 240) || (locy > (map_size_y - 240)) )
            {
                at_edge = true;
                if ((locy < 240))
                {
                    tile_bound.Add(0);
                    tile_bound.Add(15);
                }
                if ((locy > (map_size_y - 240)))
                {
                    tile_bound.Add(tile_map.Count-16);
                    tile_bound.Add(tile_map.Count-1);
                }
            }
            else
            {
                tile_bound.Add(tile_pos[0] - 8);
                tile_bound.Add(tile_pos[0] + 8);
            }

            List<Rectangle> tile_spot = new List<Rectangle>();
            List<Rectangle> source = new List<Rectangle>();
            int xdisp=0;
            int ydisp=0;
            if (!at_edge)
            {
                xdisp = (tile_size / 2) - tile_pos[1];
                if (xdisp < 0)
                    xdisp += tile_size;
                ydisp = (tile_size / 2) - tile_pos[3];
                if (ydisp < 0)
                    ydisp += tile_size;
            }
            int cur_row = 0;
            int cur_col = 0;
            for (int x = tile_bound[0]; x < tile_bound[1]; x++)
                for (int y = tile_bound[2]; y < tile_bound[3]; y++)
                {
                    cur_row = tile_map[x][y] / tile_row_num;
                    cur_col = tile_map[x][y] % tile_row_num;
                    source.Add(new Rectangle(cur_row * tile_size, cur_col * tile_size, tile_size, tile_size));
                }

            if (big_small == 1) //set displacement of tiles
            {
                for (int x = -1; x < 27; x++)
                    for (int y = -1; y < 17; y++)
                    {
                        tile_spot.Add(new Rectangle((x * tile_size) - xdisp, y * tile_size, tile_size, tile_size));
                    }
            }

            for (int x=0;x<tile_spot.Count;x++)  // draw all of the tiles
            {
                tile_batch.Draw(tile, tile_spot[x], source[x], Color.White);
            }
        }