// 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(); } } } }
public void SetExecutePoints(ExecutePoint left, ExecutePoint right) { this.left = left; this.right = right; isSet = true; // Subscribe dragitem's OnChanged event to update line. left.GetTargetDragItem().SubscribeOnChanged(UpdateLine); right.GetTargetDragItem().SubscribeOnChanged(UpdateLine); }
public ExecutePoint GetExecutePoint(ExecutePoint.PointPosition pointPosition) { int childCount = transform.childCount; for (int ix = 0; ix < childCount; ++ix) { ExecutePoint executePoint = transform.GetChild(ix).GetComponent <ExecutePoint>(); if (executePoint != null && executePoint.GetPointPosition == pointPosition) { return(executePoint); } } return(null); }
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); }
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()); }
public void SetExecutePoints(ExecutePoint left, ExecutePoint right) { this.left = left; this.right = right; isSet = true; leftExecutePointInfo = new ExecutePointInfo( left.GetTargetDragItem().GetComponent <GraphItem>().BlockID, left.GetExecutePointID ); rightExecutePointInfo = new ExecutePointInfo( right.GetTargetDragItem().GetComponent <GraphItem>().BlockID, right.GetExecutePointID ); // Subscribe dragitem's OnChanged event to update line. left.GetTargetDragItem().SubscribeOnChanged(UpdateLine); right.GetTargetDragItem().SubscribeOnChanged(UpdateLine); }
public ExecutePoint GetExecutePoint(ExecutePoint.PointPosition pointPosition, int executePointID) { int childCount = transform.childCount; for (int ix = 0; ix < childCount; ++ix) { ExecutePoint[] executePoints = transform.GetChild(ix).GetComponentsInChildren <ExecutePoint>(true); for (int jx = 0; jx < executePoints.Length; ++jx) { ExecutePoint current = executePoints[jx]; if (current != null && current.GetPointPosition == pointPosition && current.GetExecutePointID.Equals(executePointID)) { current.SetExecutePointEnabled(true); return(current); } } } return(null); }
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); } }