Пример #1
0
        private void sbSave_Click(object sender, EventArgs e)
        {
            if (teLocation.Text.Equals(string.Empty))
            {
                XtraMessageBox.Show("Set 'Location' to save result first", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
            }
            var saveInfo = new InfoSave()
            {
                OptionSave   = leSaveOptions.EditValue.ToString(),
                Location     = teLocation.Text,
                ProxyPort    = Convert.ToInt32(sePort.Value),
                TimeOutProxy = Convert.ToInt32(seTimeOut.Value),
                AutoExit     = Convert.ToInt32(seAutoExitTool.Value),
            };
            var json = JsonConvert.SerializeObject(saveInfo);

            File.WriteAllText(saveFilePath, json);
            XtraMessageBox.Show("Saved !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Пример #2
0
            public static World Deserialize(InfoSave worldInfoSave, string path)
            {
                WorldSave worldSave = Serializer.Deserialize <WorldSave>(path + "worlds/" + worldInfoSave.name + "/world.dat");

                World world = new World(worldInfoSave.name, worldInfoSave.seed, worldInfoSave.sizeX, worldInfoSave.sizeY, worldInfoSave.sizeZ);

                int index = 0;

                if (worldSave.blocks != null)
                {
                    for (int x = 0; x < world.sizeX; x++)
                    {
                        for (int y = 0; y < world.sizeY; y++)
                        {
                            for (int z = 0; z < world.sizeZ; z++)
                            {
                                world.block[x, y, z] = worldSave.blocks[index];
                                index++;
                            }
                        }
                    }
                }

                for (int y = 0; y < world.sizeY; y++)
                {
                    world.slices.Add(new Slice(0, 0, y));
                }
                if (worldSave.items != null)
                {
                    for (int i = 0; i < worldSave.items.Length; i++)
                    {
                        new Mobs.ItemEntity(world, worldSave.items[i].item, worldSave.items[i].x, worldSave.items[i].y, worldSave.items[i].z).liveTime = worldSave.items[i].t;
                    }
                }

                return(world);
            }