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


C# NPC.SetName方法代码示例

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


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

示例1: LoadNpcs

    public NPC[] LoadNpcs(int levelIn)
    {
        //Get level in
        //int levelIn = 1;
        NPC npc;
        NPC[] npc_array = new NPC[2];
        int index = -1;
        bool found = false;

        xml = (TextAsset)Resources.Load(npc_xml);
        XmlDocument xmlDoc = new XmlDocument();

        xmlDoc.LoadXml(xml.text);
        //Debug.Log("REACHED");
        XmlNodeList npc_list = xmlDoc.GetElementsByTagName("Character");
        foreach(XmlNode dialog_fragment in npc_list){
            XmlNodeList xnl = dialog_fragment.ChildNodes;
            npc = new NPC();
            foreach(XmlNode xn in xnl ){

                //ADD NPC ID TO DATABASE

                if(xn.Name == "Level" && xn.InnerText != levelIn.ToString()){
                    found = false;
                }
                if(xn.Name == "Level" && xn.InnerText == levelIn.ToString()){
                    found = true;

                    index++;
                    //Debug.Log("Response_id : " + xn.InnerText);
                    npc.SetLevel(xn.InnerText);

                }
                    if(xn.Name == "Name" && found){
                //	Debug.Log("Symbol: " + xn.InnerText);
                    npc.SetName(xn.InnerText);
                }
                if(xn.Name == "Portrait" && found){
                    //Debug.Log("TEXT: " + xn.InnerText);
                    npc.SetPortrait(xn.InnerText);
                }
                if(xn.Name == "Image" && found){
                //	Debug.Log("Audio File: " + xn.InnerText);
                    npc.SetImage(xn.InnerText);
                }

                if(xn.Name == "Statement_ID" && found){
                    //Debug.Log("Next Statement: " + xn.InnerText);
                    npc.SetStatementId(xn.InnerText);
                }

                if(xn.Name == "Position" && found){
                    //Debug.Log("Next Statement: " + xn.InnerText);
                    npc.SetPosition(xn.InnerText);
                }

            }

                //Add to response array

            if(found)
            npc.SetStatements(npc.GetName());
            npc_array[index] = npc;

        }

          /*for(int i = 0; i < 4; i++){
            Debug.Log("Array test: " + response_array[i].getText());
        }*/

        //Return array
        return npc_array;
    }
开发者ID:mduffyg13,项目名称:Game-Unity-CityLife,代码行数:73,代码来源:XML_Parser.cs


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