Example #1
0
        public new static DlmGraphicalElement ReadFromStream(DlmCell cell, IDataReader reader)
        {
            var element = new DlmGraphicalElement(cell);

            element.m_elementId = reader.ReadUInt();
            element.m_hue       = new ColorMultiplicator(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), false);
            element.m_shadow    = new ColorMultiplicator(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), false);

            if (cell.Layer.Map.Version <= 4)
            {
                element.m_offset.X      = reader.ReadByte();
                element.m_offset.Y      = reader.ReadByte();
                element.m_pixelOffset.X = (int)(element.m_offset.X * CELL_HALF_WIDTH);
                element.m_pixelOffset.Y = (int)(element.m_offset.Y * CELL_HALF_HEIGHT);
            }
            else
            {
                element.m_pixelOffset.X = reader.ReadShort();
                element.m_pixelOffset.Y = reader.ReadShort();
                element.m_offset.X      = (int)(element.m_pixelOffset.X / CELL_HALF_WIDTH);
                element.m_offset.Y      = (int)(element.m_pixelOffset.Y / CELL_HALF_HEIGHT);
            }

            element.m_altitude   = reader.ReadByte();
            element.m_identifier = reader.ReadUInt();

            // we don't care
            //element.CalculateFinalTeint();

            return(element);
        }
Example #2
0
        public static DlmBasicElement ReadFromStream(DlmCell cell, IDataReader reader)
        {
            var type = reader.ReadByte();

            switch ((ElementTypesEnum)type)
            {
            case ElementTypesEnum.Graphical:
                return(DlmGraphicalElement.ReadFromStream(cell, reader));

            case ElementTypesEnum.Sound:
                return(DlmSoundElement.ReadFromStream(cell, reader));

            default:
                throw new Exception("Unknown element ID : " + type + " CellID : " + cell.Id);
            }
        }