Example #1
0
        void Open_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
        {
            OpenFileDialog open = sender as OpenFileDialog;
            var            data = FileHelper.ReadFromFile(open.FileName);
            var            map  = FileHelper.DeserializeFromBinary <Map>(data);

            map.data = MergeArray.ToBoolArray(map.sdata);

            gridWidthSlider.Value  = map.tilewidth;
            gridHeightSlider.Value = map.tileheight;

            AddGrid();

            int height = Matrix.GetUpperBound(0) + 1;
            int width  = Matrix.GetUpperBound(1) + 1;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    if (map.data[y * width + x] == map.obstruct)
                    {
                        SetMatrixGrid(x, y, 0);
                    }
                    else
                    {
                        Matrix[y, x] = 1;
                    }
                }
            }
        }
Example #2
0
        private void Output(string savepath)
        {
            Map map = ToMap();

            map.sdata = MergeArray.ToByteArray(map.data);

            var buf = FileHelper.SerializeToBinary(map);

            FileHelper.WriteToFile(savepath, buf, 0, buf.Length);
            MessageBox.Show("导出成功!");
        }
Example #3
0
        public void MergeTest()
        {
            int[] nums1 = new int[] { 1, 2, 3, 0, 0, 0 };
            int   m     = 3;

            int[]      nums2 = new int[] { 2, 5, 6 };
            int        n     = 3;
            MergeArray ma    = new MergeArray();

            ma.Merge(nums1, m, nums2, n);
            Assert.Fail();
        }