Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 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);
				
			}
		}
Ejemplo n.º 4
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);
			}
		}
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
 public void SetRuleBase(RuleBase ruleBase)
 {
     m_RuleBase = ruleBase;
     m_RuleBase.SetContext(this);
 }
Ejemplo n.º 7
0
		public void SetRuleBase(RuleBase ruleBase)
		{
			m_RuleBase = ruleBase;
			m_RuleBase.SetContext(this);
		}
Ejemplo n.º 8
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;
			
			
		}