Example #1
0
 private void AddNode(Type type, Vector2 position)
 {
     if (type.IsSubclassOf(typeof(Leaf)))
     {
         EditorAILeafNode node = Node.Create(EditorAILeafNode.ID, position) as EditorAILeafNode;
         node.Init(type);
     }
     else if (type.IsSubclassOf(typeof(Decorator)))
     {
         EditorAIDecoratorNode node = Node.Create(EditorAIDecoratorNode.ID, position) as EditorAIDecoratorNode;
         node.Init(type);
     }
     else if (type.IsSubclassOf(typeof(Combinational)))
     {
         EditorAICombinationalNode node = Node.Create(EditorAICombinationalNode.ID, position) as EditorAICombinationalNode;
         node.Init(type);
     }
 }
Example #2
0
        public EditorAINode LoadCombinational(Combinational node)
        {
            EditorAICombinationalNode output = Node.Create(EditorAICombinationalNode.ID, Vector3.zero) as EditorAICombinationalNode;

            output.dataType = node.GetType().ToString();
            var clone = node.Clone() as Combinational;

            clone.subNodes = new List <AINode>();

            output.data = new GenericSerializable(output.dataType);
            output.data.SetObject(clone, nodeTypes);

            //load children
            foreach (var child in node.subNodes)
            {
                //load
                EditorAINode childNode = LoadNode(child);
                //attach
                output.PushChild(childNode);
            }

            return(output);
        }