Inheritance: MonoBehaviour
Exemple #1
0
 public Player(int userID, string name, Color color, bool isMouseControlled)
 {
     UserID = userID;
     Name   = name;
     Color  = color;
     Heroes = new mover[1];
 }
Exemple #2
0
 public void Start()
 {
     figter        = GetComponent <Fighter>();
     hp            = GetComponent <health>();
     player        = GameObject.FindWithTag("Player");
     guardPosition = transform.position;
     Movement      = GetComponent <mover>();
 }
Exemple #3
0
 void OnTriggerEnter2D(Collider2D otro)
 {
     if (otro.tag == "Player")
     {
         mover m = otro.GetComponent <mover>();
         m.CanEnter = true;
     }
 }
Exemple #4
0
 void OnTriggerExit2D(Collider2D otro)
 {
     if (otro.tag == "Player")
     {
         mover m = otro.GetComponent <mover>();
         m.CanEnter = false;
         m.SalirEscalera();
     }
 }
Exemple #5
0
    public void CreateHeroes()
    {
        heroObj1 = Instantiate(HeroPrefab1, new Vector3(0, 0, 50), Quaternion.identity);
        heroObj1.GetComponentInChildren <Renderer>().material.color = Players[0].Color;
        hero1           = heroObj1.GetComponent <mover>();
        Players[0].move = hero1;



        heroObj2 = Instantiate(HeroPrefab2, new Vector3(0, 0, -50), new Quaternion(0, -180, 0, 0));
        heroObj2.GetComponentInChildren <Renderer>().material.color = Players[1].Color;
        hero2            = heroObj2.GetComponent <mover2>();
        Players[1].move2 = hero2;
    }
Exemple #6
0
    void OnCollisionEnter2D(Collision2D target)
    {
        mover mover = target.gameObject.GetComponent <mover>();

        if (mover != null)
        {
            mover.TakeDamage(1);
            //Debug.Log("dealing damage");
        }
        //Debug.Log("I hit something"); // for some reason this isn't working so I'll make the bullets not triggers
        //Debug.Log(target.gameObject.name);
        if (target.gameObject.tag == "star")
        {
            //Debug.Log("hit a star!");


            // deal damage to star
        }
    }
Exemple #7
0
    // Update is called once per frame
    void Update()
    {
        trueblock      = Level2.Block - 1;// These are here because the first block of 21 trials are for practice and are not recorded
        trialminusprac = Level2.Trial - 21;
        mover          = GameObject.FindGameObjectWithTag("TAG").GetComponent <mover>();
        Variables      = GameObject.FindGameObjectWithTag("UI").GetComponent <Variables>();
        Order          = GameObject.FindGameObjectWithTag("UI").GetComponent <Order>();


#pragma warning disable CS0618 // Type or member is obsolete
        Trial = Application.loadedLevelName;
#pragma warning restore CS0618 // Type or member is obsolete



        if (TestStart == true)
        {
            if (recording == true)
            {
                if (KeysEnabled == true)
                {
                    if (updateTimer) //Starts the timer when the scene starts.
                    {
                        WaitTimer += Time.deltaTime * 1;
                    }



                    if (WaitTimer > 2.0f)

                    {
                        levelTimer += Time.deltaTime * 1;
                        Canvas.SetActive(!visible);
                        Canvas2.SetActive(!visible);
                        Wait.SetActive(!visible);
                        NextTrial.SetActive(!visible);

                        if (Level2.Block > 1)
                        {
                            posrecording = true;
                            Debug.Log("PositionRecording");
                        }



                        if (OVRInput.GetDown(OVRInput.Button.One))//Button (X) on the touch controller

                        {
                            counter1 = counter1 + 1;
                            TrialNum = TrialNum + 1;
                            Canvas.SetActive(visible);

                            posrecording = false;
                            StreamWriter sw = File.AppendText(Variables.folder + "ParticipantData" + Variables.participant + ".csv");                                                                                                                                       // This is where the data will be written
                            sw.WriteLine(Variables.participant + "," + Trial + "," + trialminusprac + "," + trueblock + "," + Variables.hand + "," + Variables.arm + "," + mover.Stimpos + "," + mover.DistanceZ + "," + Order.Condition + "," + "Y" + "," + (levelTimer)); //writes the current scene, the yes or no response, and the time since the level started to the file in the path above.
                            sw.Close();


                            Debug.Log(Trial);//Confirms current scene
                            Debug.Log("No");
                            WaitTimer        = 00.0f;
                            levelTimer       = 00.0f;
                            updateTimer      = true;
                            KeysEnabled      = false;
                            ParticipantReady = false;
                            if (Level2.Block <= 4)
                            {
                                if (TrialNum == 22)// this should be changed with the max number of trials
                                {
                                    TrialNum  = 1; Debug.Log("t1");
                                    TestStart = false;// sets a break between blocks of trials
                                }
                            }
                        }

                        if (OVRInput.GetDown(OVRInput.Button.Three))//Tells unity which button to listen for. In this case (A)

                        {
                            counter1 = counter1 + 1;
                            TrialNum = TrialNum + 1;
                            Canvas.SetActive(visible);

                            posrecording = false;
                            StreamWriter sw = File.AppendText(Variables.folder + "ParticipantData" + Variables.participant + ".csv");                                                                                                                                       // This is where the data will be written
                            sw.WriteLine(Variables.participant + "," + Trial + "," + trialminusprac + "," + trueblock + "," + Variables.hand + "," + Variables.arm + "," + mover.Stimpos + "," + mover.DistanceZ + "," + Order.Condition + "," + "N" + "," + (levelTimer)); //writes the current scene, the yes or no response, and the time since the level started to the file in the path above.
                            sw.Close();


                            Debug.Log(Trial); //Confirms current scene
                            Debug.Log("Yes"); //Confirms button press in the debug log.
                            WaitTimer        = 00.0f;
                            levelTimer       = 00.0f;
                            updateTimer      = true;//updateTimer = true;//Resets the timer
                            KeysEnabled      = false;
                            ParticipantReady = false;
                            if (Level2.Block <= 4)
                            {
                                if (TrialNum == 22)
                                {
                                    TrialNum  = 1; Debug.Log("t1");
                                    TestStart = false;
                                }
                            }
                        }
                    }
                    if (Level2.Block <= 1)
                    {
                        if (counter1 == 7)
                        {
                            practice = true;
                        }
                        if (counter1 == 14)
                        {
                            practice = true;
                        }
                    }
                }

                if (KeysEnabled == false)
                {
                    if (updateTimer) //Starts the timer when the scene starts.
                    {
                        WaitTimer += Time.deltaTime * 1;
                    }
                }



                if (WaitTimer > 1.0f)

                {
                    Canvas.SetActive(visible);
                    Canvas2.SetActive(visible);
                    NextTrial.SetActive(visible);
                }


                if (WaitTimer > 2.0f)
                {
                    KeysEnabled = true;
                    Canvas.SetActive(!visible);
                    Canvas2.SetActive(!visible);
                    Wait.SetActive(!visible);
                    NextTrial.SetActive(!visible);
                }

                if (Level2.Testend == true)
                {
                    recording = false;
                }
            }

            if (ParticipantReady == false)
            {
                recording = false;
                Canvas.SetActive(visible);
                Break.SetActive(visible);
                if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstick))
                {
                    WaitTimer = 0.0f;

                    Canvas.SetActive(!visible);
                    TrialStart.SetActive(!visible);
                    NextTrial.SetActive(!visible);
                    PracticeBreak.SetActive(!visible);

                    updateTimer      = true;
                    recording        = true;
                    ParticipantReady = true;
                }
            }
            if (practice == true)
            {
                Canvas.SetActive(visible);
                Break.SetActive(!visible);
                PracticeBreak.SetActive(visible);
                if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstick))
                {
                    counter1  = counter1 + 1;
                    WaitTimer = 0.0f;
                    Canvas.SetActive(!visible);
                    TrialStart.SetActive(!visible);
                    NextTrial.SetActive(!visible);
                    PracticeBreak.SetActive(!visible);

                    updateTimer = true;
                    recording   = true;
                    practice    = false;
                }
            }
        }
        if (TestStart == false)
        {
            Debug.Log("false");
            updateTimer = false;
            Canvas.SetActive(visible);


            if ((Level2.Block == 1) || (Level2.Block == 2) || (Level2.Block == 3) || (Level2.Block == 4))
            {
                TrialStart.SetActive(visible);
                if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstick))

                {
                    recording = true;


                    updateTimer = true;
                    WaitTimer   = 0.0f;
                    TrialStart.SetActive(!visible);
                    NextTrial.SetActive(!visible);
                    PracticeBreak.SetActive(!visible);


                    Level2.thumbstick = true;
                    Level2.Block      = Level2.Block + 1;

                    TestStart        = true;
                    ParticipantReady = true;
                }
            }


            if (Level2.Block == 0)

            {
                TrialStart.SetActive(visible);



                if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstick))
                {
                    StreamWriter sw = File.AppendText(Variables.folder + "ParticipantData" + Variables.participant + ".csv");                                                                                                        // This is where the data will be written
                    sw.WriteLine("PARTICIPANT" + "," + "SCENE" + "," + "TRIAL" + "," + "BLOCK" + "," + "HANDDOM" + "," + "ARMLENGTH" + "," + "PI" + "," + "DISTANCE" + "," + "CONDITION" + "," + "RESPONSE" + "," + "RESPONSETIME"); //writes the current scene, the yes or no response, and the time since the level started to the file in the path above.
                    sw.Close();
                    Level2.thumbstick = true;
                    WaitTimer         = 0.0f;

                    ExperimentStart.SetActive(!visible);
                    TrialStart.SetActive(!visible);
                    NextTrial.SetActive(!visible);
                    Level2.Block     = Level2.Block + 1;
                    updateTimer      = true;
                    TestStart        = true;
                    ParticipantReady = true;
                }
            }

            if (Level2.Block == 5)
            {
                Canvas.SetActive(!visible);
            }
        }
    }
Exemple #8
0
    // Update is called once per frame
    void Update()
    {
        trueblock      = Level2.Block - 1;// These are here because the first block of 21 trials are for practice and are not recorded
        trialminusprac = Level2.Trial - 6;


        Variables = GameObject.FindGameObjectWithTag("UI").GetComponent <Variables>();
        Order     = GameObject.FindGameObjectWithTag("UI").GetComponent <Order>();
        if (Variables.Experiment == 3)
        {
            mover = GameObject.FindGameObjectWithTag("TAG").GetComponent <mover>();
        }

#pragma warning disable CS0618 // Type or member is obsolete
        Trial = Application.loadedLevelName;
#pragma warning restore CS0618 // Type or member is obsolete

        if (mover == gameObject.activeInHierarchy)
        {
            stimpos = mover.Stimpos;
        }
        else
        {
            stimpos = 0;
        }
        if (mover == gameObject.activeInHierarchy)
        {
            DistanceZ = mover.DistanceZ;
        }
        else
        {
            DistanceZ = 0;
        }



        if (TestStart == true)
        {
            if (recording == true)
            {
                if (KeysEnabled == true)
                {
                    if (updateTimer) //Starts the timer when the scene starts.
                    {
                        WaitTimer += Time.deltaTime * 1;
                    }



                    if (WaitTimer > 2.0f)

                    {
                        levelTimer += Time.deltaTime * 1;
                        Canvas.SetActive(!visible);
                        Canvas2.SetActive(!visible);
                        Wait.SetActive(!visible);
                        NextTrial.SetActive(!visible);

                        if (Level2.Block > 0)
                        {
                            posrecording = true;
                            Debug.Log("PositionRecording");
                        }
                        if (TrialNum == Level2.MAX)// this should be changed with the max number of trials
                        {
                            if (OVRInput.GetDown(OVRInput.Button.One) || OVRInput.GetDown(OVRInput.Button.Three))
                            {
                                TrialNum  = 0; Debug.Log("t1");
                                TestStart = false;// sets a break between blocks of trials
                            }
                        }


                        if (OVRInput.GetDown(OVRInput.Button.One))//Button (X) on the touch controller

                        {
                            Buttonone();
                        }

                        if (OVRInput.GetDown(OVRInput.Button.Three))//Tells unity which button to listen for. In this case (A)

                        {
                            Buttonthree();
                        }
                    }

                    /* if (Level2.Block <= 1)
                     * {
                     *
                     *   if (counter1 == 7) { practice = true;  }
                     *   if (counter1 == 14) { practice = true; }
                     *
                     * }*/
                }

                if (KeysEnabled == false)
                {
                    if (updateTimer) //Starts the timer when the scene starts.
                    {
                        WaitTimer += Time.deltaTime * 1;
                    }
                }



                if (WaitTimer > 1.0f)

                {
                    Canvas.SetActive(visible);
                    Canvas2.SetActive(visible);
                    NextTrial.SetActive(visible);
                }


                if (WaitTimer > 2.0f)
                {
                    KeysEnabled = true;
                    Canvas.SetActive(!visible);
                    Canvas2.SetActive(!visible);
                    Wait.SetActive(!visible);
                    NextTrial.SetActive(!visible);
                }

                if (Level2.Testend == true)
                {
                    recording = false;
                }
            }

            if (ParticipantReady == false)
            {
                recording = false;
                Canvas.SetActive(visible);
                Break.SetActive(visible);
                if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstick))
                {
                    WaitTimer = 0.0f;

                    // Canvas.SetActive(!visible);
                    TrialStart.SetActive(!visible);
                    NextTrial.SetActive(!visible);
                    PracticeBreak.SetActive(!visible);

                    updateTimer      = true;
                    recording        = true;
                    ParticipantReady = true;
                }
            }

            /*if (practice == true)
             * {
             *
             *  Canvas.SetActive(visible);
             *  Break.SetActive(!visible);
             *  PracticeBreak.SetActive(visible);
             *  if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstick))
             *  {
             *      counter1 = counter1 + 1;
             *      WaitTimer = 0.0f;
             *      Canvas.SetActive(!visible);
             *      TrialStart.SetActive(!visible);
             *      NextTrial.SetActive(!visible);
             *      PracticeBreak.SetActive(!visible);
             *
             *      updateTimer = true;
             *      recording = true;
             *      practice = false;
             *
             *  }
             * }*/
        }
        if (TestStart == false)
        {
            Debug.Log("false");
            updateTimer = false;
            Canvas.SetActive(visible);


            // if ((Level2.Block == 1) || (Level2.Block == 2) || (Level2.Block == 3) || (Level2.Block == 4))
            //{
            //TrialStart.SetActive(visible);
            if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstick))

            {
                recording = true;


                updateTimer = true;
                WaitTimer   = 0.0f;
                //TrialStart.SetActive(!visible);
                NextTrial.SetActive(!visible);
                PracticeBreak.SetActive(!visible);


                Level2.thumbstick = true;
                //Level2.Block = Level2.Block + 1;

                TestStart        = true;
                ParticipantReady = true;
            }
            //}


            if (Level2.Block == 0)

            {
                TrialStart.SetActive(visible);



                if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstick))
                {
                    Debug.Log("writing file header");
                    if (System.IO.File.Exists((Variables.folder + "ParticipantData" + Variables.participant + ".csv")))
                    {
                        //do nothing
                    }
                    else
                    {
                        StreamWriter sw = File.AppendText(Variables.folder + "ParticipantData" + Variables.participant + ".csv");// This is where the data will be written
                        sw.WriteLine("PARTICIPANT" + "," + "SCENE" + "," + "TRIAL" + "," + "BLOCK" + "," + "HANDDOM" + "," + "ARMLENGTH" + "," + "PI" + "," + "DISTANCE" + "," + "CONDITION" + "," + "RESPONSE" + "," + "RESPONSETIME");
                        sw.Close();
                    }
                    Level2.thumbstick = true;
                    WaitTimer         = 0.0f;

                    ExperimentStart.SetActive(false);
                    TrialStart.SetActive(!visible);
                    NextTrial.SetActive(!visible);
                    Level2.Block     = Level2.Block + 1;
                    updateTimer      = true;
                    TestStart        = true;
                    ParticipantReady = true;
                }
            }

            /*if (Level2.Block == 5)
             * {
             *
             *  Canvas.SetActive(!visible);
             *
             * }*/
        }
    }
 // Use this for initialization
 void Start()
 {
     move = GetComponent <mover>();
 }
Exemple #10
0
 public void AddHero(mover hero)
 {
     Heroes[heroCount++] = hero;
     hero.Owner          = this;
 }