Exemplo n.º 1
0
        public int AddBlock(GraphItem graphItem)
        {
            graphItem.BlockID = graphItem.BlockID == -1 ? blockId++ : graphItem.BlockID;
            locatedItemList.Add(graphItem);

            return(graphItem.BlockID);
        }
Exemplo n.º 2
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();
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void ShowProperty(GraphItem node)
        {
            gameObject.SetActive(true);
            ifNode = node as IFBranchItem;
            BranchCondition data = ifNode.GetIFBranchData();

            nodeTitleInput.text   = ifNode.GetBlockTitle;
            ifTypeDrowpdown.value = (int)data.lParamType;
            nodeNameInput.text    = ifNode.GetBlockName;

            nodeTitleInput.onValueChanged.AddListener(ifNode.SetBlockTitle);
            ifTypeDrowpdown.onValueChanged.AddListener(ifNode.SetLParamType);
            nodeNameInput.onValueChanged.AddListener(ifNode.SetBlockName);

            operatorDropdown.value = (int)data.opParameter;
            operatorDropdown.onValueChanged.AddListener(ifNode.SetOpParamType);

            nodeTypeText.text   = node.GetNodeType.ToString();
            nodeIDText.text     = node.BlockID.ToString();
            nodeValueInput.text = data.rParameter;
            nodeValueInput.onValueChanged.AddListener(ifNode.SetRParamValue);

            int nextID = ifNode.GetTrueExecutePoint.GetLineData != null ? ifNode.GetTrueExecutePoint.GetLineData.GetRightExecutePointInfo.blockID : -1;

            trueNextIDText.text = nextID.ToString();

            nextID = ifNode.GetFalseExecutePoint.GetLineData != null ? ifNode.GetFalseExecutePoint.GetLineData.GetRightExecutePointInfo.blockID : -1;
            falseNextIDText.text = nextID.ToString();
        }
Exemplo n.º 4
0
        public override void ShowPopup(GraphItem targetItem = null)
        {
            base.ShowPopup(targetItem);

            // Init scroll position.
            content.localPosition = Vector2.zero;

            // Set event list.
            if (eventCategories == null || eventCategories.Length == 0)
            {
                ReadEventList();
                SetEventCategories();
            }

            // Set item selected status.
            if (targetItem != null && targetItem.GetItemData() != null)
            {
                for (int ix = 0; ix < eventListItems.Count; ++ix)
                {
                    if (Util.CompareTwoStrings(eventListItems[ix].GetEventName(), targetItem.GetItemData().ToString()))
                    {
                        eventListItems[ix].SetItemSelected(true);
                        break;
                    }
                }
            }
        }
Exemplo n.º 5
0
        // Copy/Paste를 통해 블록 복제할 때 사용하는 메소드.
        public void DuplicateBlocks(List <GraphItem> blocks)
        {
            GameObject paneObj = EditorManager.Instance.GetPaneObject(EPaneType.Graph_Pane);
            GraphPane  pane    = paneObj.GetComponent <GraphPane>();

            // 모든 블록 선택 해제.
            SetAllUnselected();

            // 변경 이전의 ID와 변경된 ID 저장용 딕셔너리 초기화.
            changedIDTable = new Dictionary <int, int>();

            for (int ix = 0; ix < blocks.Count; ++ix)
            {
                GraphItem prefab   = EditorManager.Instance.GetNodePrefab(blocks[ix].GetNodeType);
                Vector3   blockPos = blocks[ix].GetComponent <RectTransform>().position;
                blockPos += new Vector3(25f, -25f, 0f);
                //pane.AddNodeItem(prefab.gameObject, blockPos, blocks[ix].GetNodeType, blockId++);
                pane.AddNodeItem(prefab.gameObject, blocks[ix], blockPos, blockId++);

                // 추가된 블록 선택.
                SetSelectedGraphItem(locatedItemList[locatedItemList.Count - 1]);

                // 변경전 ID 값 - 변경된 ID 값 기록.
                changedIDTable.Add(blocks[ix].BlockID, blockId - 1);
            }
        }
Exemplo n.º 6
0
        private void CreateBlocks(NodeBlockArray blockData)
        {
            GameObject paneObj = EditorManager.Instance.GetPaneObject(EPaneType.Graph_Pane);
            GraphPane  pane    = paneObj.GetComponent <GraphPane>();

            int maxID = blockId;

            if (blockData.Length == -1)
            {
                return;
            }

            for (int ix = 0; ix < blockData.Length; ++ix)
            {
                GraphItem prefab = EditorManager.Instance.GetNodePrefab(blockData[ix].nodeType);
                //pane.AddNodeItem(prefab.gameObject, blockData[ix].position, blockData[ix].nodeType, blockData[ix].id);
                pane.AddNodeItem(prefab.gameObject, blockData[ix]);

                if (blockData[ix].id >= maxID)
                {
                    maxID = blockData[ix].id + 1;
                }
            }

            blockId = maxID;
        }
Exemplo n.º 7
0
 public override void ShowPopup(GraphItem targetItem = null)
 {
     gameObject.SetActive(true);
     if (targetItem)
     {
         SetTargetItem(targetItem);
     }
 }
Exemplo n.º 8
0
 public void SetBlockSelectedByDrag(GraphItem graphItem)
 {
     if (!CheckIfBlockSelected(graphItem))
     {
         curSelectedItemList.Add(graphItem);
         graphItem.SetSelected();
     }
 }
Exemplo n.º 9
0
        public override void ShowPopup(GraphItem targetItem = null)
        {
            if (targetItem && targetItem.GetItemData() != null)
            {
                inputField.text = targetItem.GetItemData() as string;
            }

            base.ShowPopup(targetItem);
        }
Exemplo n.º 10
0
        public void SetSelectedGraphItem(GraphItem graphItem)
        {
            int removeIndex = SetBlockUnSelected(graphItem);

            if (removeIndex == 0)
            {
                curSelectedItemList.Add(graphItem);
                graphItem.SetSelected();
            }
        }
Exemplo n.º 11
0
        private bool CheckIfBlockSelected(GraphItem graphItem)
        {
            for (int ix = 0; ix < curSelectedItemList.Count; ++ix)
            {
                if (curSelectedItemList[ix].BlockID.Equals(graphItem.BlockID))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 12
0
        public void AddNodeItem(GameObject itemPrefab, NodeBlock nodeData)
        {
            // Create Block on to block pane.
            GameObject    newObj        = Instantiate(itemPrefab);
            RectTransform rectTransform = newObj.GetComponent <RectTransform>();

            rectTransform.SetParent(blockPane);
            rectTransform.position   = nodeData.position;
            rectTransform.localScale = Vector3.one;
            GraphItem graphItem = newObj.GetComponent <GraphItem>();

            graphItem.BlockID = nodeData.id;
            graphItem.SetBlockTitle(nodeData.title);
            graphItem.SetItemData(nodeData.value);

            if (nodeData.nodeType == NodeType.SWITCH)
            {
                SwitchBranchItem switchNode = graphItem as SwitchBranchItem;
                switchNode.SetSwitchName(nodeData.name);
                switchNode.SetBlockCount(nodeData.switchBlockCount);

                for (int ix = 1; ix < nodeData.switchBlockCount + 1; ++ix)
                {
                    if (switchNode.executePoints[ix] is ExecuteCasePoint)
                    {
                        ExecuteCasePoint casePoint = switchNode.executePoints[ix] as ExecuteCasePoint;
                        casePoint.CaseValue = nodeData.switchBlockValues[ix - 1];
                    }
                }
            }

            else if (nodeData.nodeType == NodeType.VARIABLE)
            {
                VariableItem variableNode = graphItem as VariableItem;
                variableNode.SetBlockName(nodeData.name);
                variableNode.SetBlockName(nodeData.name);
                variableNode.SetOperatorType(nodeData.variableOperator);
            }

            else if (nodeData.nodeType == NodeType.IF)
            {
                IFBranchItem ifNode = graphItem as IFBranchItem;
                ifNode.SetBlockName(nodeData.name);
                ifNode.SetOpParamType((int)ifNode.GetOpTypeFromString(nodeData.variableOperator));
                ifNode.SetRParamValue(nodeData.value);
                ifNode.SetLParamType((int)nodeData.ifBranchType);
            }

            // Add Block Information to Block Diagram Manager.
            WorkspaceManager.Instance.AddBlock(graphItem);
        }
Exemplo n.º 13
0
        public int SetBlockUnSelected(GraphItem graphItem)
        {
            for (int ix = 0; ix < curSelectedItemList.Count; ++ix)
            {
                if (curSelectedItemList[ix].BlockID.Equals(graphItem.BlockID))
                {
                    curSelectedItemList[ix].SetUnselected();
                    curSelectedItemList.RemoveAt(ix);
                    return(ix);
                }
            }

            return(0);
        }
Exemplo n.º 14
0
        public void ShowProperty(GraphItem node)
        {
            TurnOffAll();

            switch (node.GetNodeType)
            {
            case NodeType.SWITCH: switchNodeWindow.ShowProperty(node); break;

            case NodeType.VARIABLE: variableNodeWindow.ShowProperty(node); break;

            case NodeType.IF: ifNodeWindow.ShowProperty(node); break;

            default: generalNodeWindow.ShowProperty(node); break;
            }
        }
Exemplo n.º 15
0
        public void AddNodeItem(GameObject itemPrefab, Vector3 itemPosition, NodeType nodeType, int nodeID = -1)
        {
            // Create Block on to block pane.
            GameObject    newObj        = Instantiate(itemPrefab);
            RectTransform rectTransform = newObj.GetComponent <RectTransform>();

            rectTransform.SetParent(blockPane);
            rectTransform.position   = itemPosition;
            rectTransform.localScale = Vector3.one;
            GraphItem graphItem = newObj.GetComponent <GraphItem>();

            graphItem.BlockID = nodeID;

            // Add Block Information to Block Diagram Manager.
            WorkspaceManager.Instance.AddBlock(graphItem);
        }
Exemplo n.º 16
0
        public void ShowProperty(GraphItem node)
        {
            gameObject.SetActive(true);

            nodeTitleInput.text = node.GetBlockTitle;

            normalNode = node;
            nodeTitleInput.onValueChanged.AddListener(normalNode.SetBlockTitle);

            nodeTypeText.text = node.GetNodeType.ToString();
            nodeIDText.text   = node.BlockID.ToString();

            nodeValueInput.text = node.GetItemData() != null?node.GetItemData() as string : string.Empty;

            nodeValueInput.onValueChanged.AddListener(normalNode.SetItemData);

            nextIDText.text = node.GetNextBlockID.ToString();
        }
Exemplo n.º 17
0
        public void AddNodeItem(GameObject itemPrefab, GraphItem node, Vector3 nodePos, int blockID)
        {
            // Create Block on to block pane.
            GameObject    newObj        = Instantiate(itemPrefab);
            RectTransform rectTransform = newObj.GetComponent <RectTransform>();

            rectTransform.SetParent(blockPane);
            rectTransform.position   = nodePos;
            rectTransform.localScale = Vector3.one;
            GraphItem graphItem = newObj.GetComponent <GraphItem>();

            graphItem.BlockID = blockID;
            graphItem.SetBlockTitle(node.GetBlockTitle);
            graphItem.SetItemData(node.GetItemData());

            if (node.GetNodeType == NodeType.SWITCH)
            {
                SwitchBranchItem switchNode      = graphItem as SwitchBranchItem;
                SwitchBranchItem givenSwitchNode = node as SwitchBranchItem;
                switchNode.SetBlockCount(givenSwitchNode.GetBlockCount);
                switchNode.SetSwitchType(givenSwitchNode.GetSwitchType);
                switchNode.SetSwitchName(givenSwitchNode.GetSwitchName);

                for (int ix = 1; ix < givenSwitchNode.GetBlockCount + 1; ++ix)
                {
                    if (switchNode.executePoints[ix] is ExecuteCasePoint)
                    {
                        ExecuteCasePoint casePoint = switchNode.executePoints[ix] as ExecuteCasePoint;
                        casePoint.CaseValue = (givenSwitchNode.executePoints[ix] as ExecuteCasePoint).CaseValue;
                    }
                }
            }

            else if (node.GetNodeType == NodeType.VARIABLE)
            {
                VariableItem variableNode      = graphItem as VariableItem;
                VariableItem givenVariableNode = node as VariableItem;
                variableNode.SetBlockName(givenVariableNode.GetBlockName);
                variableNode.SetOperatorType(givenVariableNode.GetOperatorType);
            }

            // Add Block Information to Block Diagram Manager.
            WorkspaceManager.Instance.AddBlock(graphItem);
        }
Exemplo n.º 18
0
        public void ShowProperty(GraphItem node)
        {
            gameObject.SetActive(true);

            nodeTitleInput.text = node.GetBlockTitle;

            switchNode = node as SwitchBranchItem;
            nodeTitleInput.onValueChanged.AddListener(switchNode.SetBlockTitle);

            nodeTypeText.text = node.GetNodeType.ToString();
            nodeIDText.text   = node.BlockID.ToString();

            switchTypeDropdown.value = (int)switchNode.GetSwitchType;
            switchTypeDropdown.onValueChanged.AddListener(switchNode.SetSwitchType);

            TurnOffAll();
            int blockCount = (node as SwitchBranchItem).GetBlockCount;

            TurnOnWithCount(blockCount);
            scrollRect.content.sizeDelta       = new Vector2(content.sizeDelta.x, defaultHeight + blockCount * itemHeight * 3);
            scrollRect.verticalScrollbar.value = 1f;

            // 0번은 ExecutePointLeft.
            // ExecutePointRight에 대해서만 처리하면 되기 때문에 index 1번 부터 순회.
            for (int ix = 0; ix < blockCount; ++ix)
            {
                ExecutePoint point  = node.executePoints[ix + 1];
                int          nextID = point.GetLineData != null ? point.GetLineData.GetRightExecutePointInfo.blockID : -1;

                if (point is ExecuteCasePoint)
                {
                    ExecuteCasePoint casePoint = point as ExecuteCasePoint;

                    caseBlocks[ix].SetProperty(casePoint.CaseValue, nextID.ToString());
                    caseBlocks[ix].valueInput.onValueChanged.AddListener(casePoint.SetCaseValue);
                }
            }

            ExecuteDefaultPoint defaultPoint = node.executePoints[node.executePoints.Length - 1] as ExecuteDefaultPoint;
            int defaultNextID = defaultPoint.GetLineData != null ? defaultPoint.GetLineData.GetRightExecutePointInfo.blockID : -1;

            defaultBlock.SetProperty(defaultNextID.ToString());
        }
Exemplo n.º 19
0
        public override void ShowPopup(GraphItem targetItem = null)
        {
            base.ShowPopup(targetItem);

            switchItem = targetItem as SwitchBranchItem;
            if (switchItem)
            {
                BranchCondition[] conditionData = switchItem.GetConditionData();
                for (int ix = 0; ix < conditionData.Length; ++ix)
                {
                    if (ix < 2)
                    {
                        switchBlocks[ix].SetDataToComponent(conditionData[ix]);
                        continue;
                    }

                    InsertBlock(conditionData[ix]);
                }
            }
        }
Exemplo n.º 20
0
        public void RemoveBlock(GraphItem graphItem)
        {
            if (locatedItemList == null || locatedItemList.Count == 0)
            {
                return;
            }

            for (int ix = 0; ix < locatedItemList.Count; ++ix)
            {
                if (locatedItemList[ix].BlockID.Equals(graphItem.BlockID))
                {
                    locatedItemList.RemoveAt(ix);
                    Destroy(graphItem.gameObject);
                }
            }

            if (locatedItemList.Count == 0)
            {
                blockId = 0;
            }
        }
Exemplo n.º 21
0
        public void BlockDrag(PointerEventData eventData, GraphItem graphItem = null)
        {
            // 드래드시 동작 현재 마우스 포인터가 위치한 블록 선택하기.
            if (graphItem != null && curSelectedItemList.Count == 1)
            {
                if (curSelectedItemList[0].BlockID != graphItem.BlockID)
                {
                    curSelectedItemList[0].SetUnselected();

                    graphItem.GetComponent <DragItem>().SetDragOffset(eventData.position);
                    graphItem.SetSelected();

                    curSelectedItemList[0] = graphItem;
                }
            }

            for (int ix = 0; ix < curSelectedItemList.Count; ++ix)
            {
                curSelectedItemList[ix].GetComponent <DragItem>().ChangePosition(eventData);
            }
        }
Exemplo n.º 22
0
        public void ShowProperty(GraphItem node)
        {
            gameObject.SetActive(true);

            variableNode        = node as VariableItem;
            nodeTitleInput.text = variableNode.GetBlockTitle;
            nodeNameInput.text  = variableNode.GetBlockName;

            nodeTitleInput.onValueChanged.AddListener(variableNode.SetBlockTitle);
            nodeNameInput.onValueChanged.AddListener(variableNode.SetBlockName);

            nodeOperatorDropdown.value = (int)variableNode.GetOperatorType;
            nodeOperatorDropdown.onValueChanged.AddListener(variableNode.SetOperatorType);

            nodeTypeText.text = node.GetNodeType.ToString();
            nodeIDText.text   = node.BlockID.ToString();

            nodeValueInput.text = node.GetItemData() != null?node.GetItemData().ToString() : "";

            nodeValueInput.onValueChanged.AddListener(variableNode.SetItemData);

            nextIDText.text = node.GetNextBlockID.ToString();
        }
Exemplo n.º 23
0
 public abstract void ShowPopup(GraphItem targetItem = null);
Exemplo n.º 24
0
 public override void SetTargetItem(GraphItem targetItem)
 {
     base.SetTargetItem(targetItem);
     targetIfItem = targetItem as IFBranchItem;
 }
Exemplo n.º 25
0
 public override void ShowPopup(GraphItem targetItem = null)
 {
     base.ShowPopup(targetItem);
     SetTargetItem(targetItem);
     SetPopupValues();
 }
Exemplo n.º 26
0
 public void SetOneSelected(GraphItem graphItem)
 {
     SetAllUnselected();
     SetSelectedGraphItem(graphItem);
 }
Exemplo n.º 27
0
 public virtual void SetTargetItem(GraphItem targetItem)
 {
     this.targetItem = targetItem;
 }
Exemplo n.º 28
0
 public int Compare(GraphItem x, GraphItem y)
 {
     return(x.BlockID.CompareTo(y.BlockID));
 }
Exemplo n.º 29
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);
            }
        }
Exemplo n.º 30
0
 private void OnDisable()
 {
     normalNode = null;
     nodeTitleInput.onValueChanged.RemoveAllListeners();
     nodeValueInput.onValueChanged.RemoveAllListeners();
 }