Пример #1
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);
        }
Пример #2
0
        void FindScriptReferences()
        {
            if (m_Rule.HasAction())
            {
                for (int i = 0; i < m_Rule.GetActionCount(); i++)
                {
                    XMLRules.ActionType action = m_Rule.GetActionAt(i);

                    if (action.HasCallScript())
                    {
                        BaseScript actionScript;

                        if (BaseScript.Load(action.GetCallScript(), m_Context.gameObject, out actionScript))
                        {
                            m_ScriptReferences.Add((BaseAction)actionScript);
                        }
                    }
                }
            }
        }
Пример #3
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);
        }