コード例 #1
0
        public static XmlEvent LoadXml(XmlNode nodeEvent)
        {
            if (nodeEvent == null)
            {
                return(null);
            }
            XmlEvent newEvent = new XmlEvent();

            newEvent.xmlText = Formater.FormatXML(nodeEvent.OuterXml);
            ////////////////////////////////////////////////////////////////////////

            XmlNodeList actList = nodeEvent.SelectNodes("action");

            newEvent.eventID = ((XmlElement)nodeEvent).getString("id");
            if (actList.Count > 0)
            {
                foreach (XmlElement nodeAct in actList)
                {
                    string strAct = nodeAct.GetAttribute("cmdID");
                    if (string.IsNullOrEmpty(strAct))
                    {
                        strAct = nodeAct.GetAttribute("cmd");
                    }

                    ActBase newAct = ActBase.CreateAction(strAct);
                    if (newAct != null)
                    {
                        newAct.loadXML(nodeAct);
                        newEvent.actList.Add(newAct);
                    }
                    else
                    {
                        Debug.Log(nodeAct.OuterXml);
                    }
                }
                return(newEvent);
            }

            actList = nodeEvent.ChildNodes;
            if (actList.Count > 0)
            {
                foreach (XmlElement nodeAct in actList)
                {
                    ActBase newAct = ActBase.CreateAction(nodeAct.Name);
                    if (newAct != null)
                    {
                        newAct.loadXML(nodeAct);
                        newEvent.actList.Add(newAct);
                    }
                    else
                    {
                        Debug.Log(nodeAct.OuterXml);
                    }
                }
                return(newEvent);
            }


            return(newEvent);
        }
コード例 #2
0
        public void LoadXML(XmlNode xmlRoot)
        {
            XmlNode nodeInit = xmlRoot.SelectSingleNode("Init");

            if (nodeInit == null)
            {
                nodeInit = xmlRoot.SelectSingleNode("begin");
            }

            if (nodeInit != null)
            {
                eventInit         = XmlEvent.LoadXml(nodeInit);
                eventInit.eventID = "Init";
            }
            XmlNode nodeItem = xmlRoot.SelectSingleNode("Assets");

            if (nodeItem == null)
            {
                nodeItem = xmlRoot.SelectSingleNode("Items");
            }
            if (nodeItem != null)
            {
                for (int i = 0; i < nodeItem.ChildNodes.Count; i++)
                {
                    XmlNode node = nodeItem.ChildNodes[i];//
                    if (node.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }

                    XmlElement element = node as XmlElement;
                    XmlPic2D   item    = XmlPic2D.LoadXml(element);
                    if (item != null)
                    {
                        assetList.Add(item);
                    }
                }
            }

            XmlNode nodeEvent = xmlRoot.SelectSingleNode("Events");

            if (nodeEvent != null)
            {
                XmlNodeList eList = nodeEvent.SelectNodes("OnClick");
                foreach (XmlElement node in eList)
                {
                    XmlEvent newEvent = XmlEvent.LoadXml(node);
                    if (newEvent != null)
                    {
                        eventList[newEvent.eventID] = newEvent;
                    }
                }
            }
        }