コード例 #1
0
        /// <summary>
        /// Loads a behaviour from the given filename
        /// </summary>
        public override void Load()
        {
            try
            {
                if (_filename.StartsWith("http://"))
                {
                    string behaviorText = HttpGet(_filename);
                    _xmlfile.LoadXml(behaviorText);
                }
                else
                {
                    _xmlfile.Load(_filename);
                }
                XmlNode root = null;
                if (_xmlfile.ChildNodes.Count > 1)
                {
                    root = _xmlfile.ChildNodes[1].ChildNodes[0];
                }
                else
                {
                    root = _xmlfile.ChildNodes[0];
                }

                if (_filename.ToLower().EndsWith(".btx"))
                {
                    Node node = new Behavior();
                    node.AddChild(node.DefaultConnector, CreateNode(root));
                    _node = (BehaviorNode)node;
                }
                else
                {
                    _node = (BehaviorNode)CreateNode(root);
                }
                _node.FileManager = this;

                DoPostLoad((Node)_node);
            }
            catch
            {
                _xmlfile.RemoveAll();

                throw;
            }
        }