Ejemplo n.º 1
0
        public MainWindow()
        {
            slides = new NodeManager();
            InitializeComponent();
            for (int i = 0; i < Directory.GetFiles(Directory.GetCurrentDirectory() + Slidefolder).Length; i++)
            {
                Node     n         = new Scripts.Node("File " + i, null, null, "Slide " + i, NodeType.Text);
                string[] slideData = slides.generateNodeData(i);
                n.writeToData(slideData);
                slides.AddNode(n);
            }

            time  = TimeSpan.FromSeconds(timerLength);
            timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
            {
                if (time == TimeSpan.Zero)
                {
                    timer.Stop();
                    if (slides.currentNode().type != NodeType.Question)
                    {
                        canTransition = true;
                    }
                    Next.Content = "NEXT ->";
                }
                time = time.Add(TimeSpan.FromSeconds(-1));
            }, Application.Current.Dispatcher);
            timer.Start();

            constructMenu();

            slides.transition(true);
            switchScreens();
        }
Ejemplo n.º 2
0
    public void GenerateGrid(int width, int height)
    {
        nodeManager.InitializeNodeMatrix(width, height);

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                Node node = Instantiate(nodePrefab, gridParent).GetComponent <Node>();
                node.GetComponent <RectTransform>().anchoredPosition = new Vector3(33 * (x - width / 2.5f), 33 * (y - height / 2.5f));
                node.x = x;
                node.y = y;
                node.SetFloorValue(defaultFloor);

                nodeManager.AddNode(node);
            }
        }
    }
Ejemplo n.º 3
0
    private void SpawnNodeAtDistance(float distanceTravelled)
    {
        // Get the coordinates of the point at the distance travelled
        Vector3 pointOnPath = pathCreator.path.GetPointAtDistance(distanceTravelled);
        // Spawn a new node under the parent transform at those coordinates
        NumberNode newNode = Instantiate(numberBall, pointOnPath, Quaternion.identity, parentTransform).GetComponent <NumberNode>();

        newNode.Init();
        // Set the pathfollower's distance travelled acoordingly
        newNode.pathFollower.SetDistanceTravelled(distanceTravelled);
        // Set the node state to be in the gutter
        newNode.SetState(NodeState.GUTTER);
        // Disable the node's motor as the pathfollower takes care of movement in the gutter
        newNode.nodeMotor.enabled = false;
        newNode.SetColorToValue();
        // Add the node to the node manager
        NodeManager.AddNode(newNode);
    }
Ejemplo n.º 4
0
 void Update()
 {
     if (!GameStateManager.IsPaused())
     {
         if (timeStamp < Time.time)
         {
             LayerMask nodeMask = LayerMask.GetMask("NodeLayer");
             if (!Physics2D.OverlapCircle(transform.position, NumberNode.RADIUS, nodeMask))
             {
                 NumberNode newNode = Instantiate(numberBall, pathStart, Quaternion.identity, parentTransform).GetComponent <NumberNode>();
                 NodeManager.AddNode(newNode);
                 newNode.SetState(NodeState.FORWARD);
                 newNode.Init();
                 newNode.SetValue(Random.Range(NumberList.BOUND_LOW, NumberList.BOUND_HIGH));
                 timeStamp = Time.time + cooldown;
             }
         }
     }
 }
            /// <summary>
            /// quality of life function, used to instantly create and connect a new dialogue node to this one
            /// </summary>
            private void CreateNextDialogue()
            {
                // get node and connection managers
                NodeManager       nodeManager       = NodeEditor.GetNodeManager();
                ConnectionManager connectionManager = NodeEditor.GetConnectionManager();

                // create the new dialogue node and connect it with this node
                DialogueNode dialogueNode = nodeManager.AddNode(typeof(DialogueNode)) as DialogueNode;

                connectionManager.CreateLinearConnection(this, dialogueNode);

                // adjust it's position to be slightly to the right of this dialogue node
                dialogueNode.m_rectangle    = m_rectangle;
                dialogueNode.m_rectangle.x += m_rectangle.width + 48;

                dialogueNode.m_character = m_character; // copy speaking character

                // save focus-relevant variables (used to auto-focussing on the new dialogue text area)
                m_newDialogueID      = dialogueNode.m_nodeID;
                m_newDialogueCreated = true;
            }
Ejemplo n.º 6
0
 public bool AddNode(NodeModel node, object whereToAdd)
 {
     return(NodeManager.AddNode(node, whereToAdd));
 }
            /// <summary>
            /// handles the processing of the right-click context menu, including options
            /// to Add/Remove/Copy/Paste nodes, Add/Remove pages
            /// </summary>
            /// <param name="newNodeOnly">if true, only allow creation of new nodes, and no copy/pasting or pages</param>
            private void ProcessContextMenu(bool newNodeOnly = false)
            {
                GenericMenu contextMenu = new GenericMenu();

                // -- add new nodes to this function! --
                // contextMenu.AddItem(new GUIContent("New Node/Category/Your Node"), false, () => m_nodeManager.AddNode(typeof(YourNode)));

                #region in-built DEVN nodes

                // audio nodes
                contextMenu.AddItem(new GUIContent("New Node/Audio/BGM"), false, () => m_nodeManager.AddNode(typeof(BGMNode)));
                contextMenu.AddItem(new GUIContent("New Node/Audio/SFX"), false, () => m_nodeManager.AddNode(typeof(SFXNode)));

                // background nodes
                contextMenu.AddItem(new GUIContent("New Node/Background/Background"), false, () => m_nodeManager.AddNode(typeof(BackgroundNode)));

                // character nodes
                contextMenu.AddItem(new GUIContent("New Node/Character/Scale"), false, () => m_nodeManager.AddNode(typeof(CharacterScaleNode)));
                contextMenu.AddItem(new GUIContent("New Node/Character/Translate"), false, () => m_nodeManager.AddNode(typeof(CharacterTranslateNode)));
                contextMenu.AddSeparator("New Node/Character/");
                contextMenu.AddItem(new GUIContent("New Node/Character/Character"), false, () => m_nodeManager.AddNode(typeof(CharacterNode)));

                // dialogue nodes
                contextMenu.AddItem(new GUIContent("New Node/Dialogue/Branch"), false, () => m_nodeManager.AddNode(typeof(BranchNode)));
                contextMenu.AddItem(new GUIContent("New Node/Dialogue/Dialogue"), false, () => m_nodeManager.AddNode(typeof(DialogueNode)));
                contextMenu.AddSeparator("New Node/Dialogue/");
                contextMenu.AddItem(new GUIContent("New Node/Dialogue/Dialogue Box"), false, () => m_nodeManager.AddNode(typeof(DialogueBoxNode)));

                // utility nodes
                contextMenu.AddItem(new GUIContent("New Node/Utility/Delay"), false, () => m_nodeManager.AddNode(typeof(DelayNode)));
                contextMenu.AddItem(new GUIContent("New Node/Utility/Page"), false, () => m_nodeManager.AddNode(typeof(PageNode)));
                contextMenu.AddItem(new GUIContent("New Node/Utility/Application Quit"), false, () => m_nodeManager.AddNode(typeof(ApplicationQuitNode)));

                // variable nodes
                contextMenu.AddItem(new GUIContent("New Node/Variable/Condition"), false, () => m_nodeManager.AddNode(typeof(ConditionNode)));
                contextMenu.AddItem(new GUIContent("New Node/Variable/Modify"), false, () => m_nodeManager.AddNode(typeof(ModifyNode)));

                // end node
                contextMenu.AddItem(new GUIContent("New Node/End"), false, () => m_nodeManager.AddNode(typeof(EndNode)));

                #endregion

                #region copy/paste/delete nodes

                // house-keeping (copy, paste, delete, etc.)
                contextMenu.AddDisabledItem(new GUIContent("Copy Node")); // copy
                if (m_nodeManager.GetClipboard() != null && !newNodeOnly)
                {
                    contextMenu.AddItem(new GUIContent("Paste Node"), false, m_nodeManager.PasteNode);     // paste
                }
                else
                {
                    contextMenu.AddDisabledItem(new GUIContent("Paste Node"));
                }
                contextMenu.AddDisabledItem(new GUIContent("Remove Node")); // remove

                #endregion

                #region add/remove pages

                // new page
                contextMenu.AddSeparator("");
                if (!newNodeOnly)
                {
                    contextMenu.AddItem(new GUIContent("New Page"), false, m_scene.NewPage);
                }
                else
                {
                    contextMenu.AddDisabledItem(new GUIContent("New Page"));
                }

                // remove page, disallow removal if only one page exists
                if (m_scene.GetPages().Count > 1 && !newNodeOnly)
                {
                    contextMenu.AddItem(new GUIContent("Remove Page"), false, m_scene.DeletePage);
                }
                else
                {
                    contextMenu.AddDisabledItem(new GUIContent("Remove Page"));
                }

                #endregion

                contextMenu.ShowAsContext();
            }