Ejemplo n.º 1
0
        protected void generateWindowData(NodeCanvasData windowData)
        {
            windowList  = new List <BaseWindow>();
            fixedWindow = new FixedWindow(windowData.shareData);

            foreach (var item in windowData.nodelist)
            {
                windowList.Add(new NodeWindow(item, windowList));
            }

            foreach (var item in windowData.routerlist)
            {
                windowList.Add(new RouterWindow(item, windowList));
            }

            //set next Node
            foreach (var item in windowList)
            {
                DataBase itemdata = windowData.Get(item.Id);

                if (itemdata.type == NodeType.Node)
                {
                    NodeData edata = itemdata as NodeData;

                    if (edata.next >= 0)
                    {
                        BaseWindow next = FindWindow(edata.next);

                        (item as NodeWindow).SetNext(next);
                    }
                }
                else
                {
                    RouterData   edata = itemdata as RouterData;
                    RouterWindow win   = item as RouterWindow;

                    //set default
                    if (edata.defaultEntity >= 0)
                    {
                        NodeWindow def = FindWindow <NodeWindow>(edata.defaultEntity);
                        win.SetDefault(def);
                    }

                    //set conditions
                    List <RouterWindowCondition> conditions = new List <RouterWindowCondition>();
                    foreach (var con in edata.conditions)
                    {
                        RouterWindowCondition rcon = new RouterWindowCondition();
                        rcon.className = con.className;
                        rcon.entity    = FindWindow <NodeWindow>(con.entity);
                        conditions.Add(rcon);
                    }
                    win.SetConditions(conditions);
                }
            }
        }
Ejemplo n.º 2
0
        public override void rightMouseDraw(Vector2 mouseposition)
        {
            GenericMenu menu = new GenericMenu();


            menu.AddItem(nextNewNodeContent, false, () =>
            {
                var tempWindow = new NodeWindow(mouseposition, windowList);
                windowList.Add(tempWindow);
                next = tempWindow;
            });

            menu.AddItem(nextNewRouterContent, false, () =>
            {
                var tempWindow = new RouterWindow(mouseposition, windowList);
                windowList.Add(tempWindow);
                next = tempWindow;
            });

            menu.AddSeparator(separator);

            #region select the next one
            List <BaseWindow> selectionList = new List <BaseWindow>();

            foreach (var item in windowList)
            {
                if (item.Id == Id)
                {
                    continue;
                }
                selectionList.Add(item);
            }

            foreach (var item in selectionList)
            {
                bool select = (next != null) && next.Id == item.Id;

                menu.AddItem(new GUIContent(string.Format("Next/[{0}][{1}] {2}", item.Id, item.windowType, item.Name))
                             , select, () =>
                {
                    if (select)
                    {
                        next = null;
                    }
                    else
                    {
                        next = item;
                    }
                });
            }
            #endregion

            if (isEntrance)
            {//the Node is Entrance can not be delete
                menu.AddDisabledItem(deleteContent);
            }
            else
            {
                menu.AddItem(deleteContent, false, () =>
                {
                    windowList.Remove(this);
                });
            }

            menu.AddItem(entranceContent, isEntrance, () =>
            {
                foreach (var item in windowList)
                {
                    if (item is NodeWindow)
                    {
                        (item as NodeWindow).isEntrance = false;
                    }
                }

                isEntrance = true;
            });

            menu.ShowAsContext();
        }