Example #1
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int yoffset = 50;

            if (paintIt)
            {
                // Just so I can get a good visual on it going to precaculate the numbers
                int xStride = rXmax;
                int zStride = xStride * rYmax;

                // Precaculate the last line in a floor and the last floor
                int zLast = rData.Length - zStride;
                int yLast = zStride - xStride;

                int bmpWidth  = rXmax * (20 + 2); // With of the square + 2 for the lin left and rigg
                int bmpLength = rYmax * (20 + 2);

                e.Graphics.Clear(Color.White);
                for (int i = 0; i < rBlocks.Length; i++)
                {
                    redstoneObj temp = rGrid[i];
                    if (temp.Z == currentZ)
                    {
                        e.Graphics.DrawImage(temp.getBitmap(rData[i]), temp.X * 20, temp.Y * 20 + yoffset);
                        e.Graphics.DrawRectangle(Pens.Black, temp.X * 20, temp.Y * 20 + yoffset, 20, 20);
                    }
                }
            }
        }
Example #2
0
        private Bitmap CreateGrid(int zLevel)
        {
            // Just so I can get a good visual on it going to precaculate the numbers
            int xStride = rXmax;
            int zStride = xStride * rYmax;

            int      bmpWidth  = rXmax * 20; // With of the square + 2 for the lin left and rigg
            int      bmpLength = rYmax * 20;
            Bitmap   buffer    = new Bitmap(bmpWidth, bmpLength, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics g         = Graphics.FromImage(buffer);

            g.Clear(Color.White);

            for (int i = 0; i < rBlocks.Length; i++)
            {
                redstoneObj temp = rGrid[i];
                if (temp.Z == zLevel)
                {
                    g.DrawImage(temp.getBitmap(rData[i]), temp.X * 20, temp.Y * 20);

                    int nZ = zLevel + 1 > rZmax ? rZmax : zLevel + 1;
                    //      if (rGrid[i + zStride].bType == blockType.RedstoneWire)
                    //        g.DrawImage(rGrid[i + zStride].getBitmap(rData[i + zStride]), temp.X * 20, temp.Y * 20);
                    g.DrawRectangle(Pens.Black, temp.X * 20, temp.Y * 20, 20, 20);
                }
            }
            return(buffer);
        }
Example #3
0
        private void AssertNbtBigFile(NbtFile file)
        {
            // NbtList enities;
            //NbtList tileenities;

            // See TestFiles/bigtest.nbt.txt to see the expected format


            NbtCompound root = file.RootTag;

            if (root.Name == "Schematic")
            {
                redBmp = new redstoneBmp();
                // I don't know why but I keep getting cofused with the height, width, length stuff
                // maybe its because I deal with to many 2d objects.
                rYmax      = root.Query <NbtShort>("/Schematic/Width").Value;
                rZmax      = root.Query <NbtShort>("/Schematic/Height").Value;
                rXmax      = root.Query <NbtShort>("/Schematic/Length").Value;
                rMaterials = root.Query <NbtString>("/Schematic/Materials").Value;
                rBlocks    = root.Query <NbtByteArray>("/Schematic/Blocks").Value;
                rData      = root.Query <NbtByteArray>("/Schematic/Data").Value;
                rGrid      = new redstoneObj[rBlocks.Length];

                // Ok, lets get this link list a starting
                for (int i = 0; i < rBlocks.Length; i++)
                {
                    // Put the normal code here to fill the data for the blocks, and data
                    // skipping for now as its more important to get the link list working
                }

                // Just so I can get a good visual on it going to precaculate the numbers
                int xStride = rXmax;
                int zStride = xStride * rYmax;

                // Precaculate the last line in a floor and the last floor
                int zLast = rData.Length - zStride;
                int yLast = zStride - xStride;

                // Lets try something diffrent and do all bounds checking

                for (int i = 0; i < rBlocks.Length; i++)
                {
                    int z = i / zStride;
                    int y = (i - z * zStride) / xStride;
                    int x = i - (y * xStride) - (z * zStride);
                    rGrid[i]   = new redstoneObj(redBmp.getSet(rBlocks[i]));
                    rGrid[i].X = x; rGrid[i].Y = y; rGrid[i].Z = z;
                }
            }
        }
Example #4
0
        private void AssertNbtBigFile(NbtFile file)
        {
            // NbtList enities;
            //NbtList tileenities;

            // See TestFiles/bigtest.nbt.txt to see the expected format

            NbtCompound root = file.RootTag;
            if (root.Name == "Schematic")
            {
                redBmp = new redstoneBmp();
                // I don't know why but I keep getting cofused with the height, width, length stuff
                // maybe its because I deal with to many 2d objects.
                rYmax = root.Query<NbtShort>("/Schematic/Width").Value;
                rZmax = root.Query<NbtShort>("/Schematic/Height").Value;
                rXmax = root.Query<NbtShort>("/Schematic/Length").Value;
                rMaterials = root.Query<NbtString>("/Schematic/Materials").Value;
                rBlocks = root.Query<NbtByteArray>("/Schematic/Blocks").Value;
                rData = root.Query<NbtByteArray>("/Schematic/Data").Value;
                rGrid = new redstoneObj[rBlocks.Length];

                // Ok, lets get this link list a starting
                for (int i = 0; i < rBlocks.Length; i++)
                {
                    // Put the normal code here to fill the data for the blocks, and data
                    // skipping for now as its more important to get the link list working
                }

                // Just so I can get a good visual on it going to precaculate the numbers
                int xStride = rXmax;
                int zStride = xStride * rYmax;

                // Precaculate the last line in a floor and the last floor
                int zLast = rData.Length - zStride;
                int yLast = zStride - xStride;

                // Lets try something diffrent and do all bounds checking

                for (int i = 0; i < rBlocks.Length; i++)
                {

                    int z =  i/zStride;
                    int y = (i - z * zStride)/xStride;
                    int x = i - (y * xStride) - (z * zStride);
                    rGrid[i] = new redstoneObj(redBmp.getSet(rBlocks[i]));
                    rGrid[i].X = x; rGrid[i].Y = y; rGrid[i].Z = z;
                }
            }
        }