Пример #1
0
		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;
		}
Пример #2
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);
			}
		}
Пример #3
0
		public GraphToRule(State state)
		{
			m_State = state; 
		}