示例#1
0
        public bool Open(string filePath)
        {
            m_State    = GetComponent <State>();
            m_RuleBase = GetComponent <RuleBase>();


            XMLRulesType root;

            try
            {
                XMLRulesDoc doc = new XMLRulesDoc();
                root = new XMLRulesType(doc.Load(filePath));
            }
            catch (Exception e)
            {
                Debug.Log("Error on Open " + e.ToString());
                return(false);
            }

            m_State.Clear();
            m_RuleBase.Clear();

            m_RuleBaseFilePath = filePath;
            m_RuleBase.SetContext(this);
            m_RuleBase.Load(root.GetRuleBase());
            m_State.Load(root.GetRuleBase());

            return(true);
        }
		public bool Open(string filePath)
		{
			m_State = GetComponent<State>();
			m_RuleBase = GetComponent<RuleBase>();

			if (File.Exists(filePath)) 
			{
				XMLRulesType root;

				try
				{
					XMLRulesDoc doc = new XMLRulesDoc();
					root = new XMLRulesType(doc.Load(filePath));
				}
				catch (Exception e)
				{
					Debug.Log("Error on Open " + e.ToString());
					return false;
				}

				m_State.Clear();
				m_RuleBase.Clear();

				m_RuleBaseFilePath = filePath;
				m_RuleBase.SetContext(this);
				m_RuleBase.Load(root.GetRuleBase());
				m_State.Load(root.GetRuleBase());

				return true;
			}

			return false;
		}
示例#3
0
        // Use this for initialization
        void Start()
        {
            m_State    = GetComponent <State>();
            m_RuleBase = GetComponent <RuleBase>();

            m_RuleBase.SetContext(this);
            //Debug.Log("RuleBase: " + m_RuleBaseFilePath);

            if (m_RuleBaseFilePath.Length != 0)
            {
                TextAsset read   = (TextAsset)Resources.Load("Xml/" + m_RuleBaseFilePath, typeof(TextAsset));
                Stream    s      = GenerateStreamFromString(read.text);
                XmlReader reader = XmlReader.Create(s);
                Open(reader, m_RuleBaseFilePath);
            }
        }
示例#4
0
		// Use this for initialization
		void Start()
		{
			m_State = GetComponent<State>();
			m_RuleBase = GetComponent<RuleBase>();
			
			m_RuleBase.SetContext(this);
			//Debug.Log("RuleBase: " + m_RuleBaseFilePath);
			
			if (m_RuleBaseFilePath.Length != 0) 
			{

				TextAsset read=(TextAsset)Resources.Load("Xml/"+m_RuleBaseFilePath,typeof(TextAsset));
				Stream s=GenerateStreamFromString (read.text);
				XmlReader reader = XmlReader.Create(s); 
				Open (reader,m_RuleBaseFilePath);
				
			}
		}
		void Awake()
		{
			// For some reason scripts instantiated during load never get destroyed
			// in the switch between edit and playmode. This bit of hack here destroys
			// any lingering scripts as they will be reloaded in the Open call.
			BaseScript[] scripts = gameObject.GetComponents<BaseScript>();

			foreach (BaseScript script in scripts)
				GameObject.DestroyImmediate(script);

			m_State = GetComponent<State>();
			m_RuleBase = GetComponent<RuleBase>();

			m_RuleBase.SetContext(this);
			Debug.Log("RuleBase: " + m_RuleBaseFilePath);
	
			if (m_RuleBaseFilePath.Length != 0) 
			{
				Open(m_RuleBaseFilePath);
			}
		}
示例#6
0
        void Awake()
        {
            // For some reason scripts instantiated during load never get destroyed
            // in the switch between edit and playmode. This bit of hack here destroys
            // any lingering scripts as they will be reloaded in the Open call.
            BaseScript[] scripts = gameObject.GetComponents <BaseScript>();

            foreach (BaseScript script in scripts)
            {
                GameObject.DestroyImmediate(script);
            }

            m_State    = GetComponent <State>();
            m_RuleBase = GetComponent <RuleBase>();

            m_RuleBase.SetContext(this);
            Debug.Log("RuleBase: " + m_RuleBaseFilePath);

            if (m_RuleBaseFilePath.Length != 0)
            {
                Open(m_RuleBaseFilePath);
            }
        }
示例#7
0
 public void SetRuleBase(RuleBase ruleBase)
 {
     m_RuleBase = ruleBase;
     m_RuleBase.SetContext(this);
 }
示例#8
0
		public void SetRuleBase(RuleBase ruleBase)
		{
			m_RuleBase = ruleBase;
			m_RuleBase.SetContext(this);
		}