Example #1
0
    void Start()
    {
        Transform parent = transform.parent;

        shapePanelContainer  = parent.GetComponent <ShapePanelContainer>();
        nameText             = nameTextTransform.GetComponent <Text>();
        formulaText          = formulaTextTransform.GetComponent <Text>();
        parameterAInputField = parameterAInputFieldTransform.GetComponent <InputField>();
        parameterBInputField = parameterBInputFieldTransform.GetComponent <InputField>();
        parameterCInputField = parameterCInputFieldTransform.GetComponent <InputField>();

        dialogContainer = GameObject.Find("Dialog Container");

        detailDisplayMode = DetailDisplayMode.StandardForm;

        // TODO: dirty hack but seems necessary for resolution-independent layout
        RectTransform rectTransform = GetComponent <RectTransform>();

        rectTransform.localScale = new Vector2(1f, 1f);

        layoutElement           = GetComponent <LayoutElement>();
        layoutElement.minHeight = contractedHeight;
        expandContainerTransform.gameObject.SetActive(false);
        isExpanded = false;
    }
Example #2
0
    void Start()
    {
        shapePanelContainer = transform.parent.GetComponent <ShapePanelContainer>();

        // TODO: dirty hack but seems necessary for resolution-independent layout
        RectTransform rectTransform = GetComponent <RectTransform>();

        rectTransform.localScale = new Vector2(1f, 1f);
    }
Example #3
0
    void Start()
    {
        GameObject loadExerciseButtonGameObject = GameObject.Find("Load Exercise Button");

        exerciseTitleText = loadExerciseButtonGameObject.GetComponentInChildren <Text>();

        //internetTab = transform.Find("Panel").Find("Internet//Local Tab");
        //internetTab.gameObject.SetActive(true);

        GameObject shapePanelContainerGameObject = GameObject.Find("Shape Panel Container");

        shapePanelContainer = shapePanelContainerGameObject.GetComponent <ShapePanelContainer>();

        GameObject exercisePanelContainerGameObject = GameObject.Find("Exercise Panel Container");

        exercisePanelContainer = exercisePanelContainerGameObject.GetComponent <ExercisePanelContainer>();

        //RefreshList();

        // TODO: dirty hack but seems necessary for resolution-independent layout
        RectTransform rectTransform = GetComponent <RectTransform>();

        rectTransform.localScale = new Vector2(1f, 1f);
    }
Example #4
0
    public static void ParseExercise(string text, Text exerciseTitleText, ExercisePanelContainer exercisePanelContainer, ShapePanelContainer shapePanelContainer)
    {
        shapePanelContainer.ClearAllPanels();
        exercisePanelContainer.ClearPanels(false);

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(text);

        foreach (XmlNode node in doc.DocumentElement.ChildNodes)
        {
            if (node.Name.CompareTo("title") == 0)
            {
                exerciseTitleText.text = node.InnerText;
            }
            else if (node.Name.CompareTo("prompt") == 0)
            {
                ParsePrompt(node, exercisePanelContainer);
            }
            else if (node.Name.CompareTo("line") == 0)
            {
                ParseLine(node, shapePanelContainer);
            }
            else if (node.Name.CompareTo("parabola") == 0)
            {
                ParseParabola(node, shapePanelContainer);
            }
            else if (node.Name.CompareTo("sequence") == 0)
            {
                instance.StartCoroutine("ParseSequence", node);
            }
        }
    }
Example #5
0
    static void ParseParabola(XmlNode node, ShapePanelContainer shapePanelContainer)
    {
        string name = "Unbenannte Parabel";
        float  colorR = 0f, colorG = 0f, colorB = 0f, originHandleX = 0f, originHandleY = 0f, curveHandleX = 1f, curveHandleY = 1f;
        bool   infinite = true;

        foreach (XmlAttribute attribute in node.Attributes)
        {
            if (attribute.Name.CompareTo("name") == 0)
            {
                name = attribute.Value;
            }
        }

        foreach (XmlNode childNode in node.ChildNodes)
        {
            if (childNode.Name.CompareTo("color") == 0)
            {
                foreach (XmlAttribute attribute in childNode.Attributes)
                {
                    if (attribute.Name.CompareTo("r") == 0)
                    {
                        colorR = float.Parse(attribute.Value);
                    }
                    else if (attribute.Name.CompareTo("g") == 0)
                    {
                        colorG = float.Parse(attribute.Value);
                    }
                    else if (attribute.Name.CompareTo("b") == 0)
                    {
                        colorB = float.Parse(attribute.Value);
                    }
                }
            }
            else if (childNode.Name.CompareTo("originhandle") == 0)
            {
                foreach (XmlAttribute attribute in childNode.Attributes)
                {
                    if (attribute.Name.CompareTo("x") == 0)
                    {
                        originHandleX = float.Parse(attribute.Value);
                    }
                    else if (attribute.Name.CompareTo("y") == 0)
                    {
                        originHandleY = float.Parse(attribute.Value);
                    }
                }
            }
            else if (childNode.Name.CompareTo("curvehandle") == 0)
            {
                foreach (XmlAttribute attribute in childNode.Attributes)
                {
                    if (attribute.Name.CompareTo("x") == 0)
                    {
                        curveHandleX = float.Parse(attribute.Value);
                    }
                    else if (attribute.Name.CompareTo("y") == 0)
                    {
                        curveHandleY = float.Parse(attribute.Value);
                    }
                }
            }
            else if (childNode.Name.CompareTo("properties") == 0)
            {
                foreach (XmlAttribute attribute in childNode.Attributes)
                {
                    if (attribute.Name.CompareTo("infinite") == 0)
                    {
                        infinite = bool.Parse(attribute.Value);
                    }
                }
            }
        }

        shapePanelContainer.AddParabolaPanel(true, name, new Color(colorR, colorG, colorB), new Vector2(originHandleX, originHandleY), new Vector2(curveHandleX, curveHandleY), infinite);
    }
Example #6
0
    static void ParseLine(XmlNode node, ShapePanelContainer shapePanelContainer)
    {
        string name = "Unbenannte Gerade";
        float  colorR = 0f, colorG = 0f, colorB = 0f, handle1X = 0f, handle1Y = 0f, handle2X = 1f, handle2Y = 1f;
        bool   infinite = true;

        foreach (XmlAttribute attribute in node.Attributes)
        {
            if (attribute.Name.CompareTo("name") == 0)
            {
                name = attribute.Value;
            }
        }

        foreach (XmlNode childNode in node.ChildNodes)
        {
            if (childNode.Name.CompareTo("color") == 0)
            {
                foreach (XmlAttribute attribute in childNode.Attributes)
                {
                    if (attribute.Name.CompareTo("r") == 0)
                    {
                        colorR = float.Parse(attribute.Value);
                    }
                    else if (attribute.Name.CompareTo("g") == 0)
                    {
                        colorG = float.Parse(attribute.Value);
                    }
                    else if (attribute.Name.CompareTo("b") == 0)
                    {
                        colorB = float.Parse(attribute.Value);
                    }
                }
            }
            else if (childNode.Name.CompareTo("handle1") == 0)
            {
                foreach (XmlAttribute attribute in childNode.Attributes)
                {
                    if (attribute.Name.CompareTo("x") == 0)
                    {
                        handle1X = float.Parse(attribute.Value);
                    }
                    else if (attribute.Name.CompareTo("y") == 0)
                    {
                        handle1Y = float.Parse(attribute.Value);
                    }
                }
            }
            else if (childNode.Name.CompareTo("handle2") == 0)
            {
                foreach (XmlAttribute attribute in childNode.Attributes)
                {
                    if (attribute.Name.CompareTo("x") == 0)
                    {
                        handle2X = float.Parse(attribute.Value);
                    }
                    else if (attribute.Name.CompareTo("y") == 0)
                    {
                        handle2Y = float.Parse(attribute.Value);
                    }
                }
            }
            else if (childNode.Name.CompareTo("properties") == 0)
            {
                foreach (XmlAttribute attribute in childNode.Attributes)
                {
                    if (attribute.Name.CompareTo("infinite") == 0)
                    {
                        infinite = bool.Parse(attribute.Value);
                    }
                }
            }
        }

        shapePanelContainer.AddLinePanel(true, name, new Color(colorR, colorG, colorB), new Vector2(handle1X, handle1Y), new Vector2(handle2X, handle2Y), infinite);
    }