Пример #1
0
        public void ReadMetaFile()
        {
            if (reader == null)
                throw new NullReferenceException("BinaryReader null!");

            metaFile = new Minecraft2DMeta();

            int count = 0;
            while(count < 2) //two lines atm
            {
                switch(count)
                {
                    case 0: //World Size
                        string worldSizeInput = reader.ReadString();
                        string[] split = worldSizeInput.Split(new char[] { 'x' }, 2);
                        metaFile.WorldSize = new Vector2i(int.Parse(split[0]) * 32, int.Parse(split[1]) * 32);
                        metaFile.WorldSizeInBlocks = new Vector2i(int.Parse(split[0]), int.Parse(split[1]));
                        break;
                    case 1: //World name
                        string worldNameInput = reader.ReadString();
                        metaFile.WorldName = worldNameInput.Trim('\"');
                        break;
                    case 2: //Player save position
                        string playerPositionInput = reader.ReadString();
                        string[] split2 = playerPositionInput.Split(new char[] { ',' }, 2);
                        metaFile.PlayerLocation = new Vector2(float.Parse(split2[0]), float.Parse(split2[1]));
                        break;
                }

                count++;
            }
        }
Пример #2
0
        public WorldObjects(World wld)
        {
            MetaFile = new Minecraft2DMeta();

            MetaFile.WorldSize = new Vector2i(100 * 32, 256 * 32);
            MetaFile.WorldSizeInBlocks = new Vector2i(100, 256);
            ForegroundLayerTiles = new Tile[MetaFile.WorldSizeInBlocks.Y, MetaFile.WorldSizeInBlocks.X];
            BackgroundLayerTiles = new Tile[MetaFile.WorldSizeInBlocks.Y, MetaFile.WorldSizeInBlocks.X];
            Lightmap = new int[MetaFile.WorldSizeInBlocks.Y, MetaFile.WorldSizeInBlocks.X];
            MetaFile.WorldName = "World1";

            _worldRef = wld;
            WorldIndex = 0;
        }
Пример #3
0
 public BinaryMetaWriter(string path, Minecraft2DMeta meta)
 {
     if(File.Exists(path))
     {
         try
         {
             File.Delete(path);
         }
         catch (Exception ex)
         {
             Console.WriteLine("Error writing meta binary: " + ex.Message);
         }
     }
     writer = new BinaryWriter(File.Open(path, FileMode.CreateNew));
     metaFile = meta;
 }
Пример #4
0
 public BinarySaveReader(string path, Minecraft2DMeta meta, bool bg = false)
 {
     reader = new BinaryReader(File.Open(path, FileMode.Open));
     isBg = bg;
     metaFile = meta;
 }