当前位置: 首页>>代码示例>>C#>>正文


C# Problem.GetQuestion方法代码示例

本文整理汇总了C#中Problem.GetQuestion方法的典型用法代码示例。如果您正苦于以下问题:C# Problem.GetQuestion方法的具体用法?C# Problem.GetQuestion怎么用?C# Problem.GetQuestion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Problem的用法示例。


在下文中一共展示了Problem.GetQuestion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PopulateRichTextAreas

    private void PopulateRichTextAreas(Problem problemToDisplay)
    {
        Question question = problemToDisplay.GetQuestion ();
        int textAreaCount = question.GetQuestionPartCount ();
        float ySpacePerArea = 1f / (float)(textAreaCount - question.GetMultipleChoiceLetterCount());
        float xSpacePerImage = (float)1/Mathf.Clamp((float)question.GetMaximumQuestionPartRepeated(), 1, imagesPerRow);
        float ySpacePerImage = (float)1 / Mathf.Ceil((float)question.GetMaximumQuestionPartRepeated()
                                                     / (float)imagesPerRow);

        int row = 0;
        bool previousAreaWasMultipleChoice = false;

        if (textAreaCount == 0)
        {
            Senseix.Logger.BasicLog("I got a problem with no question atoms.");
            return;//throw new UnityException ("I got a problem with no question atoms.");
        }
        richTextAreas = new GameObject[textAreaCount];

        for (int i = 0; i < textAreaCount; i++)
        {
            GameObject newArea = Instantiate(questionTextPrefab) as GameObject;
            ProblemPart problemPart = problemToDisplay.GetQuestion().GetQuestionPart(i);

            if (newArea.GetComponent<RectTransform>() == null ||
                newArea.GetComponent<Text>() == null )
                throw new UnityException("richTextArea must have a rect transform and Text");

            if (problemPart.HasString())
            {
                newArea.GetComponent<Text>().text += problemPart.GetString();
            }

            float indentedX = 0f;
            if (previousAreaWasMultipleChoice)
                indentedX = indentMultipleChoices;

            newArea.GetComponent<RectTransform>().SetParent(questionParent);
            PositionRectTransform(newArea.GetComponent<RectTransform>(),
                                  indentedX,
                                  1 - (row + 1) * ySpacePerArea,
                                  1,
                                  1 - row * ySpacePerArea);

            if (problemPart.HasSprite())
            {
                //squish this a little bit to provide space between image groups
                newArea.GetComponent<RectTransform>().anchorMin += new Vector2(0f, spaceImageAreas);
                newArea.GetComponent<RectTransform>().anchorMax -= new Vector2(0f, spaceImageAreas);

                for (int j = 0; j < problemPart.TimesRepeated(); j++)
                {
                    GameObject newImage = Instantiate(questionImagePrefab) as GameObject;
                    newImage.GetComponent<RectTransform>().SetParent(newArea.transform);
                    int imageColumn = j % imagesPerRow;
                    int imageRow = Mathf.FloorToInt((float)j / (float)imagesPerRow);
                    PositionRectTransform(newImage.GetComponent<RectTransform>(),
                                          (imageColumn * xSpacePerImage),
                                          1 - (imageRow + 1) * ySpacePerImage,
                                          ((imageColumn + 1) * xSpacePerImage),
                                          1 - imageRow * ySpacePerImage);

                    newImage.GetComponent<Image>().sprite = problemPart.GetSprite();
                }
            }

            richTextAreas[i] = newArea;

            if (!problemPart.IsMultipleChoiceLetter())
            {
                row++;
                previousAreaWasMultipleChoice = false;
            }
            else
            {
                previousAreaWasMultipleChoice = true;
            }
        }
    }
开发者ID:senseix,项目名称:thinksy_unity_plugin,代码行数:79,代码来源:ThinksyQuestionDisplay.cs


注:本文中的Problem.GetQuestion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。