public void ToNodes(ICodeNode parentNode)
    {
        RootNode             rootNode    = parentNode.GetRootNode();
        LogicalOperationNode logicOpNode = CreateNode(rootNode);

        parentNode.AddChildNode(logicOpNode);
    }
    public LogicalOperationNode CreateNode(RootNode rootNode)
    {
        HighlightableButton highlightableButton = (GameObjectHelper.HasComponent <HighlightableButton>(this.gameObject)) ? this.GetComponent <HighlightableButton>() : null;
        IntegerNode         field1 = GetField1Node(rootNode);
        IntegerNode         field2 = GetField2Node(rootNode);

        // Converts the Logical operator choosen to the proper enum
        LogicalOperationNode.LogicalOperation operation = GetOperation(GetOperator());
        LogicalOperationNode logicOpNode = new LogicalOperationNode(highlightableButton, field1, field2, operation);

        return(logicOpNode);
    }
Beispiel #3
0
    public void ToNodes(ICodeNode parentNode)
    {
        RootNode            rootNode            = parentNode.GetRootNode();
        HighlightableButton highlightableButton = (GameObjectHelper.HasComponent <HighlightableButton>(this.gameObject)) ? this.GetComponent <HighlightableButton>() : null;

        //Checks if this blox has a param if it has creates an LogicalOperationNode instead of an BOOLeger node
        if (this.BloxParams.Count > 0)
        {
            LogicalOperatorBlox  logicOpBlox = BloxParams[0].GetComponent <LogicalOperatorBlox>();
            LogicalOperationNode logicOpNode = logicOpBlox.CreateNode(rootNode);
            logicOpNode.NodeName = this.GetName();
            parentNode.AddChildNode(logicOpNode);
        }
        else
        {
            BooleanNode boolNode = new BooleanNode(highlightableButton, GetValueAsBoolean());
            boolNode.NodeName = this.GetName();
            parentNode.AddChildNode(boolNode);
        }
    }
Beispiel #4
0
    public void ToNodes(ICodeNode parentNode)
    {
        RootNode            rootNode            = parentNode.GetRootNode();
        IfNode              ifNode              = null;
        HighlightableButton highlightableButton = (GameObjectHelper.HasComponent <HighlightableButton>(this.gameObject)) ? this.GetComponent <HighlightableButton>() : null;

        // IfNode can receive either a bool variable (chosen in dropdown) or a LogicalOperatorBlox as param
        // If it has received a param (LogicalOperatorBlox), creates a LogicalOperationNode
        // and instantiates ifNode with it
        if (BloxParams.Count > 0)
        {
            LogicalOperatorBlox  blox        = BloxParams[0].GetComponent <LogicalOperatorBlox>();
            LogicalOperationNode logicOpNode = blox.CreateNode(rootNode);
            ifNode = new IfNode(highlightableButton, logicOpNode);
        }
        // If a variable was chosen, will search for an existing BooleanNode with that same name
        else
        {
            // Gets the selected boolean variable
            string    selectedBoolVarName = GameObjectHelper.GetDropdownSelectedTextValue(this.booleanVariablesDropdown);
            ICodeNode foundNode           = rootNode.SearchChildByName(selectedBoolVarName);
            if (foundNode != null && GameObjectHelper.CanBeCastedAs <BooleanNode>(foundNode))
            {
                BooleanNode boolNode = (BooleanNode)foundNode;
                ifNode = new IfNode(highlightableButton, boolNode);
            }
            else
            {
                throw new System.Exception("Expected " + selectedBoolVarName + " to be a boolean node");
            }
        }

        parentNode.AddChildNode(ifNode);

        CompileChildrenToNodes(ifNode);
    }