コード例 #1
0
        /// <summary>
        /// Loads the script file.
        /// </summary>
        /// <returns></returns>
        public bool Load()
        {
            if (string.IsNullOrEmpty(m_scriptFilePath))
            {
                return(false);
            }

            MyObjectBuilder_VSFiles bundle;

            using (var fstream = MyFileSystem.OpenRead(m_scriptFilePath))
            {
                if (!MyObjectBuilderSerializer.DeserializeXML(fstream, out bundle))
                {
                    return(false);
                }
            }

            try
            {
                if (bundle.LevelScript != null)
                {
                    m_objectBuilder = bundle.LevelScript;
                }
                else if (bundle.VisualScript != null)
                {
                    m_objectBuilder = bundle.VisualScript;
                }

                m_navigator  = new MyVisualScriptNavigator(m_objectBuilder);
                m_scriptName = m_objectBuilder.Name;

                if (m_objectBuilder.Interface != null)
                {
                    m_baseType = MyVisualScriptingProxy.GetType(m_objectBuilder.Interface);
                }
            }
            catch (Exception e)
            {
                Debug.Fail("Error occured during the graph reconstruction: " + e);
            }

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Loads the script file.
        /// </summary>
        /// <returns></returns>
        public bool Load()
        {
            if(string.IsNullOrEmpty(m_scriptFilePath)) return false;

            MyObjectBuilder_VSFiles bundle;

            using (var fstream = MyFileSystem.OpenRead(m_scriptFilePath))
            {
                if (!MyObjectBuilderSerializer.DeserializeXML(fstream, out bundle))
                {
                    return false;
                }
            }

            try
            {
                if (bundle.LevelScript != null)
                {
                    m_objectBuilder = bundle.LevelScript;
                }
                else if (bundle.VisualScript != null)
                {
                    m_objectBuilder = bundle.VisualScript;
                }

                m_navigator = new MyVisualScriptNavigator(m_objectBuilder);
                m_scriptName = m_objectBuilder.Name;

                if(m_objectBuilder.Interface != null)
                    m_baseType = MyVisualScriptingProxy.GetType(m_objectBuilder.Interface);
            }
            catch (Exception e)
            {
                Debug.Fail("Error occured during the graph reconstruction: " + e);
            }

            return true;
        }