Пример #1
0
        public bool Contains(Let let)
        {
            foreach (Connection connection in Connections)
            {
                if (connection.Inlet == let || connection.Outlet == let)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        void OnLetUp(object sender, LetTypes type)
        {
            if (sender != m_currentSelectedLet)
            {
                Let senderLet = (Let)sender;
                if (senderLet.Owner != m_currentSelectedLet.Owner)
                {
                    if ((m_currentSelectedLet.Type == LetTypes.INLET && type == LetTypes.OUTLET) ||
                        (m_currentSelectedLet.Type == LetTypes.OUTLET && type == LetTypes.INLET))
                    {
                        Let inlet  = null;
                        Let outlet = null;

                        if (m_currentSelectedLet.Type == LetTypes.INLET)
                        {
                            inlet  = m_currentSelectedLet;
                            outlet = (Let)sender;
                        }
                        else
                        {
                            outlet = m_currentSelectedLet;
                            inlet  = (Let)sender;
                        }

                        Connection connection = new Connection((Inlet)inlet, (Outlet)outlet, m_livePoints);
                        inlet.Connections.Add(connection);
                        outlet.Connections.Add(connection);

                        if (Application.isPlaying)
                        {
                            ((Outlet)outlet).MakeConnections();
                            //   ((Outlet)outlet).Emit += ((Inlet)inlet).Slot;
                        }
                        //if ( !inlet.Contains(outlet) &&
                        //    !outlet.Contains(inlet) )
                        //{

                        //}
                        //else
                        //{
                        //    Debug.LogError("has let ====");
                        //}

                        m_livePoints.Clear();
                        m_currentMouseMode = MouseModes.IDLE;
                    }
                }
            }
        }
Пример #3
0
 void OnLetDrag(object sender, LetTypes type)
 {
     if (sender != m_currentSelectedLet)
     {
         Let senderLet = (Let)sender;
         if (senderLet.Owner != m_currentSelectedLet.Owner)
         {
             if ((m_currentSelectedLet.Type == LetTypes.INLET && type == LetTypes.OUTLET) ||
                 (m_currentSelectedLet.Type == LetTypes.OUTLET && type == LetTypes.INLET))
             {
                 // Valid connection
             }
         }
     }
 }
Пример #4
0
        public override void WindowCallback(int id)
        {
            GUI.BeginGroup(new Rect(5, y, 100, 50));

            int newNum = EditorGUILayout.IntField(Outlets, GUILayout.MaxWidth(80));

            newNum = Mathf.Clamp(newNum, 1, 100);
            if (newNum < Outlets)
            {
                int remove = Outlets - newNum;

                for (int i = 0; i < remove; i++)
                {
                    Let letToRemove = m_outlets[m_outlets.Count - 1];
                    DestroyLet(letToRemove);
                    m_outlets.Remove((Outlet)letToRemove);
                    y -= 25;
                }

                Size = new Vector2(Size.x, 55 + y);

                Outlets = newNum;
            }
            else if (newNum > Outlets)
            {
                int add = newNum - Outlets;

                for (int i = 0; i < add; i++)
                {
                    Outlet outlet = MakeLet <Outlet>("Outlet " + m_outlets.Count.ToString(), y);
                    m_outlets.Add(outlet);

                    y += 25;
                }

                Size = new Vector2(Size.x, 55 + y);

                Outlets = newNum;
            }

            GUI.EndGroup();

            base.WindowCallback(id);
        }
Пример #5
0
 public override void RemoveLet(Let letToRemove)
 {
     base.RemoveLet(letToRemove);
     MakeConnections();
 }
Пример #6
0
 protected void DestroyLet(Let let)
 {
     m_lets.Remove(let);
     DestroyImmediate(let);
 }
Пример #7
0
 void OnLetPressed(object sender, LetTypes type)
 {
     m_currentSelectedLet = (Let)sender;
     m_startMousePos      = Event.current.mousePosition;
     m_currentMouseMode   = MouseModes.CONNECTING;
 }
Пример #8
0
        void OnGUI()
        {
            if (GUI.Button(new Rect(10, 10, 80, 30), "New"))
            {
                OnDestroy();
                Clear();
                chatID = 1000 + PersuadeSystem.Instacne.persuadeGroup.persuadeGroup.Count;
                Repaint();
            }
            if (GUI.Button(new Rect(10, 50, 80, 30), "Open"))
            {
                ChatJsonWindow.Open(JsonWindow.Persuade);
            }
            if (GUI.Button(new Rect(10, 90, 80, 30), "Save"))
            {
                EditorPersuadeData editorPersuade = new EditorPersuadeData();
                SetPersuadeData(editorPersuade);
                editorPersuade.m_describe = m_describeLab;
                PersuadeSystem.Instacne.SaveEditorData(m_nodes, chatID, editorPersuade);
            }

            if (GUI.Button(new Rect(10, 130, 80, 30), "Ouput"))
            {
                EditorPersuadeData editorPersuade = new EditorPersuadeData();
                SetPersuadeData(editorPersuade);
                editorPersuade.m_describe = m_describeLab;
                PersuadeData persuadeData = new PersuadeData();
                SetPersuadeData(persuadeData);
                PersuadeSystem.Instacne.SaveData(m_nodes, chatID, editorPersuade, persuadeData);
            }
            GUI.BeginGroup(new Rect(100, 5, 500, 400));
            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("ID:", GUILayout.MaxWidth(150));
            chatID = EditorGUILayout.IntField(chatID);
            EditorGUILayout.EndHorizontal();
            //m_bgImg = EditorGUILayout.ObjectField(m_bgImg, typeof(Texture), GUILayout.MaxWidth(180)) as Texture;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("描述(策划看):", GUILayout.MaxWidth(150));
            m_describeLab = EditorGUILayout.TextArea(m_describeLab);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("名称:", GUILayout.MaxWidth(150));
            persuadeName = EditorGUILayout.TextArea(persuadeName);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("开头介绍:", GUILayout.MaxWidth(150));
            introduce = EditorGUILayout.TextArea(introduce);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("关键证人ID:", GUILayout.MaxWidth(150));
            npcId = EditorGUILayout.LongField(npcId);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("证据ID数组0,1,2:", GUILayout.MaxWidth(150));
            evidenceIds = EditorGUILayout.TextField(evidenceIds);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
            GUI.EndGroup();
            //GUI.BeginGroup(new Rect(100, 15, 200, 50));
            //GUI.EndGroup();
            var nodesToRemove = new List <int>();

            for (int i = 0; i < m_nodes.Count; i++)
            {
                if (m_nodes[i] == null)
                {
                    nodesToRemove.Add(i);
                }
            }

            for (int i = 0; i < nodesToRemove.Count; i++)
            {
                m_nodes.RemoveAt(nodesToRemove[i] - i);
            }

            BeginWindows();

            for (int i = 0; i < m_nodes.Count; i++)
            {
                m_nodes[i].Draw();
            }

            EndWindows();

            bool       isConnectionSelected = false;
            Connection connectionSelected   = null;
            float      minDistance          = float.MaxValue;

            // Collect connections
            List <Connection> connections = new List <Connection>();
            int selectedConnection        = -1;

            for (int i = 0; i < m_nodes.Count; i++)
            {
                for (int j = 0; j < m_nodes[i].Lets.Count; j++)
                {
                    Let outlet = m_nodes[i].Lets[j];
                    if (outlet.Type == LetTypes.OUTLET)
                    {
                        for (int k = 0; k < outlet.Connections.Count; k++)
                        {
                            Connection connection = outlet.Connections[k];
                            connections.Add(connection);

                            List <Vector2> points = new List <Vector2>();
                            points.Add(new Vector2(connection.Inlet.Position.center.x, connection.Inlet.Position.center.y));
                            for (int l = 0; l < connection.Points.Length; l++)
                            {
                                points.Add(connection.Points[l]);
                            }
                            points.Add(new Vector2(connection.Outlet.Position.center.x, connection.Outlet.Position.center.y));

                            for (int l = 0; l < points.Count - 1; l++)
                            {
                                float distance = MouseDistanceToLine(points[l], points[l + 1]);

                                if (distance < 20.0f)
                                {
                                    if (distance < minDistance)
                                    {
                                        minDistance          = distance;
                                        isConnectionSelected = true;
                                        connectionSelected   = connection;
                                        selectedConnection   = connections.Count - 1;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Draw connections
            for (int i = 0; i < connections.Count; i++)
            {
                Connection connection = connections[i];

                List <Vector2> points = new List <Vector2>();
                points.Add(connection.Inlet.Position.center);
                for (int j = 0; j < connection.Points.Length; j++)
                {
                    points.Add(connection.Points[j]);
                }
                points.Add(connection.Outlet.Position.center);

                for (int j = 0; j < points.Count - 1; j++)
                {
                    if (i != selectedConnection)
                    {
                        DrawLine(points[j], points[j + 1], ConnectionColor);
                    }
                    else
                    {
                        DrawLine(points[j], points[j + 1], Color.blue);
                    }
                }
            }

            // Process events
            if (Event.current.type == EventType.MouseMove)
            {
                bool handled = false;
                for (int i = 0; i < m_nodes.Count; i++)
                {
                    if (m_nodes[i].MouseOver(Event.current.mousePosition))
                    {
                        handled = true;

                        break;
                    }
                }

                if (!handled)
                {
                    // Do something
                }

                Repaint();
            }
            else if (Event.current.type == EventType.MouseDown && m_currentMouseMode != MouseModes.CONNECTING)
            {
                bool handled = false;
                for (int i = 0; i < m_nodes.Count; i++)
                {
                    if (m_nodes[i].MouseDown(Event.current.mousePosition, Event.current.button))
                    {
                        handled = true;
                    }
                }

                if (!handled && Event.current.button == 1)
                {
                    if (!isConnectionSelected)
                    {
                        CreateNodeMenu();
                    }
                    else
                    {
                        BreakConnectionMenu(connectionSelected.Inlet, connectionSelected.Outlet);
                    }
                }
                else if (!handled && Event.current.button == 0)
                {
                    m_startMousePos = Event.current.mousePosition;
                }
            }
            else if (Event.current.type == EventType.MouseDown && m_currentMouseMode == MouseModes.CONNECTING)
            {
                if (Event.current.button == 0)
                {
                    m_livePoints.Add(Event.current.mousePosition);
                    Repaint();
                }
                else if (Event.current.button == 1)
                {
                    m_currentMouseMode = MouseModes.IDLE;
                    m_livePoints.Clear();
                }
            }
            else if (Event.current.type == EventType.MouseDrag)
            {
                bool handled = false;
                for (int i = 0; i < m_nodes.Count; i++)
                {
                    if (m_nodes[i].MouseDrag(Event.current.mousePosition))
                    {
                        handled = true;
                        break;
                    }
                }

                if (!handled)
                {
                    if (Event.current.shift)
                    {
                        Vector2 offset = Event.current.mousePosition - m_startMousePos;
                        for (int i = 0; i < m_nodes.Count; i++)
                        {
                            m_nodes[i].Position += offset;
                        }

                        Repaint();

                        m_startMousePos = Event.current.mousePosition;
                        handled         = true;
                    }
                }
            }
            else if (Event.current.type == EventType.MouseUp)
            {
                for (int i = 0; i < m_nodes.Count; i++)
                {
                    m_nodes[i].MouseUp(Event.current.mousePosition);
                }
            }

            if (m_currentMouseMode == MouseModes.CONNECTING)
            {
                List <Vector2> points = new List <Vector2>();
                points.Add(m_startMousePos);
                for (int i = 0; i < m_livePoints.Count; i++)
                {
                    points.Add(m_livePoints[i]);
                }
                points.Add(Event.current.mousePosition);

                for (int i = 0; i < points.Count - 1; i++)
                {
                    DrawConnectingCurve(points[i], points[i + 1]);
                }

                Repaint();
            }

            List <BaseNode> nodesToDelete = new List <BaseNode>();

            foreach (BaseNode node in m_nodes)
            {
                if (!node.Valid)
                {
                    nodesToDelete.Add(node);
                }
            }

            foreach (BaseNode node in nodesToDelete)
            {
                m_nodes.Remove(node);

                node.BreakAllLets();

                // DestroyImmediate(node.gameObject);
            }

            if (nodesToDelete.Count > 0)
            {
                Repaint();
            }
        }
Пример #9
0
        void OnGUI()
        {
            if (m_nodegraphStack.Count > 0)
            {
                if (GUI.Button(new Rect(10, 10, 200, 50), "Back"))
                {
                    // Pop nodegraph stack
                    GoBack();

                    return;
                }
            }

            var nodesToRemove = new List <int>();

            for (int i = 0; i < m_nodes.Count; i++)
            {
                if (m_nodes[i] == null)
                {
                    nodesToRemove.Add(i);
                }
            }

            for (int i = 0; i < nodesToRemove.Count; i++)
            {
                m_nodes.RemoveAt(nodesToRemove[i] - i);
            }

            BeginWindows();

            for (int i = 0; i < m_nodes.Count; i++)
            {
                m_nodes[i].Draw();
            }

            EndWindows();

            bool       isConnectionSelected = false;
            Connection connectionSelected   = null;
            float      minDistance          = float.MaxValue;

            // Collect connections
            List <Connection> connections = new List <Connection>();
            int selectedConnection        = -1;

            for (int i = 0; i < m_nodes.Count; i++)
            {
                for (int j = 0; j < m_nodes[i].Lets.Count; j++)
                {
                    Let outlet = m_nodes[i].Lets[j];
                    if (outlet.Type == LetTypes.OUTLET)
                    {
                        for (int k = 0; k < outlet.Connections.Count; k++)
                        {
                            Connection connection = outlet.Connections[k];
                            connections.Add(connection);

                            List <Vector2> points = new List <Vector2>();
                            points.Add(new Vector2(connection.Inlet.Position.center.x, connection.Inlet.Position.center.y));
                            for (int l = 0; l < connection.Points.Length; l++)
                            {
                                points.Add(connection.Points[l]);
                            }
                            points.Add(new Vector2(connection.Outlet.Position.center.x, connection.Outlet.Position.center.y));

                            for (int l = 0; l < points.Count - 1; l++)
                            {
                                float distance = MouseDistanceToLine(points[l], points[l + 1]);

                                if (distance < 20.0f)
                                {
                                    if (distance < minDistance)
                                    {
                                        minDistance          = distance;
                                        isConnectionSelected = true;
                                        connectionSelected   = connection;
                                        selectedConnection   = connections.Count - 1;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Draw connections
            for (int i = 0; i < connections.Count; i++)
            {
                Connection connection = connections[i];

                List <Vector2> points = new List <Vector2>();
                points.Add(connection.Inlet.Position.center);
                for (int j = 0; j < connection.Points.Length; j++)
                {
                    points.Add(connection.Points[j]);
                }
                points.Add(connection.Outlet.Position.center);

                for (int j = 0; j < points.Count - 1; j++)
                {
                    if (i != selectedConnection)
                    {
                        DrawLine(points[j], points[j + 1], ConnectionColor);
                    }
                    else
                    {
                        DrawLine(points[j], points[j + 1], Color.blue);
                    }
                }
            }

            // Process events
            if (Event.current.type == EventType.MouseMove)
            {
                bool handled = false;
                for (int i = 0; i < m_nodes.Count; i++)
                {
                    if (m_nodes[i].MouseOver(Event.current.mousePosition))
                    {
                        handled = true;

                        break;
                    }
                }

                if (!handled)
                {
                    // Do something
                }

                Repaint();
            }
            else if (Event.current.type == EventType.MouseDown && m_currentMouseMode != MouseModes.CONNECTING)
            {
                bool handled = false;
                for (int i = 0; i < m_nodes.Count; i++)
                {
                    if (m_nodes[i].MouseDown(Event.current.mousePosition, Event.current.button))
                    {
                        handled = true;
                    }
                }

                if (!handled && Event.current.button == 1)
                {
                    if (!isConnectionSelected)
                    {
                        CreateNodeMenu();
                    }
                    else
                    {
                        BreakConnectionMenu(connectionSelected.Inlet, connectionSelected.Outlet);
                    }
                }
                else if (!handled && Event.current.button == 0)
                {
                    m_startMousePos = Event.current.mousePosition;
                }
            }
            else if (Event.current.type == EventType.MouseDown && m_currentMouseMode == MouseModes.CONNECTING)
            {
                if (Event.current.button == 0)
                {
                    m_livePoints.Add(Event.current.mousePosition);
                    Repaint();
                }
                else if (Event.current.button == 1)
                {
                    m_currentMouseMode = MouseModes.IDLE;
                    m_livePoints.Clear();
                }
            }
            else if (Event.current.type == EventType.MouseDrag)
            {
                bool handled = false;
                for (int i = 0; i < m_nodes.Count; i++)
                {
                    if (m_nodes[i].MouseDrag(Event.current.mousePosition))
                    {
                        handled = true;
                        break;
                    }
                }

                if (!handled)
                {
                    if (Event.current.shift)
                    {
                        Vector2 offset = Event.current.mousePosition - m_startMousePos;
                        for (int i = 0; i < m_nodes.Count; i++)
                        {
                            m_nodes[i].Position += offset;
                        }

                        Repaint();

                        m_startMousePos = Event.current.mousePosition;
                        handled         = true;
                    }
                }
            }
            else if (Event.current.type == EventType.MouseUp)
            {
                for (int i = 0; i < m_nodes.Count; i++)
                {
                    m_nodes[i].MouseUp(Event.current.mousePosition);
                }
            }

            if (m_currentMouseMode == MouseModes.CONNECTING)
            {
                List <Vector2> points = new List <Vector2>();
                points.Add(m_startMousePos);
                for (int i = 0; i < m_livePoints.Count; i++)
                {
                    points.Add(m_livePoints[i]);
                }
                points.Add(Event.current.mousePosition);

                for (int i = 0; i < points.Count - 1; i++)
                {
                    DrawConnectingCurve(points[i], points[i + 1]);
                }

                Repaint();
            }

            List <BaseNode> nodesToDelete = new List <BaseNode>();

            foreach (BaseNode node in m_nodes)
            {
                if (!node.Valid)
                {
                    nodesToDelete.Add(node);
                }
            }

            foreach (BaseNode node in nodesToDelete)
            {
                m_nodes.Remove(node);

                node.BreakAllLets();

                DestroyImmediate(node.gameObject);
            }

            if (nodesToDelete.Count > 0)
            {
                Repaint();
            }
        }
Пример #10
0
        void OnGUI()
        {
            if (GUI.Button(new Rect(10, 10, 80, 30), "New"))
            {
                OnDestroy();
                Clear();
                chatID = 1000 + ChatSystemManager.Instacne.chatGroup.m_chats.Count;
                Repaint();
            }
            if (GUI.Button(new Rect(10, 50, 80, 30), "Open"))
            {
                ChatJsonWindow.Open();
            }
            if (GUI.Button(new Rect(10, 90, 80, 30), "Save"))
            {
                string bgName = string.Empty;
                if (m_bgImg != null)
                {
                    bgName = UnityEditor.AssetDatabase.GetAssetPath(m_bgImg);
                }
                ChatSystemManager.Instacne.SaveEditorChatData(m_nodes, bgName, chatID, m_describeLab);
            }

            if (GUI.Button(new Rect(10, 130, 80, 30), "Ouput"))
            {
                //string bgName = string.Empty;
                //if (m_bgImg != null)
                //{
                //    bgName = m_bgImg.name + ".png";
                //}
                ChatSystemManager.Instacne.SaveChatData(m_nodes, m_bgImg, chatID, m_describeLab);
            }
            GUI.BeginGroup(new Rect(100, 5, 200, 200));
            EditorGUILayout.BeginVertical();
            chatID        = EditorGUILayout.IntField(chatID);
            m_bgImg       = EditorGUILayout.ObjectField(m_bgImg, typeof(Texture), GUILayout.MaxWidth(180)) as Texture;
            m_describeLab = EditorGUILayout.TextArea(m_describeLab);
            EditorGUILayout.EndVertical();
            GUI.EndGroup();
            //GUI.BeginGroup(new Rect(100, 15, 200, 50));
            //GUI.EndGroup();
            var nodesToRemove = new List <int>();

            for (int i = 0; i < m_nodes.Count; i++)
            {
                if (m_nodes[i] == null)
                {
                    nodesToRemove.Add(i);
                }
            }

            for (int i = 0; i < nodesToRemove.Count; i++)
            {
                m_nodes.RemoveAt(nodesToRemove[i] - i);
            }

            BeginWindows();

            for (int i = 0; i < m_nodes.Count; i++)
            {
                m_nodes[i].Draw();
            }

            EndWindows();

            bool       isConnectionSelected = false;
            Connection connectionSelected   = null;
            float      minDistance          = float.MaxValue;

            // Collect connections
            List <Connection> connections = new List <Connection>();
            int selectedConnection        = -1;

            for (int i = 0; i < m_nodes.Count; i++)
            {
                for (int j = 0; j < m_nodes[i].Lets.Count; j++)
                {
                    Let outlet = m_nodes[i].Lets[j];
                    if (outlet.Type == LetTypes.OUTLET)
                    {
                        for (int k = 0; k < outlet.Connections.Count; k++)
                        {
                            Connection connection = outlet.Connections[k];
                            connections.Add(connection);

                            List <Vector2> points = new List <Vector2>();
                            points.Add(new Vector2(connection.Inlet.Position.center.x, connection.Inlet.Position.center.y));
                            for (int l = 0; l < connection.Points.Length; l++)
                            {
                                points.Add(connection.Points[l]);
                            }
                            points.Add(new Vector2(connection.Outlet.Position.center.x, connection.Outlet.Position.center.y));

                            for (int l = 0; l < points.Count - 1; l++)
                            {
                                float distance = MouseDistanceToLine(points[l], points[l + 1]);

                                if (distance < 20.0f)
                                {
                                    if (distance < minDistance)
                                    {
                                        minDistance          = distance;
                                        isConnectionSelected = true;
                                        connectionSelected   = connection;
                                        selectedConnection   = connections.Count - 1;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Draw connections
            for (int i = 0; i < connections.Count; i++)
            {
                Connection connection = connections[i];

                List <Vector2> points = new List <Vector2>();
                points.Add(connection.Inlet.Position.center);
                for (int j = 0; j < connection.Points.Length; j++)
                {
                    points.Add(connection.Points[j]);
                }
                points.Add(connection.Outlet.Position.center);

                for (int j = 0; j < points.Count - 1; j++)
                {
                    if (i != selectedConnection)
                    {
                        DrawLine(points[j], points[j + 1], ConnectionColor);
                    }
                    else
                    {
                        DrawLine(points[j], points[j + 1], Color.blue);
                    }
                }
            }

            // Process events
            if (Event.current.type == EventType.MouseMove)
            {
                bool handled = false;
                for (int i = 0; i < m_nodes.Count; i++)
                {
                    if (m_nodes[i].MouseOver(Event.current.mousePosition))
                    {
                        handled = true;

                        break;
                    }
                }

                if (!handled)
                {
                    // Do something
                }

                Repaint();
            }
            else if (Event.current.type == EventType.MouseDown && m_currentMouseMode != MouseModes.CONNECTING)
            {
                bool handled = false;
                for (int i = 0; i < m_nodes.Count; i++)
                {
                    if (m_nodes[i].MouseDown(Event.current.mousePosition, Event.current.button))
                    {
                        handled = true;
                    }
                }

                if (!handled && Event.current.button == 1)
                {
                    if (!isConnectionSelected)
                    {
                        CreateNodeMenu();
                    }
                    else
                    {
                        BreakConnectionMenu(connectionSelected.Inlet, connectionSelected.Outlet);
                    }
                }
                else if (!handled && Event.current.button == 0)
                {
                    m_startMousePos = Event.current.mousePosition;
                }
            }
            else if (Event.current.type == EventType.MouseDown && m_currentMouseMode == MouseModes.CONNECTING)
            {
                if (Event.current.button == 0)
                {
                    m_livePoints.Add(Event.current.mousePosition);
                    Repaint();
                }
                else if (Event.current.button == 1)
                {
                    m_currentMouseMode = MouseModes.IDLE;
                    m_livePoints.Clear();
                }
            }
            else if (Event.current.type == EventType.MouseDrag)
            {
                bool handled = false;
                for (int i = 0; i < m_nodes.Count; i++)
                {
                    if (m_nodes[i].MouseDrag(Event.current.mousePosition))
                    {
                        handled = true;
                        break;
                    }
                }

                if (!handled)
                {
                    if (Event.current.shift)
                    {
                        Vector2 offset = Event.current.mousePosition - m_startMousePos;
                        for (int i = 0; i < m_nodes.Count; i++)
                        {
                            m_nodes[i].Position += offset;
                        }

                        Repaint();

                        m_startMousePos = Event.current.mousePosition;
                        handled         = true;
                    }
                }
            }
            else if (Event.current.type == EventType.MouseUp)
            {
                for (int i = 0; i < m_nodes.Count; i++)
                {
                    m_nodes[i].MouseUp(Event.current.mousePosition);
                }
            }

            if (m_currentMouseMode == MouseModes.CONNECTING)
            {
                List <Vector2> points = new List <Vector2>();
                points.Add(m_startMousePos);
                for (int i = 0; i < m_livePoints.Count; i++)
                {
                    points.Add(m_livePoints[i]);
                }
                points.Add(Event.current.mousePosition);

                for (int i = 0; i < points.Count - 1; i++)
                {
                    DrawConnectingCurve(points[i], points[i + 1]);
                }

                Repaint();
            }

            List <BaseNode> nodesToDelete = new List <BaseNode>();

            foreach (BaseNode node in m_nodes)
            {
                if (!node.Valid)
                {
                    nodesToDelete.Add(node);
                }
            }

            foreach (BaseNode node in nodesToDelete)
            {
                m_nodes.Remove(node);

                node.BreakAllLets();

                // DestroyImmediate(node.gameObject);
            }

            if (nodesToDelete.Count > 0)
            {
                Repaint();
            }
        }
Пример #11
0
 public Signal(Let sender, SignalArgs args)
 {
     Sender = sender;
     Args   = args;
 }