当前位置: 首页>>代码示例>>C#>>正文


C# IValueReader.ReadNode方法代码示例

本文整理汇总了C#中IValueReader.ReadNode方法的典型用法代码示例。如果您正苦于以下问题:C# IValueReader.ReadNode方法的具体用法?C# IValueReader.ReadNode怎么用?C# IValueReader.ReadNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IValueReader的用法示例。


在下文中一共展示了IValueReader.ReadNode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StationaryGrhData

        /// <summary>
        /// Initializes a new instance of the <see cref="StationaryGrhData"/> class.
        /// </summary>
        /// <param name="r">The <see cref="IValueReader"/>.</param>
        /// <param name="cm">The <see cref="IContentManager"/>.</param>
        /// <param name="grhIndex">The <see cref="GrhIndex"/>.</param>
        /// <param name="cat">The <see cref="SpriteCategorization"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="cat"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="grhIndex"/> is equal to GrhIndex.Invalid.</exception>
        StationaryGrhData(IValueReader r, IContentManager cm, GrhIndex grhIndex, SpriteCategorization cat) : base(grhIndex, cat)
        {
            _cm = cm;

            var automaticSize = r.ReadBool(_automaticSizeValueKey);
            var textureReader = r.ReadNode(_textureNodeName);
            var textureName = textureReader.ReadTextureAssetName(_textureNameValueKey);
            var textureSource = textureReader.ReadRectangle(_textureSourceValueKey);

            _textureName = textureName;
            SetSourceRect(textureSource);
            _automaticSize = automaticSize;
        }
开发者ID:Furt,项目名称:netgore,代码行数:22,代码来源:StationaryGrhData.cs

示例2: LoadLighting

        void LoadLighting(IValueReader reader)
        {
            reader = reader.ReadNode(_lightingNodeName);

            AmbientLight = reader.ReadColor("Ambient");

            _lights.Clear();

            var loadedLights = reader.ReadManyNodes(_lightsNodeName, x => new Light(x));
            _lights.AddRange(loadedLights);

            foreach (var light in loadedLights)
            {
                light.Tag = this;
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:16,代码来源:Map.cs

示例3: LoadRefractionEffects

        void LoadRefractionEffects(IValueReader reader)
        {
            reader = reader.ReadNode(_refractionEffectsNodeName);

            _refractionEffects.Clear();

            var loadedFx = reader.ReadManyNodes(_refractionEffectListNodeName, RefractionEffectFactory.Read);

            _refractionEffects.AddRange(loadedFx);

            foreach (var fx in loadedFx)
            {
                fx.Tag = this;
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:15,代码来源:Map.cs

示例4: Read

        /// <summary>
        /// Reads a <see cref="ParticleModifier"/> from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
        /// <returns>The <see cref="ParticleModifier"/> instance created from the values read from the
        /// <paramref name="reader"/>.</returns>
        /// <exception cref="ParticleEmitterLoadParticleModifierException">The <see cref="ParticleModifier"/> could not be loaded.</exception>
        public static ParticleModifier Read(IValueReader reader)
        {
            // Get the type
            var typeName = reader.ReadString(_typeKeyName).Trim();

            // Create the instance
            ParticleModifier modifier;
            try
            {
                modifier = (ParticleModifier)_typeFactory.GetTypeInstance(typeName);
            }
            catch (KeyNotFoundException ex)
            {
                throw new ParticleEmitterLoadParticleModifierException(typeName, ex);
            }

            // Read the custom values
            var customValueReader = reader.ReadNode(_customValuesNodeName);
            modifier.ReadState(customValueReader);

            return modifier;
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:29,代码来源:ParticleModifier.cs

示例5: LoadGrhs

        void LoadGrhs(IValueReader reader)
        {
            reader = reader.ReadNode(_mapGrhsNodeName);

            // Used GrhIndexes
            var usedGrhIndexes = reader.ReadMany(_usedIndiciesNodeName, ((r, key) => r.ReadGrhIndex(key)));
            BuildAtlas(usedGrhIndexes);

            // MapGrhs
            var currentTime = GetTime();
            var loadedMapGrhs = reader.ReadManyNodes(_mapGrhsNodeName, x => new MapGrh(x, currentTime));
            foreach (var mapGrh in loadedMapGrhs)
            {
                AddMapGrh(mapGrh);
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:16,代码来源:Map.cs

示例6: Read

        /// <summary>
        /// Reads a <see cref="IRefractionEffect"/> from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        /// <returns>The <see cref="IRefractionEffect"/> instance.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="reader"/> is null.</exception>
        public static IRefractionEffect Read(IValueReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            var typeName = reader.ReadString(_refractionEffectTypeKeyName);
            var nodeReader = reader.ReadNode(_refractionEffectNodeName);

            var instance = (IPersistable)Instance.GetTypeInstance(typeName);
            instance.ReadState(nodeReader);

            return (IRefractionEffect)instance;
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:19,代码来源:RefractionEffectFactory.cs

示例7: Read

        /// <summary>
        /// Reads the values for this NPCChatResponseBase from an IValueReader.
        /// </summary>
        /// <param name="reader">IValueReader to read the values from.</param>
        protected void Read(IValueReader reader)
        {
            var value = reader.ReadByte("Value");
            var page = reader.ReadNPCChatDialogItemID("Page");
            var text = reader.ReadString("Text");
            var actionNames = reader.ReadMany("Actions", ((r, name) => r.ReadString(name)));
            var actions = GetActionsFromNames(actionNames);

            var cReader = reader.ReadNode("Conditionals");
            var hasConditionals = cReader.ReadBool("HasConditionals");
            NPCChatConditionalCollectionBase conditionals = null;
            if (hasConditionals)
            {
                conditionals = CreateConditionalCollection();
                if (conditionals != null)
                    conditionals.Read(cReader);
            }

            SetReadValues(value, page, text, conditionals, actions);
        }
开发者ID:wtfcolt,项目名称:game,代码行数:24,代码来源:NPCChatResponseBase.cs

示例8: ReadState

        /// <summary>
        /// Reads the state of the object from an <see cref="IValueReader"/>. Values should be read in the exact
        /// same order as they were written.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
        public void ReadState(IValueReader reader)
        {
            // Read the primary values
            Name = reader.ReadString(_nameKeyName);
            BlendMode = reader.ReadEnum<BlendMode>(_blendModeKeyName);
            Budget = reader.ReadInt(_budgetKeyName);
            EmitterLife = reader.ReadInt(_emitterLifeKeyName);
            ParticleLife = reader.ReadVariableInt(_particleLifeKeyName);
            Origin = reader.ReadVector2(_originKeyName);
            ReleaseAmount = reader.ReadVariableUShort(_releaseAmountKeyName);
            ReleaseColor = reader.ReadVariableColor(_releaseColorKeyName);
            ReleaseRate = reader.ReadVariableUShort(_releaseRateKeyName);
            ReleaseRotation = reader.ReadVariableFloat(_releaseRotationKeyName);
            ReleaseScale = reader.ReadVariableFloat(_releaseScaleKeyName);
            ReleaseSpeed = reader.ReadVariableFloat(_releaseSpeedKeyName);
            Sprite.SetGrh(reader.ReadGrhIndex(_grhIndexKeyName));

            // Read the custom values
            var customValuesReader = reader.ReadNode(_customValuesNodeName);
            ReadCustomValues(customValuesReader);

            // Read the modifier collection
            ParticleModifiers.Read(_particleModifiersNodeName, reader);
            EmitterModifiers.Read(_emitterModifiersNodeName, reader);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:30,代码来源:ParticleEmitter.cs

示例9: Read

        /// <summary>
        /// Reads the values for this NPCChatDialogItemBase from an IValueReader.
        /// </summary>
        /// <param name="reader">IValueReader to read the values from.</param>
        protected void Read(IValueReader reader)
        {
            var id = reader.ReadNPCChatDialogItemID("ID");
            var title = reader.ReadString("Title");
            var text = reader.ReadString("Text");
            var isBranch = reader.ReadBool("IsBranch");

            var responses = reader.ReadManyNodes("Responses", CreateResponse);

            NPCChatConditionalCollectionBase conditionals = null;
            if (isBranch)
            {
                var cReader = reader.ReadNode("Conditionals");
                var hasConditionals = cReader.ReadBool("HasConditionals");
                if (hasConditionals)
                {
                    conditionals = CreateConditionalCollection();
                    if (conditionals != null)
                        conditionals.Read(cReader);
                }
            }

            SetReadValues(id, title, text, isBranch, responses, conditionals);

            AssertBranchHasTwoResponses();
            AssertNonBranchHasNoConditionals();
            AssertResponsesHaveValidValues();
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:32,代码来源:NPCChatDialogItemBase.cs

示例10: ReadState

        /// <summary>
        /// Reads the state of the object from an <see cref="IValueReader"/>. Values should be read in the exact
        /// same order as they were written.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
        public void ReadState(IValueReader reader)
        {
            reader = reader.ReadNode(_particleEffectNodeName);

            // Clear the emitters
            foreach (var e in _emitters.ToImmutable())
            {
                e.Dispose();
            }

            Debug.Assert(_emitters.IsEmpty());
            _emitters.Clear();

            // Read the effect properties
            PersistableHelper.Read(this, reader);

            // Read the emitters
            var readEmitters = reader.ReadManyNodes(_emittersNodeName, r => ParticleEmitterFactory.Read(r, this));

            Debug.Assert(readEmitters.All(x => x.Owner == this));
        }
开发者ID:wtfcolt,项目名称:game,代码行数:26,代码来源:ParticleEffect.cs

示例11: ReadKVP

        /// <summary>
        /// Reads a <see cref="KeyValuePair{T,U}"/> for a <see cref="Tool"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        /// <returns>The <see cref="KeyValuePair{T,U}"/>.</returns>
        static KeyValuePair<string, IValueReader> ReadKVP(IValueReader reader)
        {
            var kvpKey = reader.ReadString(_kvpKeyName);
            var kvpValue = reader.ReadNode(_kvpValueNodeName);

            return new KeyValuePair<string, IValueReader>(kvpKey, kvpValue);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:12,代码来源:ToolStateManager.cs

示例12: ReadFilter

        /// <summary>
        /// Reads a filter from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        /// <returns>The name of the filter and the filter object.</returns>
        static KeyValuePair<string, MapDrawFilterHelper> ReadFilter(IValueReader reader)
        {
            var key = reader.ReadString(_filterKeyValueName);

            var valueReader = reader.ReadNode(_filterValueValueName);
            var value = new MapDrawFilterHelper(valueReader);

            return new KeyValuePair<string, MapDrawFilterHelper>(key, value);
        }
开发者ID:Vizzini,项目名称:netgore,代码行数:14,代码来源:MapDrawFilterHelperCollection.cs

示例13: ReadCustomToolState

        /// <summary>
        /// Handles reading custom state information for this <see cref="Tool"/> from an <see cref="IValueReader"/> for when
        /// persisting the <see cref="Tool"/>'s state.
        /// When possible, it is preferred that you use the <see cref="SyncValueAttribute"/> instead of manually handling
        /// reading and writing the state.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
        protected override void ReadCustomToolState(IValueReader reader)
        {
            base.ReadCustomToolState(reader);

            var filterCollectionReader = reader.ReadNode(_filterCollectionNodeName);

            _filterCollection.ReadState(filterCollectionReader);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:15,代码来源:MapDisplayFilterTool.cs

示例14: Read

        /// <summary>
        /// Reads a <see cref="ParticleEmitter"/> from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        /// <param name="owner">The <see cref="IParticleEffect"/> to add the read <see cref="ParticleEmitter"/> to.</param>
        /// <returns>
        /// The <see cref="ParticleEmitter"/> read from the <paramref name="reader"/>.
        /// </returns>
        /// <exception cref="ParticleEmitterLoadEmitterException">The <see cref="ParticleEmitter"/> could not be loaded.</exception>
        public static ParticleEmitter Read(IValueReader reader, IParticleEffect owner)
        {
            // Get the type name
            var emitterTypeString = reader.ReadString(_emitterTypeKeyName);

            // Create the instance using the type name
            ParticleEmitter emitter;
            try
            {
                emitter = (ParticleEmitter)Instance.GetTypeInstance(emitterTypeString, owner);
            }
            catch (KeyNotFoundException ex)
            {
                throw new ParticleEmitterLoadEmitterException(emitterTypeString, ex);
            }

            // Grab the reader for the emitter node, then read the values into the emitter
            var emitterReader = reader.ReadNode(_emitterNodeName);
            emitter.ReadState(emitterReader);

            return emitter;
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:31,代码来源:ParticleEmitterFactory.cs


注:本文中的IValueReader.ReadNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。