// Start is called before the first frame update
    protected virtual void Start()
    {
        clueHud = GameObject.Find("ClueHUD").GetComponent <ClueHUD>();

        functions = new Dictionary <string, System.Delegate>();
        InitSymTable();

        CombineControllerFunctions(ControllerFunctions());

        if (!editorUi)
        {
            Logger.LogWarning($"There is no EditorUI present in {gameObject.name}.{name}");
        }
        else
        {
            program = editorUi.GetComponent <EditorProgram>();
            program.programController = this;
            currentNode = program.programStart;
        }

        // Add OutputRenderer if it doesn't exist yet
        if (!GameObject.Find("OutputRenderer"))
        {
            Instantiate(Resources.Load("Prefabs/ProgramEditor/OutputRenderer")).name = "OutputRenderer";
        }

        if (transform.Find("CurrentLine"))
        {
            transform.Find("CurrentLine").gameObject.SetActive(false);
        }
    }
Exemple #2
0
    // Start is called before the first frame update
    void Start()
    {
        rectTransform = GetComponent <RectTransform>();

        // Find the owner EditorProgram
        Transform ownerTransform = transform.parent;

        while ((owner = ownerTransform.GetComponent <EditorProgram>()) == null)
        {
            ownerTransform = ownerTransform.parent;
        }

        clueHud = GameObject.Find("ClueHUD").GetComponent <ClueHUD>();

        // Find original colour
        Image image = GetComponent <Image>();

        if (image)
        {
            color = new float[4] {
                image.color.r, image.color.g, image.color.b, image.color.a
            };
        }
    }
Exemple #3
0
    void UpdatePrompts(List <GameObject> promptSets)
    {
        EditorProgram currentEditor = null;

        alwaysOnFlowChartPrompt.SetActive(false);
        alwaysOnCodeViewerPrompt.SetActive(false);
        promptBackgroundLeft.SetActive(false);
        promptBackgroundRight.SetActive(false);
        foreach (EditorProgram editor in editors)
        {
            if (editor.EditorActive)
            {
                if (editor.editorMode == EditorProgram.EditorMode.FlowChart)
                {
                    alwaysOnFlowChartPrompt.SetActive(true);
                    promptBackgroundLeft.SetActive(true);
                }
                else
                {
                    alwaysOnCodeViewerPrompt.SetActive(true);
                }

                currentEditor = editor;
                break;
            }
        }

        if (currentEditor && currentEditor.EditorActive && !currentEditor.editingNodeProperty && !currentEditor.linkingNodes)
        {
            if (CopyPasteNodePrompt.activeInHierarchy || CopyNodePrompt.activeInHierarchy || PasteNodePrompt.activeInHierarchy)
            {
                promptBackgroundRight.SetActive(true);
            }
        }
        else
        {
            promptBackgroundRight.SetActive(false);
            CopyPasteNodePrompt.SetActive(false);
            CopyNodePrompt.SetActive(false);
            PasteNodePrompt.SetActive(false);
        }

        if (currentEditor && currentEditor.EditorActive && currentEditor.linkingNodes && hoveredNode)
        {
            if (currentEditor.linkingNodeMode == EditorProgram.LinkingMode.NextNode)
            {
                if (!hoveredNode.GetComponent <ProgramStart>())
                {
                    LinkNodeCaption.text = "Set as next node";
                    LinkNodePrompt.SetActive(true);
                }

                if (hoveredNode == currentEditor.linkingNodesObjects[0])
                {
                    LinkNodeCaption.text = "Remove link";
                    LinkNodePrompt.SetActive(true);
                }
            }
            else
            {
                if (!hoveredNode.GetComponent <ProgramStart>())
                {
                    LinkNodeCaption.text = "Set as first node";
                    LinkNodePrompt.SetActive(true);
                }

                if (hoveredNode == currentEditor.linkingNodesObjects[0])
                {
                    LinkNodeCaption.text = "Remove link";
                    LinkNodePrompt.SetActive(true);
                }
            }
        }
        else if (currentEditor && currentEditor.EditorActive && !currentEditor.linkingNodes && hoveredNode && !currentEditor.editingNodeProperty && !currentEditor.choosingNode && !currentEditor.choosingFunctionCall)
        {
            if (!hoveredNode.GetComponent <ProgramEnd>())
            {
                if (potentialLinkingMode == EditorProgram.LinkingMode.FirstBodyNode && hoveredNode.GetComponent <LogicalBlock>())
                {
                    LinkNodeCaption.text = hoveredNode.GetComponent <WhileLoop>() ? "Start loop" : (hoveredNode.GetComponent <ElseBlock>() ? "Start\nElse Block" : "Start\nIf statement");
                    LinkNodePrompt.SetActive(true);
                }
                else
                {
                    LinkNodeCaption.text = "Connect to\nnext node";
                    LinkNodePrompt.SetActive(true);
                }
            }
        }
        else
        {
            LinkNodePrompt.SetActive(false);
        }

        foreach (GameObject promptSet in promptSets)
        {
            if (currentPromptSet != promptSet)
            {
                promptSet.SetActive(false);
            }
            else
            {
                if (currentEditor == null || (currentEditor != null && (!currentEditor.choosingNode && !currentEditor.choosingFunctionCall)))
                {
                    promptSet.SetActive(true);
                }
            }
        }
    }