コード例 #1
0
        public static NoduleDatabase CreateNew(NodeObject mainObject)
        {
            NoduleDatabase DB = CreateInstance <NoduleDatabase> ();

            DB.name = mainObject.name + " - " + DB.GetType().Name;

            if (mainObject is BaseNode)
            {
                DB.mainNode   = mainObject as BaseNode;
                DB.mainNodule = null;
            }
            else if (mainObject is BaseNodule)
            {
                DB.mainNode   = null;
                DB.mainNodule = mainObject as BaseNodule;
            }
            else
            {
                throw new UnityException();
            }

            if (!DB)
            {
                throw new UnityException();
            }
            DB.Construct();
            return(DB);
        }
コード例 #2
0
        public override void Init()
        {
            base.Init();
            bool startNode = false;

            for (int i = 0; i < Count; i++)
            {
                BaseNode node = Get(i);

                if (!node)
                {
                    Debug.LogError("The Node at index '" + i + "' is missing its reference. Removing from NodeDatabase.");
                    base.RemoveAt(i);
                    i--;
                    continue;
                }

                if (node is StartNode)
                {
                    if (!startNode)
                    {
                        startNode = true;
                    }
                    else
                    {
                        Debug.LogError("");
                        base.Remove(node);
                        (node as StartNode).Delete(true);
                        i--;
                        continue;
                    }
                }

                if (!ItemNames.Contains(node.name))
                {
                    ItemNames.Add(node.name);
                }
                node.Init();
            }

            if (!startNode)
            {
                base.Add(NodeObject.CreateNew <StartNode> ("StartNode"));
            }
        }
コード例 #3
0
        public static void FetchAllNodes()
        {
            nodeTypes = new Dictionary <NodeData, BaseNode> ();
            IEnumerable <Assembly> assems = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.FullName.Contains("Assembly"));

            foreach (Assembly assem in assems)
            {
                foreach (Type type in assem.GetTypes().Where(a => !a.IsAbstract && a.IsClass && a.IsSubclassOf(typeof(BaseNode))))
                {
                    NodeAttribute attri = type.GetCustomAttributes(typeof(NodeAttribute), false)[0] as NodeAttribute;

                    if (attri != null && !attri.Hide)
                    {
                        NodeData data = new NodeData(attri);
                        nodeTypes.Add(data, NodeObject.CreateNew <BaseNode> (data.GetClassName));
                    }
                }
            }
        }