Exemplo n.º 1
0
		public Variable(GameObject gameObject, XMLRules.VariableType variable)
		{
            m_GameObject = gameObject;
			m_IsDirty = true;

            Load(variable);
		}
Exemplo n.º 2
0
		NodeBase CreateActionNode(XMLRules.ActionType action)
		{
			NodeBase result = null;

			if (action.HasChangeState()) 
			{
				NodeBase rhsNode = CreateArithmeticNode(action.GetChangeState().GetExpression());

				result = new SetNode(m_Container);
				((SetNode)result).m_VariableName = action.GetChangeState().GetVariable().GetName().Value;
				result.AddChild(rhsNode);
			} 
			else if (action.HasCallScript()) 
			{
				result = new CallNode(m_Container);

				string scriptName = action.GetCallScript().GetScriptName().Value;

				List<ScriptDescriptor> actionList = ScriptManager.GetScriptsByType(typeof(BaseAction));

                foreach (ScriptDescriptor script in actionList)
				{
					if (scriptName == script.m_Type.ToString())
					{
                        BaseScript newScript = null;
                        BaseScript.Load(action.GetCallScript(), m_Container.m_Editor.m_TargetObject, out newScript);

                        ((CallNode)result).m_Script = (BaseAction)newScript;
						break;
					}
				}
			}

			return result;
		}
Exemplo n.º 3
0
		public bool Save(ref XMLRules.VariableType variable)
		{
            bool result = true;

			variable.AddName(new SchemaString(m_Name));
			variable.AddType2(new SchemaLong((long)m_Type));
			variable.AddValue(GetConstantFromValue(m_Type, m_Value));
            
            if (m_UpdateScript != null)
            {
                ScriptReference scriptReference;

                if (BaseScript.Save(m_UpdateScript, out scriptReference))
                {
                    variable.AddUpdateScript(scriptReference);
                }
                else
                {
                    Debug.LogError("Error saving update script for variable " + m_Name);
                    result = false;
                }
            }
			
			return result;
		}
Exemplo n.º 4
0
		public bool Load(XMLRules.VariableType variable)
		{
			m_Name = (string)variable.GetName().Value;
			m_Type = (VariableType)variable.GetType2().Value;
			m_Value = GetValueFromConstant((VariableType)variable.GetType2().Value, variable.GetValue());

            if (variable.HasUpdateScript())
            {
                BaseScript updateScript;

				RemoveScript();

                if (BaseScript.Load(variable.GetUpdateScript(), m_GameObject, out updateScript))
                {
                    m_UpdateScriptType = updateScript.GetType();
                    m_UpdateScript = (BaseSensor)updateScript;
                }
            }

			m_IsDirty = true;

			return true;
		}