void DisplayBody(CGME.ActionIfThenElse action)
 {
     EditorGUI.indentLevel++;
     {
         DisplayAction(action.GetIF(), null);
         DisplayAction(action.GetTHEN(), null);
         DisplayAction(action.GetELSE(), null);
     }
     EditorGUI.indentLevel--;
 }
Beispiel #2
0
        CGME.Action InstantiateNodes()
        {
            List <CGME.Action> actions = new List <CGME.Action>();


            //INSTANTIATE
            int i = 0;

            foreach (SerialNode node in serial_nodes)
            {
                CGME.Action act = CGME.CGFactory.CreateCGInstance(node.type_string) as CGME.Action;
                act.Read(node.data);


                actions.Add(act);
            }

            foreach (SerialNode node in serial_nodes)
            {
                if (node.children_indexes.Count > 0)
                {
                    //Debug.Log ("3");

                    if (actions[node.index] is CGME.ActionGroup)
                    {
                        CGME.ActionGroup actiongroup = actions[node.index] as CGME.ActionGroup;

                        foreach (int index in node.children_indexes)
                        {
                            //	Debug.Log ("4");
                            actiongroup.AddAction(actions[index]);
                        }
                    }
                    else if (actions[node.index] is CGME.ActionIfThenElse)
                    {
                        CGME.ActionIfThenElse action_ite = actions[node.index] as CGME.ActionIfThenElse;

                        action_ite.SetIF(actions[node.children_indexes[0]] as CGME.ActionGroup);
                        action_ite.SetTHEN(actions[node.children_indexes[1]] as CGME.ActionGroup);
                        action_ite.SetELSE(actions[node.children_indexes[2]] as CGME.ActionGroup);
                    }
                }
            }


            if (actions.Count > 0)
            {
                return(actions[0]);
            }

            return(null);
        }
Beispiel #3
0
        void AddChildrenToSerializedNodes(CGME.ActionIfThenElse parent_action, SerialNode parent_node)
        {
            // Create a NODE for each ACTION CHILD and add them to the list
            // save the index of each CHILDREN NODE to the PARENT NODE

            SerialNode if_node   = AddNode(parent_action.GetIF(), parent_node);
            SerialNode then_node = AddNode(parent_action.GetTHEN(), parent_node);
            SerialNode else_node = AddNode(parent_action.GetELSE(), parent_node);

            // For every child that can have children (actiongroup),
            // call the funcion again sending its index

            AddChildrenToSerializedNodes(parent_action.GetIF(), if_node);
            AddChildrenToSerializedNodes(parent_action.GetTHEN(), then_node);
            AddChildrenToSerializedNodes(parent_action.GetELSE(), else_node);
        }