Example #1
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();
        }
        private void SetPopupValues()
        {
            if (targetIfItem)
            {
                BranchCondition ifBranchItem = targetIfItem.GetIFBranchData();
                if (ifBranchItem == null || ifBranchItem.lParamType == BranchCondition.IFBranchParamType.None)
                {
                    return;
                }

                branchData.SetDataToComponent(ifBranchItem);
            }
        }
Example #3
0
        public static ProjectFormat GetSaveFormat(List <GraphItem> locatedItemList, List <GraphLine> locatedLineList, string projectName = "")
        {
            ProjectFormat project = new ProjectFormat();

            project.projectName = projectName;

            project.blockArray = new NodeBlockArray();
            for (int ix = 0; ix < locatedItemList.Count; ++ix)
            {
                NodeBlock block = new NodeBlock();
                block.nodeType = locatedItemList[ix].GetNodeType;
                block.id       = locatedItemList[ix].BlockID;
                block.title    = locatedItemList[ix].GetBlockTitle;
                block.value    = locatedItemList[ix].GetItemData() as string;
                block.position = locatedItemList[ix].GetComponent <RectTransform>().position;

                NodeType nodeType = locatedItemList[ix].GetNodeType;

                if (nodeType == NodeType.SWITCH)
                {
                    SwitchBranchItem switchNode = locatedItemList[ix] as SwitchBranchItem;
                    block.switchBlockCount = switchNode.GetBlockCount;
                    block.switchBranchType = switchNode.GetSwitchType;
                    block.name             = switchNode.GetSwitchName;
                    for (int jx = 0; jx < switchNode.GetBlockCount; ++jx)
                    {
                        ExecuteCasePoint casePoint = switchNode.executePoints[jx + 1] as ExecuteCasePoint;
                        block.switchBlockValues.Add(casePoint.CaseValue);
                    }
                }

                else if (nodeType == NodeType.VARIABLE)
                {
                    VariableItem variableNode = locatedItemList[ix] as VariableItem;
                    block.variableOperator = variableNode.GetOperatorType.ToString();
                    block.name             = variableNode.GetBlockName;
                }

                else if (nodeType == NodeType.IF)
                {
                    IFBranchItem    ifNode = locatedItemList[ix] as IFBranchItem;
                    BranchCondition data   = ifNode.GetIFBranchData();
                    block.name             = data.nameField;
                    block.value            = data.rParameter;
                    block.ifBranchType     = data.lParamType;
                    block.variableOperator = ifNode.GetStringFromOpType(data.opParameter);
                }

                project.BlockAdd(block);
            }

            project.lineArray = new LineBlockArray();
            for (int ix = 0; ix < locatedLineList.Count; ++ix)
            {
                int leftBlockID        = locatedLineList[ix].GetLeftExecutePointInfo.blockID;
                int leftExecutePointID = locatedLineList[ix].GetLeftExecutePointInfo.executePointID;
                int rightBlockID       = locatedLineList[ix].GetRightExecutePointInfo.blockID;

                LineBlock line = new LineBlock(leftBlockID, leftExecutePointID, rightBlockID);
                project.LineAdd(line);
            }

            return(project);
        }