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


C# XmlDictionaryWriter.WriteCustomObject方法代码示例

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


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

示例1: SerializeNPC

        public static void SerializeNPC(Terraria.NPC npc, XmlDictionaryWriter writer, bool SetDefaults_Int32 = true)
        {
            writer.WriteString("\n\t");
            writer.WriteStartElement("NPC");

            foreach (var feild in Feilds)
            {
                switch (feild)
                {
                    case "ConfusionImmunity":
                        writer.WriteCustomObject(npc.buffImmune[31], feild);
                        break;
                    case "PoisonImmunity":
                        writer.WriteCustomObject(npc.buffImmune[20], feild);
                        break;
                    case "BurningImmunity":
                        writer.WriteCustomObject(npc.buffImmune[24], feild);
                        break;
                    case "CurseImmunity":
                        writer.WriteCustomObject(npc.buffImmune[39], feild);
                        break;
                    case "Name":
                        writer.WriteCustomObject(npc.name, feild);
                        break;
                    case "Type":
                        if (SetDefaults_Int32)
                            writer.WriteCustomObject(npc.type, feild);
                        else
                            writer.WriteCustomObject(npc.type, "Inherits");
                        break;
                    case "aiStyle":
                        writer.WriteCustomObject(npc.aiStyle, feild);
                        break;
                    case "scale":
                        writer.WriteCustomObject(npc.scale, feild);
                        break;
                    case "damage":
                        writer.WriteCustomObject(npc.damage, feild);
                        break;
                    case "defense":
                        writer.WriteCustomObject(npc.defense, feild);
                        break;
                    case "lifeMax":
                        writer.WriteCustomObject(npc.lifeMax, feild);
                        break;
                    case "value":
                        writer.WriteCustomObject(npc.value, feild);
                        break;
                    case "knockBackResist":
                        writer.WriteCustomObject(npc.knockBackResist, feild);
                        break;
                    case "Width":
                        writer.WriteCustomObject(npc.width, feild);
                        break;
                    case "Height":
                        writer.WriteCustomObject(npc.height, feild);
                        break;
                    case "slots":
                        writer.WriteCustomObject(npc.npcSlots, feild);
                        break;
                    case "noTileCollide":
                        writer.WriteCustomObject(npc.noTileCollide, feild);
                        break;
                    case "noGravity":
                        writer.WriteCustomObject(npc.noGravity, feild);
                        break;
                    case "behindTiles":
                        writer.WriteCustomObject(npc.behindTiles, feild);
                        break;
                    case "DisplayName":
                        if(npc.displayName != npc.name)
                            writer.WriteCustomObject(npc.displayName, feild);
                        break;
                    case "NetAlways":
                        writer.WriteCustomObject(npc.netAlways, feild);
                        break;
                    case "netSkip":
                        writer.WriteCustomObject(npc.netSkip, feild);
                        break;
                    case "NetID":
                        writer.WriteCustomObject(npc.netID, feild);
                        break;
                    default:
                        throw new Exception("This class is feild specific! Please add the relative feild above [" + feild + "]");
                }
            }

            writer.WriteString("\n\t");
            writer.WriteEndElement();
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:90,代码来源:NPCSerializer.cs


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