當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。