Exemple #1
0
    // Use this for initialization
    void Start()
    {
        question  = transform.FindChild("Question").GetComponent <Text>();
        corInc    = transform.FindChild("CorInc").GetComponent <Text> ();
        sAnswer   = transform.FindChild("Answer Button").GetComponent <Button> ();
        nQuestion = transform.FindChild("Next Button").GetComponent <Button>();
        hint      = transform.FindChild("Hint Button").GetComponent <Button>();

        //Set the size of the canvas
        rt           = GetComponent <RectTransform> ();
        rt.sizeDelta = new Vector2(WIDTH, HEIGHT);

        nQuestion.gameObject.SetActive(false);

        //Find the Level Manager for scorekeeping
        levelManager = FindObjectOfType <LevelManager> ();

        //Find other components of this game object
        qr2       = GetComponent <QuizRandomQ2> ();
        quizPopup = GetComponentInParent <QuizPopup> ();

        //Find the Stat Tracker for stat tracking
        statTracking = FindObjectOfType <StatTracking>();
        rs           = GetComponentInParent <ReportSelf> ();

        //When panel opens, make sure no other panel can open.
        levelManager.noObjections = false;

        //dragAndSnap = GetComponent<DragAndSnap> ();
        setQuestion();
        //Set the feedback as empty.
        corInc.text = "";


        //Gather the set of correct answers as well as their values.
        answerSet = qr2.getAnswer();
        StartCoroutine(setAnswers());
    }
    // Use this for initialization
    void Start()
    {
        //Find needed components in children.
        question  = transform.FindChild("Question").GetComponent <Text>();
        corInc    = transform.FindChild("CorInc").GetComponent <Text> ();
        sAnswer   = transform.FindChild("Answer Button").GetComponent <Button> ();
        nQuestion = transform.FindChild("Next Button").GetComponent <Button>();
        hint      = transform.FindChild("Hint Button").GetComponent <Button>();
        answers1  = GetComponentInChildren <Dropdown> ();

        //Set the size of the canvas
        rt           = GetComponent <RectTransform> ();
        rt.sizeDelta = new Vector2(WIDTH, HEIGHT);


        /*Set the functions of the buttons.  Because Unity has a terrible prefab system.
         * // ***TO BE USED ONLY IF BUTTONS ARE NOT ALREADY ASSIGNED IN INSPECTOR***
         * sAnswer.onClick.RemoveAllListeners ();
         * nQuestion.onClick.RemoveAllListeners ();
         * hint.onClick.RemoveAllListeners ();
         * if (statTracking.levelIdentity == "Q0")
         *      sAnswer.onClick.AddListener (() => submitTestAnswer ());
         * else
         *      sAnswer.onClick.AddListener (() => submitAnswer());
         * nQuestion.onClick.AddListener (() => nextQuestion());
         * hint.onClick.AddListener (() => giveHint()); */

        hint.gameObject.SetActive(false);
        //Make sure only one canvas is enabled
        nQuestion.gameObject.SetActive(false);
        //question2.gameObject.SetActive (false);

        //Find the Level Manager
        levelManager = FindObjectOfType <LevelManager> ();

        //Find the Quiz Popup Script.
        quizPopup = GetComponentInParent <QuizPopup> ();

        //Find the QuizRandomQ1
        qr1 = GetComponent <QuizRandomQ1> ();

        //Set the Correct Answer to this string.
        correctAnswer = qr1.getAnswer();



        //Find the Stat Tracker and ReportSelf scripts.
        statTracking = FindObjectOfType <StatTracking>();
        if (statTracking.identifyLevel() == "Q0" || statTracking.identifyLevel() == "QC")
        {
            rs = transform.GetComponentInChildren <ReportSelf> ();
        }
        else
        {
            rs = GetComponentInParent <ReportSelf> ();
        }

        setQuestion();

        //When panel opens, make sure no other panel can open.
        levelManager.noObjections = false;
        levelManager.canvasOpen   = true;

        //Set the feedback as empty.
        corInc.text = "";
    }
Exemple #3
0
    // Use this for initialization
    void Start()
    {
        //Get the position of the parent.
        //This is the correct position to place the object.
        xParent = transform.root.position.x;
        yParent = transform.root.position.y;

        //Set hint button toggles to inactive.
        hint2Toggle.gameObject.SetActive(false);           //We may need to rework how this feature works.

        //Find the Sprite Renderer for fading/recoloring purposes.
        spriteRenderer = GetComponent <SpriteRenderer> ();

        //Find the box collider so it can be removed when object is placed.
        polyCol = GetComponent <PolygonCollider2D> ();

        //Sets a range of + or - the Offset within the correct position.
        xRangeHigh = xParent + OFFSET;
        xRangeLow  = xParent - OFFSET;
        yRangeHigh = yParent + OFFSET;
        yRangeLow  = yParent - OFFSET;

        //Set range for audio hint system.
        warmRange = 120;
        hotRange  = 15;

        //Make the sprite hint invisible at the start.
        hintBox.enabled = false;
        hintBox.color   = new Color(1f, 1f, 1f, 0f);


        //Find the Level Manager.
        levelManager = FindObjectOfType <LevelManager> ();

        //Find the Stat Tracking and ReportSelf Scripts.
        statTracking = FindObjectOfType <StatTracking>();
        rs           = GetComponentInChildren <ReportSelf> ();



        //Scaling objects to fit inside the box.  This is probably not needed.
        releaseScale = 50f;
        snapScale    = 50f;


        //Following is code for if we decide to have both drag and drop AND quiz questions in one level.
        //levelManager.noObjections = true;
        quizP = GetComponent <QuizPopup> ();



        //Make sure that myAttempt starts at 0
        //guesses = 0; //NOTE: This is handled through ReportSelf now.

        //Count all body parts
        piece = (this.tag == "unPlaced");
        if (piece)
        {
            levelManager.startObjects++;
            levelManager.incObjCount();             //This may no longer be needed.
        }
    }