Exemple #1
0
        // Copy/Paste를 통해 라인 복제할 때 사용하는 메소드.
        public void DuplicateLines(List <GraphLine> lines)
        {
            for (int ix = 0; ix < lines.Count; ++ix)
            {
                int       leftID    = changedIDTable[lines[ix].GetLeftExecutePointInfo.blockID];
                int       rightID   = changedIDTable[lines[ix].GetRightExecutePointInfo.blockID];
                GraphItem leftItem  = GetGraphItem(leftID);
                GraphItem rightItem = GetGraphItem(rightID);

                ExecutePoint leftPoint  = null;
                ExecutePoint rightPoint = null;

                if (leftItem != null)
                {
                    leftPoint = leftItem.GetExecutePoint(ExecutePoint.PointPosition.ExecutePoint_Right, lines[ix].GetLeftExecutePointInfo.executePointID);
                }
                if (rightItem != null)
                {
                    rightPoint = rightItem.GetExecutePoint(ExecutePoint.PointPosition.ExecutePoint_Left);
                }

                if (leftItem != null && rightItem != null && leftPoint != null && rightPoint != null)
                {
                    GraphLine newLine = leftPoint.SetLineData(rightPoint);
                    if (newLine)
                    {
                        newLine.SetSelected();
                    }
                }
            }
        }
Exemple #2
0
        public virtual void OnPointerUp(PointerEventData eventData)
        {
            List <RaycastResult> result = new List <RaycastResult>();

            EditorManager.Instance.UIRaycaster.Raycast(eventData, result);

            if (pointPosition == PointPosition.ExecutePoint_Left)
            {
                if (SetLine(result, PointPosition.ExecutePoint_Right))
                {
                    return;
                }
            }
            else if (pointPosition == PointPosition.ExecutePoint_Right)
            {
                if (SetLine(result, PointPosition.ExecutePoint_Left))
                {
                    return;
                }
            }

            if (!hasLine && graphLine)
            {
                Destroy(graphLine.gameObject);
                graphLine = null;
            }
        }
Exemple #3
0
 public void SetLineSelectionByDrag(GraphLine graphLine)
 {
     if (!CheckIfLineSelected(graphLine))
     {
         curSelectedLineList.Add(graphLine);
         graphLine.SetSelected();
     }
 }
Exemple #4
0
 public void SetLineUnSelected(GraphLine graphLine)
 {
     for (int ix = 0; ix < curSelectedLineList.Count; ++ix)
     {
         if (curSelectedLineList[ix].GetLeftExecutePointInfo.blockID.Equals(graphLine.GetLeftExecutePointInfo.blockID) &&
             curSelectedLineList[ix].GetRightExecutePointInfo.blockID.Equals(graphLine.GetRightExecutePointInfo.blockID))
         {
             curSelectedLineList[ix].SetUnselected();
             curSelectedLineList.RemoveAt(ix);
         }
     }
 }
Exemple #5
0
        private bool CheckIfLineSelected(GraphLine graphLine)
        {
            for (int ix = 0; ix < curSelectedLineList.Count; ++ix)
            {
                if (curSelectedLineList[ix].GetLeftExecutePointInfo.blockID.Equals(graphLine.GetLeftExecutePointInfo.blockID) &&
                    curSelectedLineList[ix].GetRightExecutePointInfo.blockID.Equals(graphLine.GetRightExecutePointInfo.blockID))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #6
0
        public void RemoveLine(GraphLine graphLine)
        {
            if (locatedLineList == null || locatedLineList.Count == 0)
            {
                return;
            }

            for (int ix = 0; ix < locatedLineList.Count; ++ix)
            {
                if (locatedLineList[ix].GetLeftExecutePointInfo.blockID.Equals(graphLine.GetLeftExecutePointInfo.blockID) &&
                    locatedLineList[ix].GetRightExecutePointInfo.blockID.Equals(graphLine.GetRightExecutePointInfo.blockID))
                {
                    locatedLineList.RemoveAt(ix);
                    Destroy(graphLine.gameObject);
                }
            }
        }
Exemple #7
0
        public GraphLine SetLineData(ExecutePoint rightExecutePoint)
        {
            if (graphLine == null)
            {
                graphLine = CreateLineGO().GetComponent <GraphLine>();
            }

            linePoint.start = SelfPosition;
            linePoint.end   = rightExecutePoint.GetComponent <RectTransform>().position;
            graphLine.SetLinePoint(linePoint);
            graphLine.SetExecutePoints(this, rightExecutePoint);

            SetHasLine(true);
            rightExecutePoint.SetHasLine(true);

            return(graphLine);
        }
Exemple #8
0
        public virtual void OnPointerDown(PointerEventData eventData)
        {
            if (KeyInputManager.Instance.isAltPressed && graphLine)
            {
                WorkspaceManager.Instance.RemoveLine(graphLine);
                return;
            }

            if (hasLine)
            {
                return;
            }

            // create and set graph line.
            if (HasDragItem)
            {
                dragItem.SetEnableDrag(false);
            }

            GameObject newObj = CreateLineGO();

            graphLine = newObj.GetComponent <GraphLine>();
        }
Exemple #9
0
        public virtual void OnPointerDown(PointerEventData eventData)
        {
            if (isAltPressed && graphLine)
            {
                Destroy(graphLine.gameObject);
                return;
            }

            if (hasLine)
            {
                return;
            }

            // create and set graph line.
            if (HasDragItem)
            {
                dragItem.SetEnableDrag(false);
            }
            GameObject newObj = Instantiate(lineBasePrefab);

            newObj.transform.SetParent(transform);
            newObj.transform.localPosition = Vector3.zero;
            graphLine = newObj.GetComponent <GraphLine>();
        }
Exemple #10
0
 public void AddLine(GraphLine graphLine)
 {
     locatedLineList.Add(graphLine);
 }
Exemple #11
0
        private void CreateLines(LineBlockArray lineData)
        {
            if (lineData.Length == -1)
            {
                return;
            }

            for (int ix = 0; ix < lineData.Length; ++ix)
            {
                GraphItem leftItem  = GetGraphItem(lineData[ix].left.blockID);
                GraphItem rightItem = GetGraphItem(lineData[ix].right.blockID);

                if (leftItem.GetNodeType == NodeType.SWITCH)
                {
                    if (switchCounts.Count == 0)
                    {
                        switchCounts.Add(new SwitchCount()
                        {
                            nodeID = leftItem.BlockID, count = 1
                        });
                    }

                    else if (switchCounts.Count == 1 && !switchCounts[0].nodeID.Equals(leftItem.BlockID))
                    {
                        switchCounts.Add(new SwitchCount()
                        {
                            nodeID = leftItem.BlockID, count = 1
                        });
                    }

                    else
                    {
                        bool isProcessed = false;
                        foreach (SwitchCount item in switchCounts)
                        {
                            if (item.nodeID.Equals(leftItem.BlockID))
                            {
                                item.count++;
                                isProcessed = true;
                                break;
                            }
                        }

                        if (!isProcessed)
                        {
                            switchCounts.Add(new SwitchCount()
                            {
                                nodeID = leftItem.BlockID, count = 1
                            });
                        }
                    }
                }

                ExecutePoint leftPoint  = null;
                ExecutePoint rightPoint = null;

                if (leftItem != null)
                {
                    leftPoint = leftItem.GetExecutePoint(ExecutePoint.PointPosition.ExecutePoint_Right, lineData[ix].left.executePointID);
                }
                if (rightItem != null)
                {
                    rightPoint = rightItem.GetExecutePoint(ExecutePoint.PointPosition.ExecutePoint_Left);
                }

                if (leftItem != null && rightItem != null && leftPoint != null && rightPoint != null)
                {
                    GraphLine newLine = leftPoint.SetLineData(rightPoint);
                }
            }

            //Debug.Log("switchCount: " + switchCounts.Count);

            foreach (SwitchCount item in switchCounts)
            {
                GraphItem        node       = GetGraphItem(item.nodeID);
                SwitchBranchItem switchNode = node as SwitchBranchItem;
                switchNode.SetBlockCount(item.count - 1);
            }
        }