Exemplo n.º 1
0
 void Init()
 {
     Tiles = new Tile[TileLayers.Count][][];
     for (int l = 0; l < TileLayers.Count; l++)
     {
         Tiles[l] = new Tile[Size.Height][];
         for (int y = 0; y < Size.Height; y++)
         {
             Tiles[l][y] = new Tile[Size.Width];
             for (int x = 0; x < Size.Width; x++)
             {
                 Tiles[l][y][x] = TileLayers[l][x, y];
             }
         }
     }
     Codes = new Code[Size.Height][];
     for (int y = 0; y < Size.Height; y++)
     {
         Codes[y] = new Code[Size.Width];
         for (int x = 0; x < Size.Width; x++)
         {
             Codes[y][x] = CodeLayers[0][x, y];
         }
     }
 }
Exemplo n.º 2
0
        void paint_tile(Point p, Rectangle rect)
        {
            if (sceneMaker2D.drawingLayer < 0)
            {
                return;
            }
            if (sceneMaker2D.mxtIndex == -1)
            {
                return;
            }
            int xo, yo;
            int xoo = 0, yoo = 0;
            for (yo = 0; yo < rect.Height; yo += game.SCN.TileSizePixel.Height)
            {
                xoo = 0;
                for (xo = 0; xo < rect.Width; xo += game.SCN.TileSizePixel.Width)
                {
                    Vector3 pp = new Vector3();
                    pp.X = p.X + xo;
                    pp.Y = p.Y + yo;
                    pp.Z = 0;

                    if (pp.X < 0 || pp.Y < 0 || pp.X >= game.SCN.SizePixel.Width || pp.Y >= game.SCN.SizePixel.Height)
                    {
                        continue;
                    }

                    TileFrame tf = new TileFrame();
                    tf.TextureFileName = sceneMaker2D.mxtName;
                    tf.TextureIndex = sceneMaker2D.mxtIndex;
                    tf.DrawZone.Location = new Point(rect.X + xoo, rect.Y + yoo);
                    tf.DrawZone.Size = game.Textures[sceneMaker2D.mxtIndex].TileSize;

                    Tile tile = new Tile();
                    tile.Location = Util.Vector3DivInt(pp, game.SCN.TilePixelX);
                    tile.Frames.Add(tf);

                    int i = contains_tile(tile.Location);
                    if (i > -1)
                    {
                        bool err = false;
                        do
                        {
                            try
                            {
                                game.SCN.TileLayers[sceneMaker2D.drawingLayer].Tiles[i].Frames[sceneMaker2D.edit_frame_index] = tf;
                                err = false;
                            }
                            catch
                            {
                                game.SCN.TileLayers[sceneMaker2D.drawingLayer].Tiles[i].Frames.Add(new TileFrame());
                                err = true;
                            }
                        }
                        while (err);
                        //if (insFrame)
                        //{
                        //    game.SCN.TileLayers[sceneMaker2D.drawingLayer].Tiles[i].Frames.Add(tf);
                        //}
                        //else
                        //{
                        //    game.SCN.TileLayers[sceneMaker2D.drawingLayer].Tiles[i] = tile;
                        //}
                    }
                    else
                    {
                        game.SCN.TileLayers[sceneMaker2D.drawingLayer].Tiles.Add(tile);
                    }
                    xoo += game.Textures[sceneMaker2D.mxtIndex].TileSize.Width;
                }
                yoo += game.Textures[sceneMaker2D.mxtIndex].TileSize.Height;
            }
            ui_cursorsat.Text = "铅笔";
            pictureBox1.Cursor = bc;
            ui_tilecount.Text = game.SCN.TileLayers[sceneMaker2D.drawingLayer].Tiles.Count.ToString();
        }