Пример #1
0
        public static ZStatusElement Deserialize(System.IO.BinaryReader reader)
        {
            ZStatusElement info = new ZStatusElement();

            info.LocationX          = reader.ReadByte();
            info.LocationY          = reader.ReadByte();
            info.StepX              = reader.ReadInt16();
            info.StepY              = reader.ReadInt16();
            info.Cycle              = reader.ReadInt16();
            info.Parameter1         = reader.ReadByte();
            info.Parameter2         = reader.ReadByte();
            info.Parameter3         = reader.ReadByte();
            info.Follower           = reader.ReadInt16();
            info.Leader             = reader.ReadInt16();
            info.UnderID            = reader.ReadByte();
            info.UnderColor         = reader.ReadByte();
            info.Pointer            = reader.ReadInt32();
            info.CurrentInstruction = reader.ReadInt16();
            info.InstructionsLength = reader.ReadInt16();
            reader.ReadBytes(8);

            if (info.InstructionsLength != 0)
            {
                info.CodeBlock = reader.ReadBytes(info.InstructionsLength);
            }

            return(info);
        }
Пример #2
0
        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);
        }