Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new <see cref="DyoFile"/> instance.
        /// </summary>
        /// <param name="dyoFilePath">Dyo file path</param>
        public DyoFile(string dyoFilePath)
            : base(dyoFilePath, FileMode.Open, FileAccess.Read)
        {
            this._elements = new List <DyoElement>();
            var memoryReader = new BinaryReader(this);

            while (true)
            {
                DyoElement rgnElement = null;
                int        type       = memoryReader.ReadInt32();

                if (type == -1)
                {
                    break;
                }

                if (type == 5)
                {
                    rgnElement = new NpcDyoElement();
                    rgnElement.Read(memoryReader);
                }

                if (rgnElement != null)
                {
                    this._elements.Add(rgnElement);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="DyoFile"/> instance.
        /// </summary>
        /// <param name="dyoFilePath">Dyo file path</param>
        public DyoFile(string dyoFilePath)
            : base(dyoFilePath, FileMode.Open, FileAccess.Read)
        {
            _elements = new List <DyoElement>();
            var memoryReader = new BinaryReader(this);

            while (memoryReader.BaseStream.Position < memoryReader.BaseStream.Length)
            {
                DyoElement rgnElement = null;
                uint       type       = memoryReader.ReadUInt32();

                switch (type)
                {
                case (int)WorldObjectType.Control:
                    rgnElement = new CommonControlDyoElement();
                    break;

                case (int)WorldObjectType.Mover:
                    rgnElement = new NpcDyoElement();
                    break;

                case (int)WorldObjectType.Object:
                case (int)WorldObjectType.Item:
                case (int)WorldObjectType.Ship:
                    rgnElement = new DyoElement();
                    break;
                }

                if (rgnElement == null)
                {
                    break;
                }

                rgnElement.ElementType = (int)type;
                rgnElement.Read(memoryReader);
                _elements.Add(rgnElement);
            }
        }