Пример #1
0
        public override string GetString(string tabs)
        {
            string otherTrue  = "";
            string otherFalse = "";
            string condition;

            if (rightConnectors[0].Connected)
            {
                otherTrue = rightConnectors[0].Connected.RootNode.GetString(tabs + "    ");
            }

            if (rightConnectors[1].Connected)
            {
                otherFalse = rightConnectors[1].Connected.RootNode.GetString(tabs + "    ");
            }

            if (inputs[0].Connected)
            {
                OutputPivot connected = (OutputPivot)inputs[0].Connected;
                condition = connected.GetString();
            }
            else
            {
                InputPivot input = inputs[0] as InputPivot;
                condition = input.GetInputValue();
            }

            return($"{tabs}if ({condition})\n{tabs}{{\n{otherTrue}\n{tabs}}}\n{tabs}else\n{tabs}{{\n{otherFalse}\n{tabs}}}");
        }
Пример #2
0
        public override string GetString(string tabs)
        {
            string other = null;

            if (rightConnectors[0].Connected)
            {
                other = rightConnectors[0].Connected.RootNode.GetString(tabs);
            }

            string input = "";

            if (inputs != null)
            {
                List <string> vs = new List <string>();

                foreach (InputPivot inputPivot in inputs)
                {
                    if (inputPivot.Connected)
                    {
                        OutputPivot connected = (OutputPivot)inputPivot.Connected;
                        vs.Add(connected.GetString());
                    }
                    else
                    {
                        vs.Add(inputPivot.GetInputValue());
                    }
                }

                for (int i = 0; i < vs.Count; i++)
                {
                    if (i > 0)
                    {
                        input += $", {vs[i]}";
                    }
                    else
                    {
                        input += $"{vs[i]}";
                    }
                }
            }

            if (output && output.Connected)
            {
                return($"{tabs}{output.Type.ToString().ToLower()} {id} = {nodeName}({input});\n{other}");
            }
            else
            {
                if (other != null)
                {
                    return($"{tabs}{nodeName}({input});\n{other}");
                }
                else
                {
                    return($"{tabs}{nodeName}({input});");
                }
            }
        }
Пример #3
0
        protected void Start()
        {
            leftConnectors  = GetComponentsInChildren <LeftConnector>();
            rightConnectors = GetComponentsInChildren <RightConnector>();

            inputs = GetComponentsInChildren <InputPivot>();
            output = GetComponentInChildren <OutputPivot>();

            nodeName = GetComponentInChildren <Text>().text.TrimEnd();
            id       = ProjectMath.GetNodeId();
        }