public void Deserialize(BinaryReader binaryReader)
        {
            Type         = binaryReader.ReadInt32();
            Index        = binaryReader.ReadInt32();
            _imgHead     = Context.LibData.GetImage(1, Index);
            LevelupChain = Context.LibData.GetLevelupChain(Index);

            SetWalkingSprite(new WalkingSprite(Context, Type, binaryReader.ReadInt32()));
            FightingSprite = new FightingSprite(Context, false, Index);
            Direction      = (Direction)binaryReader.ReadInt32();
            SetStep(binaryReader.ReadInt32());
            SetPosInMap(binaryReader.ReadInt32(), binaryReader.ReadInt32());

            var hasMagicChain = binaryReader.ReadBoolean();

            if (hasMagicChain)
            {
                MagicChain = new ResMagicChain(Context);
                MagicChain.Deserialize(binaryReader);
            }

            Name       = binaryReader.ReadString();
            Level      = binaryReader.ReadInt32();
            MaxHP      = binaryReader.ReadInt32();
            HP         = binaryReader.ReadInt32();
            MaxMP      = binaryReader.ReadInt32();
            MP         = binaryReader.ReadInt32();
            Attack     = binaryReader.ReadInt32();
            Defend     = binaryReader.ReadInt32();
            Speed      = binaryReader.ReadInt32();
            Lingli     = binaryReader.ReadInt32();
            Luck       = binaryReader.ReadInt32();
            CurrentExp = binaryReader.ReadInt32();

            for (int i = 0; i < 8; i++)
            {
                var type  = binaryReader.ReadInt32();
                var index = binaryReader.ReadInt32();
                if (type != 0 && index != 0)
                {
                    Equipments[i] = Context.LibData.GetGoods(type, index) as GoodsEquipment;
                }
            }
        }
        public override void SetData(byte[] buf, int offset)
        {
            Type     = buf[offset] & 0xFF;
            Index    = buf[offset + 1] & 0xFF;
            _imgHead = Context.LibData.GetImage(1, Index);
            SetWalkingSprite(new WalkingSprite(Context, Type, buf[offset + 0x16] & 0xFF));
            FightingSprite = new FightingSprite(Context, false, Index);
            Direction direction = Direction.North;

            switch (buf[offset + 2] & 0xFF)
            {
            case 1:
                direction = Direction.North;
                break;

            case 2:
                direction = Direction.East;
                break;

            case 3:
                direction = Direction.South;
                break;

            case 4:
                direction = Direction.West;
                break;
            }
            Direction = direction;
            SetStep(buf[offset + 3] & 0xff);
            SetPosInMap(buf[offset + 5] & 0xFF, buf[offset + 6] & 0xFF);
            MagicChain = Context.LibData.GetMagicChain(buf[offset + 0x17] & 0xff);
            if (MagicChain != null)
            {
                MagicChain.LearnFromChain(buf[offset + 9] & 0xff);
            }
            else
            {
                MagicChain = new ResMagicChain(Context);
            }
            Name   = buf.GetString(offset + 0x0a);
            Level  = buf[offset + 0x20] & 0xff;
            MaxHP  = buf.Get2BytesUInt(offset + 0x26);
            HP     = buf.Get2BytesUInt(offset + 0x28);
            MaxMP  = buf.Get2BytesUInt(offset + 0x2a);
            MP     = buf.Get2BytesUInt(offset + 0x2c);
            Attack = buf.Get2BytesUInt(offset + 0x2e);
            Defend = buf.Get2BytesUInt(offset + 0x30);
            Speed  = buf[offset + 0x36] & 0xff;
            Lingli = buf[offset + 0x37] & 0xff;
            Luck   = buf[offset + 0x38] & 0xff;

            CurrentExp = buf.Get2BytesUInt(offset + 0x32);

            LevelupChain = Context.LibData.GetLevelupChain(Index);

            int tmp;

            tmp = buf[offset + 0x1e] & 0xff;
            if (tmp != 0)
            {
                Equipments[0] = Context.LibData.GetGoods(6, tmp) as GoodsEquipment;
            }

            tmp = buf[offset + 0x1f] & 0xff;
            if (tmp != 0)
            {
                Equipments[1] = Context.LibData.GetGoods(6, tmp) as GoodsEquipment;
            }

            tmp = buf[offset + 0x1b] & 0xff;
            if (tmp != 0)
            {
                Equipments[2] = Context.LibData.GetGoods(5, tmp) as GoodsEquipment;
            }

            tmp = buf[offset + 0x1d] & 0xff;
            if (tmp != 0)
            {
                Equipments[3] = Context.LibData.GetGoods(3, tmp) as GoodsEquipment;
            }

            tmp = buf[offset + 0x1c] & 0xff;
            if (tmp != 0)
            {
                Equipments[4] = Context.LibData.GetGoods(7, tmp) as GoodsEquipment;
            }

            tmp = buf[offset + 0x19] & 0xff;
            if (tmp != 0)
            {
                Equipments[5] = Context.LibData.GetGoods(2, tmp) as GoodsEquipment;
            }

            tmp = buf[offset + 0x1a] & 0xff;
            if (tmp != 0)
            {
                Equipments[6] = Context.LibData.GetGoods(4, tmp) as GoodsEquipment;
            }

            tmp = buf[offset + 0x18] & 0xff;
            if (tmp != 0)
            {
                Equipments[7] = Context.LibData.GetGoods(1, tmp) as GoodsEquipment;
            }
        }