コード例 #1
0
ファイル: ZBoard.cs プロジェクト: AnotherEpigone/SadConsole
        public static ZBoard Deserialize(System.IO.BinaryReader reader)
        {
            ZBoard info = new ZBoard();

            info.BoardSize = reader.ReadInt16();
            info.BoardName = reader.ReadString();
            reader.ReadBytes(50 - info.BoardName.Length);

            List <byte[]> bytes       = new List <byte[]>(10);
            int           tileCounter = 0;

            do
            {
                byte[] byteData;
                byteData = reader.ReadBytes(3);
                if (byteData[0] == 0)
                {
                    tileCounter += 256;
                }
                else
                {
                    tileCounter += byteData[0];
                }
                bytes.Add(byteData);
            } while (tileCounter != 1500);
            info.BoardData = bytes.ToArray();

            info.MaxPlayerShots = reader.ReadByte();
            info.IsDark         = reader.ReadByte();
            info.ExitNorth      = reader.ReadByte();
            info.ExitSouth      = reader.ReadByte();
            info.ExitWest       = reader.ReadByte();
            info.ExitEast       = reader.ReadByte();
            info.RestartOnZap   = reader.ReadByte();
            info.Message        = reader.ReadString();
            reader.ReadBytes(58 - info.Message.Length);
            info.PlayerEnterX = reader.ReadByte();
            info.PlayerEnterY = reader.ReadByte();
            info.Timelimit    = reader.ReadInt16();
            reader.ReadBytes(16);
            info.StatElementCount = reader.ReadInt16();

            info.Player = ZStatusElement.Deserialize(reader);

            List <ZStatusElement> elements = new List <ZStatusElement>(info.StatElementCount);

            for (int i = 0; i < info.StatElementCount; i++)
            {
                elements.Add(ZStatusElement.Deserialize(reader));
            }
            info.Elements = elements.ToArray();

            return(info);
        }
コード例 #2
0
ファイル: ZWorld.cs プロジェクト: AnotherEpigone/SadConsole
        public static ZWorld Load(System.IO.Stream fileStream)
        {
            using (System.IO.BinaryReader binreader = new System.IO.BinaryReader(fileStream))
            {
                ZWorldStatus worldStatus = ZWorldStatus.Deserialize(binreader);
                ZWorld       world       = Deserialize(binreader);

                fileStream.Position = 512;

                var boards = new List <ZBoard>(worldStatus.BoardCount + 1);
                for (int i = 0; i < worldStatus.BoardCount + 1; i++)
                {
                    boards.Add(ZBoard.Deserialize(binreader));
                }

                world.Status = worldStatus;
                world.Boards = boards.ToArray();

                return(world);
            }
        }