Beispiel #1
0
    public override ExperimentState HandleInput(ExperimentController ec)
    {
        if (rum.RosBridge.latestPlanningStatus.Count > 0)
        {
            int status = rum.RosBridge.latestPlanningStatus.Dequeue();
            if (status != RosMessages_old.std_msgs.Int32_old.PLANNED_PICK)
            {
                ms = "wrong state -> exit all";
            }
        }

        if (next)
        {
            if (sc.lastCommand == "Pick")
            {
                nextStateIndex = 0; //planningPick
                next           = false;
            }
            else if (sc.lastCommand == "Execute")
            {
                nextStateIndex = 1; //executePick
                next           = false;
            }

            return(nextStates[nextStateIndex]);
        }

        return(this);
    }
 public override ExperimentState HandleInput(ExperimentController ec)
 {
     if (rum.RosBridge.latestPlanningStatus.Count > 0)
     {
         int status = rum.RosBridge.latestPlanningStatus.Dequeue();
         if (status == RosMessages_old.std_msgs.Int32_old.PLANNING_FAILED)
         {
             fn.ShowMessage("FAIL", new Color(1, 0, 0));
             mos.CurrentSelectedObject.transform.position = setTransform.GetBackToPreviousPlacePos();
             if (ec.PreviousState.GetType() == typeof(PlannedPlace_State))
             {
                 return(nextStates[1]); //PlannedPlace
             }
             return(nextStates[0]);     //Picked
         }
         else if (status == RosMessages_old.std_msgs.Int32_old.SUCCESS)
         {
             fn.ShowMessage("SUCCESS", new Color(0, 1, 0));
             return(nextStates[1]); //PlannedPlace
         }
         else
         {
             ms = "wrong state -> exit all";
         }
     }
     return(this);
 }
    void Start()
    {
        experimentController = GameObject.FindGameObjectWithTag("ExperimentControl").GetComponent <ExperimentController>();

        informationTask          = GameObject.FindGameObjectWithTag("InformationTask");
        informationWrongAnswer   = GameObject.FindGameObjectWithTag("InformationWrongAnswer");
        informationCorrectAnswer = GameObject.FindGameObjectWithTag("InformationCorrectAnswer");



        if (isLocalPlayer)
        {
            increaseSizeButton = GameObject.FindGameObjectWithTag("IncreaseAsteroidSizeButton").GetComponent <Button>();
            increaseSizeButton.onClick.AddListener(() => { IncreaseAsteroidSize(); });
            decreaseSizeButton = GameObject.FindGameObjectWithTag("DecreaseAsteroidSizeButton").GetComponent <Button>();
            decreaseSizeButton.onClick.AddListener(() => { DecreaseAsteroidSize(); });
            increaseSpeedButton = GameObject.FindGameObjectWithTag("IncreaseAsteroidSpeedButton").GetComponent <Button>();
            increaseSpeedButton.onClick.AddListener(() => { IncreaseAsteroidSpeed(); });
            decreaseSpeedButton = GameObject.FindGameObjectWithTag("DecreaseAsteroidSpeedButton").GetComponent <Button>();
            decreaseSpeedButton.onClick.AddListener(() => { DecreaseAsteroidSpeed(); });

            submitAnswerButtonObject = GameObject.FindGameObjectWithTag("SubmitAnswerButton");
            submitAnswerButton       = submitAnswerButtonObject.GetComponent <Button>();
            submitAnswerButton.onClick.AddListener(() => { SubmitAnswer(); });
            tryAgainButtonObject = GameObject.FindGameObjectWithTag("TryAgainButton");
            tryAgainButton       = tryAgainButtonObject.GetComponent <Button>();
            tryAgainButton.onClick.AddListener(() => { ResetExperement(); });
            tryAgainButtonObject.SetActive(false);

            informationTask.SetActive(true);
            informationWrongAnswer.SetActive(false);
            informationCorrectAnswer.SetActive(false);
        }
    }
Beispiel #4
0
 public void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
    // Use this for initialization
    void Start()
    {
        timeLimit = 2;

        controllerScript = GameObject.Find("Main Camera").GetComponent <ExperimentController>();

        mathTextObj = GameObject.Find("MathText");
        mathText    = mathTextObj.GetComponent <Text>();

        submitTextObj = GameObject.Find("SubmissionText");
        submitText    = submitTextObj.GetComponent <Text>();

        answerButton1Obj = GameObject.Find("answerButtonOne");
        answerButton1    = answerButton1Obj.GetComponent <Button>();
        answerButton1.onClick.AddListener(delegate {
            if (!provideAnswer && currentTurn)
            {
                submitText.text = "Answer recorded.";
                //submitText.text= checkAnswer(1).ToString();
                //System.IO.File.AppendAllText("mathbox.txt", checkAnswer(1).ToString() + System.Environment.NewLine);
                controllerScript.recordExp2Answer(checkAnswer(1));
            }
        });

        answerButton2Obj = GameObject.Find("answerButtonTwo");
        answerButton2    = answerButton2Obj.GetComponent <Button>();
        answerButton2.onClick.AddListener(delegate {
            if (!provideAnswer && currentTurn)
            {
                submitText.text = "Answer recorded.";
                //submitText.text= checkAnswer(2).ToString();
                //System.IO.File.AppendAllText("mathbox.txt", checkAnswer(2).ToString() + System.Environment.NewLine);
                controllerScript.recordExp2Answer(checkAnswer(2));
            }
        });

        answerButton3Obj = GameObject.Find("answerButtonThree");
        answerButton3    = answerButton3Obj.GetComponent <Button>();
        answerButton3.onClick.AddListener(delegate {
            if (!provideAnswer && currentTurn)
            {
                submitText.text = "Answer recorded.";
                //submitText.text = checkAnswer(3).ToString();
                //System.IO.File.AppendAllText("mathbox.txt", checkAnswer(3).ToString() + System.Environment.NewLine);
                controllerScript.recordExp2Answer(checkAnswer(3));
            }
        });

        answerButton1TextObj = GameObject.Find("answerButton1Text");
        answerButton1Text    = answerButton1TextObj.GetComponent <Text>();;

        answerButton2TextObj = GameObject.Find("answerButton2Text");
        answerButton2Text    = answerButton2TextObj.GetComponent <Text>();

        answerButton3TextObj = GameObject.Find("answerButton3Text");
        answerButton3Text    = answerButton3TextObj.GetComponent <Text>();


        //mathInputFunctions = (MathInputHelper)textInput.GetComponent(typeof(MathInputHelper));
    }
Beispiel #6
0
    // Update is called once per frame
    void Update()
    {
        Text target = WorldSpace ? WorldSpaceText : CamSpaceText;

        if (AllowManualSet)
        {
            if (ScorePrefix)
            {
                target.text = "Score: " + ManualScoreText;
            }
            else
            {
                target.text = ManualScoreText;
            }
        }
        else
        {
            if (ScorePrefix)
            {
                target.text = "Score: " + ExperimentController.Instance().Score;
            }
            else
            {
                target.text = "" + ExperimentController.Instance().Score;
            }
        }
    }
Beispiel #7
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        ExperimentController expControl = ExperimentController.instance;

        expControl.ShowDistractors();
        expControl.CanRespond(true);
    }
Beispiel #8
0
    public override void Setup()
    {
        ctrler = ExperimentController.Instance();

        //pinballDummy = Instantiate(ctrler.GetPrefab("PinballPrefabDummy"));
        //pinballDummy.transform.SetParent(ctrler.gameObject.transform);
        //pinballDummy.transform.localPosition = new Vector3(0, 0, 0);

        string per_block_ins = ctrler.Session.CurrentTrial.settings.GetString("per_block_instruction");

        ins = ctrler.Session.CurrentTrial.settings.GetString(per_block_ins);

        // Temporarily disable VR Camera
        // TODO: This needs to be changed when we implement instruction task for VR
        //ctrler.CursorController.SetVRCamera(false);

        //Task GameObjects
        instructionPanel = Instantiate(ctrler.GetPrefab("InstructionPanel"), this.transform);

        instruction    = GameObject.Find("Instruction");
        timer          = GameObject.Find("Timer");
        done           = GameObject.Find("Done");
        vrInstructions = GameObject.Find("VRInstructions");
        vrInstructions.transform.localPosition = new Vector3(vrInstructions.transform.localPosition.x, vrInstructionOffset, vrInstructions.transform.localPosition.z);

        instruction.GetComponent <Text>().text        = ins;
        vrInstructions.GetComponent <TextMesh>().text = ins;

        //countdown Timer start
        timer.GetComponent <Text>().text = System.Math.Round(timeRemaining, 0).ToString();

        //add event listener to done button
        done.GetComponent <Button>().onClick.AddListener(() => End());
    }
Beispiel #9
0
 public override ExperimentState HandleInput(ExperimentController ec)
 {
     if (rum.RosBridge.latestPlanningStatus.Count > 0)
     {
         int status = rum.RosBridge.latestPlanningStatus.Dequeue();
         if (status == RosMessages_old.std_msgs.Int32_old.PLANNING_FAILED)
         {
             fn.ShowMessage("FAIL", new Color(1, 0, 0));
             if (ec.PreviousState.GetType() == typeof(PlannedPick_State))
             {
                 return(nextStates[1]); //PlannedPick
             }
             return(nextStates[0]);     //Idle
         }
         else if (status == RosMessages_old.std_msgs.Int32_old.SUCCESS)
         {
             fn.ShowMessage("SUCCESS", new Color(0, 1, 0));
             return(nextStates[1]);
         }
         else
         {
             ms = "wrong state -> exit all";
         }
     }
     return(this);
 }
Beispiel #10
0
 void FixedUpdate()
 {
     if (ExperimentController.Instance().CurrentTask.GetCurrentStep == 1 &&
         GetComponent <Rigidbody>().velocity.sqrMagnitude > 0.0f)
     {
         ExperimentController.Instance().CurrentTask.IncrementStep();
     }
 }
Beispiel #11
0
 private void Update()
 {
     if (ExperimentController.Instance().CursorController.triggerUp)
     {
         //Debug.Log("Trigger Up");
         Grabbed = false;
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        handCursorController = GameObject.FindGameObjectWithTag("Cursor").GetComponent <HandCursorController>();
        experimentController = handCursorController.experimentController;

        // find the tracker object
        cursObjTracker = GameObject.FindGameObjectWithTag("CursObjTracker");
    }
    // This state predetermines all of the trial's task parameters,
    // resets task objects, and prepares the cue.

    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        animator.ResetTrigger("TrialOver");

        ExperimentController expControl = ExperimentController.instance;

        expControl.EndTrial();
    }
Beispiel #14
0
 public override ExperimentState HandleInput(ExperimentController ec)
 {
     if (next)
     {
         next = false;
         return(nextStates[0]); //planningPlace
     }
     return(this);
 }
Beispiel #15
0
 void OnTriggerEnter(Collider col)
 {
     if ((col.gameObject.name == "ToolBox" || col.gameObject.name == "ToolSphere") &&
         ExperimentController.Instance().CurrentTask.GetCurrentStep == 1)
     {
         //ExperimentController.Instance().CurrentTask.IncrementStep();
         Debug.Log(" you hit me");
     }
 }
 void Awake()
 {
     // get the inputs we need for displaying the cursor
     handCursor                = GameObject.FindGameObjectWithTag("Cursor");
     cursObjTracker            = GameObject.FindGameObjectWithTag("CursObjTracker");
     handCursorController      = handCursor.GetComponent <HandCursorController>();
     experimentController      = handCursorController.experimentController;
     targetContainerController = experimentController.targetContainerController;
 }
Beispiel #17
0
    protected int maxSteps;       // Number of steps this task has

    /// <summary>
    /// Increments the current step in this task
    /// </summary>
    public virtual bool IncrementStep()
    {
        currentStep++;

        // Track the time when a step is incremented
        ExperimentController.Instance().StepTimer.Add(Time.time);

        finished = currentStep == maxSteps;
        return(finished);
    }
Beispiel #18
0
    // Update is called once per frame
    void LateUpdate()
    {
        triggerUp = false;

        if (RightHandDevice.TryGetFeatureValue(CommonUsages.triggerButton, out bool val) && val)
        {
            // if start pressing, trigger event
            if (!IsPressed)
            {
                IsPressed = true;
                Debug.Log("Trig down now");
            }
        }
        else if (IsPressed) // check for button release
        {
            IsPressed = false;
            triggerUp = true;
        }
        // Above code should work for OnTriggerUp (this means clean-up is required on current onTriggerUp method)

        if (ExperimentController.Instance().CurrentTask == null)
        {
            return;
        }

        Vector3 realHandPosition = GetHandPosition();

        // Update the position of the cursor depending on which hand is involved
        transform.position = ConvertPosition(realHandPosition);

        if ((previousPosition - realHandPosition).magnitude > 0.001f)
        {
            PauseTime = 0f;
        }
        else
        {
            PauseTime += Time.deltaTime;
        }

        previousPosition = realHandPosition;

        if (ExperimentController.Instance().CurrentTask.Home != null)
        {
            DistanceFromHome =
                (transform.position - ExperimentController.Instance().CurrentTask.Home.transform.position).magnitude;
        }
        else
        {
            DistanceFromHome = -1f;
        }

        prevLeftTrigger  = IsTriggerDown("l");
        prevRightTrigger = IsTriggerDown("r");
    }
Beispiel #19
0
    public override ExperimentState HandleInput(ExperimentController ec)
    {
        if (rum.RosBridge.latestPlanningStatus.Count > 0)
        {
            int status = rum.RosBridge.latestPlanningStatus.Dequeue();
            if (status == RosMessages_old.std_msgs.Int32_old.IDLE)
            {
                return(nextStates[0]); //idle
            }
        }

        return(this);
    }
Beispiel #20
0
    public override bool IncrementStep()
    {
        ExperimentController ctrler = ExperimentController.Instance();

        switch (currentStep)
        {
        case 0:     // Enter dock
            targets[0].SetActive(false);
            Home.SetActive(true);
            break;

        case 1:     // Enter home
            Home.SetActive(false);

            ctrler.StartTimer();

            // Create tracker objects
            ctrler.AddTrackedObject("hand_path",
                                    ctrler.Session.CurrentTrial.settings.GetString("per_block_hand") == "l"
                        ? ctrler.CursorController.LeftHand
                        : ctrler.CursorController.RightHand);

            ctrler.AddTrackedObject("cursor_path", ctrler.CursorController.gameObject);

            Target.SetActive(true);

            ExperimentController.Instance().CursorController.SetCursorVisibility(false);

            break;

        case 2:     // Pause in arc
            localizer.SetActive(true);
            Target.GetComponent <ArcScript>().Expand();

            break;

        case 3:     // Select the spot they think their real hand is
            Target.SetActive(false);

            // We use the target variable to store the cursor position
            Target.transform.position =
                ExperimentController.Instance().CursorController.GetHandPosition();

            break;
        }

        base.IncrementStep();
        return(finished);
    }
Beispiel #21
0
    private void Awake()
    {
        targetDistance = 0.1f;
        oldArc         = arcSpan;
        prevWidth      = width;
        prevSpan       = arcSpan;
        prevThickness  = thickness;
        GenerateArc();

        // get the inputs we need for displaying the cursor
        handCursor                = GameObject.FindGameObjectWithTag("Cursor");
        handCursorController      = handCursor.GetComponent <HandCursorController>();
        experimentController      = handCursorController.experimentController;
        targetContainerController = experimentController.targetContainerController;
    }
    // Start is called before the first frame update
    void Start()
    {
        //initialize variables and data structures
        handCursor           = GameObject.FindGameObjectWithTag("Cursor");
        home                 = GameObject.FindGameObjectWithTag("Home");
        experimentController = GameObject.FindGameObjectWithTag("ExpCont").GetComponent <ExperimentController>();
        handCursorController = handCursor.GetComponent <HandCursorController>();

        prevPosition    = handCursor.transform.localPosition;
        currPosition    = Vector3.zero;
        prevTime        = 0;
        handVelocity    = Vector3.zero;
        velocityHistory = new Stack <Vector3>();

        // find the tracker object
        cursObjTracker = GameObject.FindGameObjectWithTag("CursObjTracker");
    }
    public override ExperimentState HandleInput(ExperimentController ec)
    {
        if (rum.RosBridge.latestPlanningStatus.Count > 0)
        {
            int status = rum.RosBridge.latestPlanningStatus.Dequeue();
            if (status == RosMessages_old.std_msgs.Int32_old.HOLD_OBJECT)
            {
                return(nextStates[0]); //picked
            }
            else if (status == RosMessages_old.std_msgs.Int32_old.ERROR)
            {
                return(nextStates[1]); //error
            }
        }

        return(this);
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        ExperimentController myScript = (ExperimentController)target;

        GUILayout.Space(20);
        if (GUILayout.Button("Run Experiment"))
        {
            myScript.RunExperiment();
        }

        GUILayout.Space(10);
        if (GUILayout.Button("Abort Current & Run Next Configuration"))
        {
            myScript.AbortCurrentConfigurationAndRunNext();
        }

        GUILayout.Space(10);
        if (GUILayout.Button("Pause Experiment"))
        {
            myScript.PauseExperiment();
        }

        if (GUILayout.Button("Stop Experiment"))
        {
            myScript.StopExperiment();
        }

        GUILayout.Space(20);
        if (GUILayout.Button("Start Meta2 Origin Calibration"))
        {
            myScript.StartCalibrationOfExperimentPosition();
        }
        GUILayout.Space(20);
        if (GUILayout.Button("Calibrate VIVE Controller Cursor Offset"))
        {
            myScript.StartCalibrationOfVIVEController();
        }

        if (GUILayout.Button("Calibrate Leap Motion Controller Cursor Offset"))
        {
            myScript.StartCalibrationOfLeapMotionController();
        }
    }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            string experimentName = txtExperimentName.Text.Trim();

            if (experimentName == string.Empty)
            {
                errInfo.Text = "实验名称不能为空。";
                return;
            }
            else if (System.Text.Encoding.Default.GetByteCount(experimentName) > 255)
            {
                errInfo.Text = "实验名称允许最大长度为127个汉字";
                return;
            }

            ExperimentController controller = new ExperimentController();

            if (controller.ExperimentNameExists(experimentName))
            {
                errInfo.Text = "实验名称\"" + txtExperimentName.Text + "\"已存在。";
                return;
            }
            ExperimentsInfo experimentsInfo = new ExperimentsInfo();

            experimentsInfo.ExperimentID       = WanTaiObjectService.NewSequentialGuid();
            experimentsInfo.ExperimentName     = experimentName;
            experimentsInfo.LoginName          = txtOrperatorName.Text;
            experimentsInfo.Remark             = txtRemark.Text;
            experimentsInfo.StartTime          = DateTime.Now;
            experimentsInfo.State              = (short)ExperimentStatus.Create;;
            SessionInfo.CurrentExperimentsInfo = experimentsInfo;
            if (controller.CreateExperiment(experimentsInfo))
            {
                SessionInfo.ExperimentID = experimentsInfo.ExperimentID;
                SessionInfo.RotationFormulaParameters = new Dictionary <Guid, FormulaParameters>();
                SessionInfo.PraperRotation            = null;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "新建实验 成功", SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID);
                this.DialogResult = true;
                this.Close();
            }
            else
            {
                errInfo.Text = "添加实验失败。";
            }
        }
        public ProgramController(ProgramView programView,
                                 DatabaseConnector databaseConnector,
                                 DatabaseController databaseController,
                                 ExperimentController experimentController,
                                 PhaseVisualizationController phaseVisualizationController)
        {
            Claws.NotNull(() => programView);
            Claws.NotNull(() => databaseConnector);
            Claws.NotNull(() => databaseController);
            Claws.NotNull(() => experimentController);
            Claws.NotNull(() => phaseVisualizationController);

            this.programView                  = programView;
            this.databaseConnector            = databaseConnector;
            this.databaseController           = databaseController;
            this.experimentController         = experimentController;
            this.phaseVisualizationController = phaseVisualizationController;
        }
Beispiel #27
0
    //
    public Vector3 GetHandPosition()
    {
        if (UseVR)
        {
            return(CurrentTaskHand == "l"
            ? leftHandCollider.transform.position
            : rightHandCollider.transform.position);
        }

        if (Camera.main == null)
        {
            Debug.LogWarning("make sure your camera is tagged as the Main camera");
        }

        Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        return(new Vector3(mousePos.x, ExperimentController.Instance().transform.position.y, mousePos.z));
    }
Beispiel #28
0
    public override ExperimentState HandleInput(ExperimentController ec)
    {
        if (rum.RosBridge.latestPlanningStatus.Count > 0)
        {
            int status = rum.RosBridge.latestPlanningStatus.Dequeue();
            if (status != RosMessages_old.std_msgs.Int32_old.IDLE)
            {
                ms = "wrong state -> exit all";
            }
        }

        if (next)
        {
            next = false;
            return(nextStates[0]);//planning pick
        }

        return(this);
    }
Beispiel #29
0
    /// <summary>
    /// Converts the user's hand location into the transformed cursor location
    /// </summary>
    /// <returns></returns>
    private Vector3 ConvertPosition(Vector3 position)
    {
        ExperimentController ctrler = ExperimentController.Instance();

        // Get home position. Returns Vector3.zero when task doesn't use a home position
        Vector3 home = ctrler.CurrentTask.Home != null ?
                       ctrler.CurrentTask.Home.transform.position : Vector3.zero;

        switch (MoveType)
        {
        case MovementType.aligned:
            return(position);

        case MovementType.rotated:
            float angle = ctrler.Session.CurrentTrial.settings
                          .GetFloat("per_block_rotation");

            return(Quaternion.Euler(0, -angle, 0) * (position - home) + home);

        case MovementType.clamped:
            // Get vector between home position and target
            Vector3 target = ctrler.CurrentTask.Target.transform.position;
            Vector3 normal = target - home;

            // Rotate vector by 90 degrees to get plane parallel to the vector
            normal = Quaternion.Euler(0f, -90f, 0f) * normal;

            //  o   < target
            //  |
            // -|   < normal
            //  |
            //  x   < dock / center of experiment

            // Project position using this new vector as the plane normal
            return(Vector3.ProjectOnPlane(position - home, normal.normalized) + home);

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
Beispiel #30
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    // This script will handle the timing only and will rely on the experiment controller to handle the
    // Gaze and Player collision data.
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        ExperimentController exp = ExperimentController.instance;

        // Just Started
        if (exp.IsRunning && !wasRunning)
        {
            animator.SetTrigger("Run");
            wasRunning = true;
            return;
        }
        // Just Stopped
        else if (!exp.IsRunning && wasRunning)
        {
            animator.SetTrigger("Stop");
            wasRunning = false;
            return;
        }
        // Check for state completion
        else if (exp.IsRunning && wasRunning)
        {
            if (exp.IsTrialOver())
            {
                animator.SetTrigger("TrialOver");
                return;
            }

            if (exp.IsStateOver())
            {
                animator.SetTrigger("StateOver");
                return;
            }
        }
        else
        {
            //animator.SetBool("IsTrialOver", true);
            return;
        }
    }
    // Use this for initialization
    void Start()
    {
        timeLimit = 2;

        controllerScript = GameObject.Find ("Main Camera").GetComponent <ExperimentController>();

        mathTextObj = GameObject.Find ("MathText");
        mathText = mathTextObj.GetComponent<Text>();

        submitTextObj = GameObject.Find ("SubmissionText");
        submitText = submitTextObj.GetComponent<Text>();

        answerButton1Obj = GameObject.Find ("answerButtonOne");
        answerButton1 = answerButton1Obj.GetComponent<Button>();
        answerButton1.onClick.AddListener(delegate {
            if(!provideAnswer && currentTurn)
            {
                submitText.text = "Answer recorded.";
                //submitText.text= checkAnswer(1).ToString();
                //System.IO.File.AppendAllText("mathbox.txt", checkAnswer(1).ToString() + System.Environment.NewLine);
                controllerScript.recordExp2Answer(checkAnswer (1));
            }
        });

        answerButton2Obj = GameObject.Find ("answerButtonTwo");
        answerButton2 = answerButton2Obj.GetComponent<Button>();
        answerButton2.onClick.AddListener(delegate {
            if(!provideAnswer && currentTurn)
            {
                submitText.text = "Answer recorded.";
                //submitText.text= checkAnswer(2).ToString();
                //System.IO.File.AppendAllText("mathbox.txt", checkAnswer(2).ToString() + System.Environment.NewLine);
                controllerScript.recordExp2Answer(checkAnswer (2));
            }
        });

        answerButton3Obj = GameObject.Find ("answerButtonThree");
        answerButton3 = answerButton3Obj.GetComponent<Button>();
        answerButton3.onClick.AddListener(delegate {
            if(!provideAnswer && currentTurn)
            {
                submitText.text = "Answer recorded.";
                //submitText.text = checkAnswer(3).ToString();
                //System.IO.File.AppendAllText("mathbox.txt", checkAnswer(3).ToString() + System.Environment.NewLine);
                controllerScript.recordExp2Answer(checkAnswer (3));
            }
        });

        answerButton1TextObj = GameObject.Find ("answerButton1Text");
        answerButton1Text = answerButton1TextObj.GetComponent<Text>();;

        answerButton2TextObj = GameObject.Find ("answerButton2Text");
        answerButton2Text = answerButton2TextObj.GetComponent<Text>();

        answerButton3TextObj = GameObject.Find ("answerButton3Text");
        answerButton3Text = answerButton3TextObj.GetComponent<Text>();

        //mathInputFunctions = (MathInputHelper)textInput.GetComponent(typeof(MathInputHelper));
    }
    // Use this for initialization
    void Start()
    {
        timeLimit = 4;

        controllerScript = GameObject.Find ("Main Camera").GetComponent <ExperimentController>();

        tickerTextObj = GameObject.Find ("TickerText");
        tickerText = tickerTextObj.GetComponent<Text>();

        confirmTextObj = GameObject.Find ("ConfirmationText");
        confirmText = confirmTextObj.GetComponent<Text>();

        buyButtonObj = GameObject.Find ("Buy Button");
        buyButton = buyButtonObj.GetComponent<Button>();
        buyButton.onClick.AddListener(delegate {
            if(!provideAnswer && currentTurn)
            {
                if(prevPercentChange > 0 && percentChange > 0)
                {
                    confirmText.text="Bought shares.";
                    //System.IO.File.AppendAllText("stocktickerbox.txt", "true" + System.Environment.NewLine);
                    controllerScript.recordExp2Answer(true);
                }
                else
                {
                    confirmText.text="Bought shares.";
                    //System.IO.File.AppendAllText("stocktickerbox.txt", "false" + System.Environment.NewLine);
                    controllerScript.recordExp2Answer(false);
                }
            }

        });

        sellButtonObj = GameObject.Find ("Sell Button");
        sellButton = sellButtonObj.GetComponent<Button>();
        sellButton.onClick.AddListener(delegate {
            if(!provideAnswer && currentTurn)
            {
                if(prevPercentChange <= 0 && percentChange <=0)
                {
                    confirmText.text="Sold shares.";
                    //System.IO.File.AppendAllText("stocktickerbox.txt", "true" + System.Environment.NewLine);
                    controllerScript.recordExp2Answer(true);
                }
                else
                {
                    confirmText.text="Sold shares.";
                    //System.IO.File.AppendAllText("stocktickerbox.txt", "false" + System.Environment.NewLine);
                    controllerScript.recordExp2Answer(false);
                }
            }
        });

        buyButtonTextObj = GameObject.Find ("BuyButtonText");
        buyButtonText = buyButtonTextObj.GetComponent<Text>();

        sellButtonTextObj = GameObject.Find ("SellButtonText");
        sellButtonText = sellButtonTextObj.GetComponent<Text>();

        tick = Random.Range(9.0F, 18.0F);
    }
    // Use this for initialization
    void Start()
    {
        controllerScript = GameObject.Find ("Main Camera").GetComponent <ExperimentController>();

        titleTextObj = GameObject.Find ("Title Bar Email");
        titleText = titleTextObj.GetComponent<Text>();

        initMessages();
        timeLimit = 3;
        messageGameObjs = new List<GameObject> ();

        displayedMessages = new List<int>();

        flagButtonObj = GameObject.Find ("Flag Button");
        flagButton = flagButtonObj.GetComponent<Button>();

        flagButtonTextObj = GameObject.Find ("FlagText");
        flagButtonText = flagButtonTextObj.GetComponent<Text>();

        flagButton.onClick.AddListener(delegate {
            if(!provideAnswer && currentTurn)
            {
                if(prevAnswer && answer)
                {
                    flagButtonText.text = "*FLAGGED*";
                    //System.IO.File.AppendAllText("emailbox.txt", "true" + System.Environment.NewLine);
                    controllerScript.recordExp2Answer(true);
                }
                else
                {
                    flagButtonText.text = "*FLAGGED*";
                    //System.IO.File.AppendAllText("emailbox.txt", "false" + System.Environment.NewLine);
                    controllerScript.recordExp2Answer(false);
                }
            }
        });
    }