Example #1
0
    // "Next" Command Functionality
    public void NextStep()
    {
        if (curr_instr_num == instruction_number)
        {
            UnityEngine.Debug.Log("curr_instr number: " + curr_instr_num);
            UnityEngine.Debug.Log("inst num: " + instruction_number);
            InstructionAndPicture instructionChosen = new InstructionAndPicture();
            instructionChosen = display.nextInstruction(instruction_number);
            previousInstructions.Add(instructionChosen);
            UnityEngine.Debug.Log("previous_inst: " + previousInstructions.Count);

            //Set Instruction
            GameObject child        = GameObject.Find("Instructions");
            Text       instructions = child.GetComponent <Text>();
            instructions.text = instructionChosen.instruction;

            //Set Picture
            myImageComponent.sprite      = sprite_array[instructionChosen.pic_index];
            myBoxedImageComponent.sprite = boxed_images[instructionChosen.boxpic_index];

            instruction_number = instruction_number + 1;
            curr_instr_num     = curr_instr_num + 1;
            UnityEngine.Debug.Log("instr_num: " + instruction_number);
        }
        else if (curr_instr_num > instruction_number || curr_instr_num < 0)
        {
            UnityEngine.Debug.Log("NextStep Problem");
        }
        else
        { // curr_instr_num < instruction_number
            InstructionAndPicture instructionChosen = new InstructionAndPicture();
            instructionChosen = (InstructionAndPicture)previousInstructions[curr_instr_num - 1];
            UnityEngine.Debug.Log("current_num: " + curr_instr_num);

            //Set Instruction
            GameObject child        = GameObject.Find("Instructions");
            Text       instructions = child.GetComponent <Text>();
            instructions.text = instructionChosen.instruction;

            //Set Picture
            myImageComponent.sprite      = sprite_array[instructionChosen.pic_index];
            myBoxedImageComponent.sprite = boxed_images[instructionChosen.boxpic_index];

            curr_instr_num = curr_instr_num + 1;
        }
    }
Example #2
0
    // "Back" Command Functionality
    public void PreviousStep()
    {
        if (curr_instr_num > 1)
        {
            curr_instr_num--;

            InstructionAndPicture instructionChosen = new InstructionAndPicture();
            instructionChosen = (InstructionAndPicture)previousInstructions[curr_instr_num - 1];

            //Set Instruction
            GameObject child        = GameObject.Find("Instructions");
            Text       instructions = child.GetComponent <Text>();
            instructions.text = instructionChosen.instruction;

            //Set Picture
            myImageComponent.sprite      = sprite_array[instructionChosen.pic_index];
            myBoxedImageComponent.sprite = boxed_images[instructionChosen.boxpic_index];
        }
    }
Example #3
0
    // Choose a random instruction and display it on the screen
    public InstructionAndPicture nextInstruction(int instructionNum)
    {
        /*foreach (var item in turnKnob)
         * {
         *  UnityEngine.Debug.Log("The nodes of MDG are:" + item.instruction);
         * } */
        //UnityEngine.Debug.Log(turnKnob.ToString());
        InstructionAndPicture instructionChosen    = null;
        ArrayList             instructionArrayList = new ArrayList();
        string categoryChosen = null;

        // first instruction: open the box
        if (instructionNum == 1)
        {
            InstructionAndPicture openBox = new InstructionAndPicture
            {
                instruction = "Unscrew fasteners, remove lid from box.",
                pic_index   = 5
            };
            return(openBox);
        }
        else if (instructionNum == 2)
        {
            InstructionAndPicture takeCarabiners = new InstructionAndPicture
            {
                instruction = "Remove carabiners from box. Place them aside.",
                pic_index   = 10
            };
            return(takeCarabiners);
        }
        else if (instructionNum == 49)
        {
            InstructionAndPicture returnCarabiners = new InstructionAndPicture
            {
                instruction = "Unclip and return all carabiners to gray box",
                pic_index   = 10
            };
            return(returnCarabiners);
        } //last instruction: close the box//last instruction: close the box//last instruction: close the box
        else if (instructionNum == 50)
        {
            InstructionAndPicture closeBox = new InstructionAndPicture
            {
                instruction = "Replace lid and screw in fasteners.",
                pic_index   = 5
            };
            return(closeBox);
        }
        else if (instructionNum > 50)
        {
            InstructionAndPicture finalStep = new InstructionAndPicture
            {
                instruction = "EVA Task Completed. Great job!"
            };
            return(finalStep);
        }
        else
        {
            if (categories.Count > 0)
            {
                // Total of 46 instructions to choose from left (2 plug, 5 knob, 4 carabiner, 10 switch, 25 button)
                // Randomly choose from the 6 categories using math.random % categories.size()
                System.Random rnd             = new System.Random();
                int           randomNumber    = rnd.Next(50 - instructionNum - 1); // ex. 3rd instruction 50-3-1=46... finds index under 46; 48... 50-48-1 = 1
                int           categoryDecided = randomCategories[randomNumber];
                categoryChosen = (string)categories[categoryDecided];
                //UnityEngine.Debug.Log(categoryChosen);


                if (categoryChosen != "Plug" && categoryChosen != "Knob" && categoryChosen != "Carabiner")
                {
                    ArrayList value;
                    // Use math.random() % arraylist.size() to pick an instruction
                    if (instruct_dict.TryGetValue(categoryChosen, out value))
                    {
                        instructionArrayList = value;

                        instructionChosen = (InstructionAndPicture)instructionArrayList[rnd.Next(instructionArrayList.Count)];
                    }
                }
                else if (categoryChosen == "Plug")
                {
                    ArrayList value;
                    if (instruct_dict.TryGetValue(categoryChosen, out value))
                    {
                        instructionArrayList = value;
                        instructionChosen    = (InstructionAndPicture)instructionArrayList[0];
                    }
                }
                else if (categoryChosen == "Knob")
                {
                    ArrayList     value;
                    System.Random r = new System.Random();

                    if (instruct_dict.TryGetValue(categoryChosen, out value))
                    {
                        instructionArrayList = value;

                        int temp_num = rnd.Next(instructionArrayList.Count);
                        int len      = instructionArrayList.Count;
                        instructionChosen = (InstructionAndPicture)instructionArrayList[temp_num];
                        //UnityEngine.Debug.Log(instructionChosen.instruction);
                        instructionChosen.instruction += (r.Next(0, 20) * 5) + ".";
                        //UnityEngine.Debug.Log(instructionChosen.instruction);
                    }
                }
                else if (categoryChosen == "Carabiner")
                {
                    UnityEngine.Debug.Log("Carabiner chosen");
                    ArrayList     value;
                    System.Random r = new System.Random();
                    corner_chosen = r.Next(corners.Count);

                    if (instruct_dict.TryGetValue(categoryChosen, out value))
                    {
                        UnityEngine.Debug.Log("In the if statement");
                        instructionArrayList = value;

                        int temp_num = rnd.Next(instructionArrayList.Count);
                        instructionChosen = (InstructionAndPicture)instructionArrayList[temp_num];

                        instructionChosen.instruction += (corners[corner_chosen]);
                        UnityEngine.Debug.Log(instructionChosen.instruction);
                    }

                    corners.RemoveAt(corner_chosen);
                }
            }
        }
        if (instructionNum != 1 && instructionNum != 49 && instructionNum != 2 && instructionNum != 50)
        {
            // Delete from arraylist after use
            instructionArrayList.Remove(instructionChosen);

            // If it’s arraylist is now empty
            ArrayList test;
            if (instruct_dict.TryGetValue(categoryChosen, out test))
            {
                instructionArrayList = test;
                if (test.Count == 0)
                {
                    categories.Remove(categoryChosen);
                    UnityEngine.Debug.Log("Category successfully removed");
                }
            }
        }
        return(instructionChosen);
    }
Example #4
0
    private void createAndAddInstructionAndPictures()
    {
        //hard coded creation of every pair of instructions and picture pairs and addition to their category's arraylist

        // Flip Switch (10 instructions)
        InstructionAndPicture switch1A = new InstructionAndPicture();

        switch1A.instruction  = "Flip switch A1.";
        switch1A.pic_index    = 8;
        switch1A.boxpic_index = 25;
        flipSwitch.Add(switch1A);

        InstructionAndPicture switch1B = new InstructionAndPicture();

        switch1B.instruction  = "Flip switch B1.";
        switch1B.pic_index    = 7;
        switch1B.boxpic_index = 30;
        flipSwitch.Add(switch1B);

        InstructionAndPicture switch2A = new InstructionAndPicture();

        switch2A.instruction  = "Flip switch A2.";
        switch2A.pic_index    = 8;
        switch2A.boxpic_index = 26;
        flipSwitch.Add(switch2A);

        InstructionAndPicture switch2B = new InstructionAndPicture();

        switch2B.instruction  = "Flip switch B2.";
        switch2B.pic_index    = 7;
        switch2B.boxpic_index = 31;
        flipSwitch.Add(switch2B);

        InstructionAndPicture switch3A = new InstructionAndPicture();

        switch3A.instruction  = "Flip switch A3.";
        switch3A.pic_index    = 8;
        switch3A.boxpic_index = 27;
        flipSwitch.Add(switch3A);

        InstructionAndPicture switch3B = new InstructionAndPicture();

        switch3B.instruction  = "Flip switch B3.";
        switch3B.pic_index    = 7;
        switch3B.boxpic_index = 32;
        flipSwitch.Add(switch3B);

        InstructionAndPicture switch4A = new InstructionAndPicture();

        switch4A.instruction  = "Flip switch A4.";
        switch4A.pic_index    = 8;
        switch4A.boxpic_index = 28;
        flipSwitch.Add(switch4A);

        InstructionAndPicture switch4B = new InstructionAndPicture();

        switch4B.instruction  = "Flip switch B4.";
        switch4B.pic_index    = 7;
        switch4B.boxpic_index = 33;
        flipSwitch.Add(switch4B);

        InstructionAndPicture switch5A = new InstructionAndPicture();

        switch5A.instruction  = "Flip switch A5.";
        switch5A.pic_index    = 8;
        switch5A.boxpic_index = 29;
        flipSwitch.Add(switch5A);

        InstructionAndPicture switch5B = new InstructionAndPicture();

        switch5B.instruction  = "Flip switch B5.";
        switch5B.pic_index    = 7;
        switch5B.boxpic_index = 34;
        flipSwitch.Add(switch5B);

        // Push Button (10)
        InstructionAndPicture buttonRed1 = new InstructionAndPicture();

        buttonRed1.instruction  = "Push button Red One.";
        buttonRed1.pic_index    = 0;
        buttonRed1.boxpic_index = 0;
        pushButton.Add(buttonRed1);

        InstructionAndPicture buttonRed2 = new InstructionAndPicture();

        buttonRed2.instruction  = "Push button Red Two.";
        buttonRed2.pic_index    = 0;
        buttonRed2.boxpic_index = 1;
        pushButton.Add(buttonRed2);

        InstructionAndPicture buttonRed3 = new InstructionAndPicture();

        buttonRed3.instruction  = "Push button Red Three.";
        buttonRed3.pic_index    = 0;
        buttonRed3.boxpic_index = 2;
        pushButton.Add(buttonRed3);

        InstructionAndPicture buttonRed4 = new InstructionAndPicture();

        buttonRed4.instruction  = "Push button Red Four.";
        buttonRed4.pic_index    = 0;
        buttonRed4.boxpic_index = 3;
        pushButton.Add(buttonRed4);

        InstructionAndPicture buttonRed5 = new InstructionAndPicture();

        buttonRed5.instruction  = "Push button Red Five.";
        buttonRed5.pic_index    = 0;
        buttonRed5.boxpic_index = 4;
        pushButton.Add(buttonRed5);

        InstructionAndPicture buttonOrange1 = new InstructionAndPicture();

        buttonOrange1.instruction  = "Push button Orange One.";
        buttonOrange1.pic_index    = 3;
        buttonOrange1.boxpic_index = 5;
        pushButton.Add(buttonOrange1);

        InstructionAndPicture buttonO2 = new InstructionAndPicture();

        buttonO2.instruction  = "Push button Orange Two.";
        buttonO2.pic_index    = 3;
        buttonO2.boxpic_index = 6;
        pushButton.Add(buttonO2);

        InstructionAndPicture buttonO3 = new InstructionAndPicture();

        buttonO3.instruction  = "Push button Orange Three.";
        buttonO3.pic_index    = 3;
        buttonO3.boxpic_index = 7;
        pushButton.Add(buttonO3);

        InstructionAndPicture buttonO4 = new InstructionAndPicture();

        buttonO4.instruction  = "Push button Orange Four.";
        buttonO4.pic_index    = 3;
        buttonO4.boxpic_index = 8;
        pushButton.Add(buttonO4);

        InstructionAndPicture buttonO5 = new InstructionAndPicture();

        buttonO5.instruction  = "Push button Orange Five.";
        buttonO5.pic_index    = 3;
        buttonO5.boxpic_index = 9;
        pushButton.Add(buttonO5);

        InstructionAndPicture buttonG1 = new InstructionAndPicture();

        buttonG1.instruction  = "Push button Gray One.";
        buttonG1.pic_index    = 2;
        buttonG1.boxpic_index = 10;
        pushButton.Add(buttonG1);

        InstructionAndPicture buttonG2 = new InstructionAndPicture();

        buttonG2.instruction  = "Push button Gray Two.";
        buttonG2.pic_index    = 2;
        buttonG2.boxpic_index = 11;
        pushButton.Add(buttonG2);

        InstructionAndPicture buttonG3 = new InstructionAndPicture();

        buttonG3.instruction  = "Push button Gray Three.";
        buttonG3.pic_index    = 2;
        buttonG3.boxpic_index = 12;
        pushButton.Add(buttonG3);

        InstructionAndPicture buttonG4 = new InstructionAndPicture();

        buttonG4.instruction  = "Push button Gray Four.";
        buttonG4.pic_index    = 2;
        buttonG4.boxpic_index = 13;
        pushButton.Add(buttonG4);

        InstructionAndPicture buttonG5 = new InstructionAndPicture();

        buttonG5.instruction  = "Push button Gray Five.";
        buttonG5.pic_index    = 2;
        buttonG5.boxpic_index = 14;
        pushButton.Add(buttonG5);

        InstructionAndPicture buttonGr1 = new InstructionAndPicture();

        buttonGr1.instruction  = "Push button Green One.";
        buttonGr1.pic_index    = 4;
        buttonGr1.boxpic_index = 15;
        pushButton.Add(buttonGr1);

        InstructionAndPicture buttonGr2 = new InstructionAndPicture();

        buttonGr2.instruction  = "Push button Green Two.";
        buttonGr2.pic_index    = 4;
        buttonGr2.boxpic_index = 16;
        pushButton.Add(buttonGr2);

        InstructionAndPicture buttonGr3 = new InstructionAndPicture();

        buttonGr3.instruction  = "Push button Green Three.";
        buttonGr3.pic_index    = 4;
        buttonGr3.boxpic_index = 17;
        pushButton.Add(buttonGr3);

        InstructionAndPicture buttonGr4 = new InstructionAndPicture();

        buttonGr4.instruction  = "Push button Green Four.";
        buttonGr4.pic_index    = 4;
        buttonGr4.boxpic_index = 18;
        pushButton.Add(buttonGr4);

        InstructionAndPicture buttonGr5 = new InstructionAndPicture();

        buttonGr5.instruction  = "Push button Green Five.";
        buttonGr5.pic_index    = 4;
        buttonGr5.boxpic_index = 19;
        pushButton.Add(buttonGr5);

        InstructionAndPicture buttonB1 = new InstructionAndPicture();

        buttonB1.instruction  = "Push button Blue One.";
        buttonB1.pic_index    = 1;
        buttonB1.boxpic_index = 20;
        pushButton.Add(buttonB1);

        InstructionAndPicture buttonB2 = new InstructionAndPicture();

        buttonB2.instruction  = "Push button Blue Two.";
        buttonB2.pic_index    = 1;
        buttonB2.boxpic_index = 21;
        pushButton.Add(buttonB2);

        InstructionAndPicture buttonB3 = new InstructionAndPicture();

        buttonB3.instruction  = "Push button Blue Three.";
        buttonB3.pic_index    = 1;
        buttonB3.boxpic_index = 22;
        pushButton.Add(buttonB3);

        InstructionAndPicture buttonB4 = new InstructionAndPicture();

        buttonB4.instruction  = "Push button Blue Four.";
        buttonB4.pic_index    = 1;
        buttonB4.boxpic_index = 23;
        pushButton.Add(buttonB4);

        InstructionAndPicture buttonB5 = new InstructionAndPicture();

        buttonB5.instruction  = "Push button Blue Five.";
        buttonB5.pic_index    = 1;
        buttonB5.boxpic_index = 24;
        pushButton.Add(buttonB5);

        // Tether (8 - in order)

        // Plug (2 - in order)
        InstructionAndPicture plug = new InstructionAndPicture();

        plug.instruction  = "Insert plug into socket";
        plug.pic_index    = 6;
        plug.boxpic_index = 41;
        pluglist.Add(plug);

        InstructionAndPicture unplug = new InstructionAndPicture();

        unplug.instruction  = "Remove plug from socket";
        unplug.pic_index    = 6;
        unplug.boxpic_index = 41;
        pluglist.Add(unplug);

        // Turn Knob (10)
        InstructionAndPicture knob1 = new InstructionAndPicture();

        knob1.instruction  = "Turn dial 1 to ";
        knob1.pic_index    = 9;
        knob1.boxpic_index = 35;
        turnKnob.Add(knob1);

        InstructionAndPicture knob2 = new InstructionAndPicture();

        knob2.instruction  = "Turn dial 2 to ";
        knob2.pic_index    = 9;
        knob2.boxpic_index = 36;
        turnKnob.Add(knob2);

        InstructionAndPicture knob3 = new InstructionAndPicture();

        knob3.instruction  = "Turn dial 3 to ";
        knob3.pic_index    = 9;
        knob3.boxpic_index = 37;
        turnKnob.Add(knob3);

        InstructionAndPicture knob4 = new InstructionAndPicture();

        knob4.instruction  = "Turn dial 4 to ";
        knob4.pic_index    = 9;
        knob4.boxpic_index = 38;
        turnKnob.Add(knob4);

        InstructionAndPicture knob5 = new InstructionAndPicture();

        knob5.instruction  = "Turn dial 5 to ";
        knob5.pic_index    = 9;
        knob5.boxpic_index = 39;
        turnKnob.Add(knob5);

        //Tethers (4)
        InstructionAndPicture carabiner_silver = new InstructionAndPicture();

        carabiner_silver.instruction  = "Clip the silver carabiner to the ";
        carabiner_silver.pic_index    = 11;
        carabiner_silver.boxpic_index = 12;
        carabiner.Add(carabiner_silver);

        InstructionAndPicture carabiner_blue = new InstructionAndPicture();

        carabiner_blue.instruction  = "Clip the blue carabiner to the ";
        carabiner_blue.pic_index    = 10;
        carabiner_blue.boxpic_index = 12;
        carabiner.Add(carabiner_blue);

        InstructionAndPicture carabiner_orange = new InstructionAndPicture();

        carabiner_orange.instruction  = "Clip the orange carabiner to the ";
        carabiner_orange.pic_index    = 12;
        carabiner_orange.boxpic_index = 12;
        carabiner.Add(carabiner_orange);

        InstructionAndPicture carabiner_green = new InstructionAndPicture();

        carabiner_green.instruction  = "Clip the green carabiner to the ";
        carabiner_green.pic_index    = 13;
        carabiner_green.boxpic_index = 12;
        carabiner.Add(carabiner_green);
    }
Example #5
0
    // Choose a random instruction and display it on the screen
    public InstructionAndPicture nextInstruction(int instructionNum)
    {
        /*foreach (var item in turnKnob)
         * {
         *  UnityEngine.Debug.Log("The nodes of MDG are:" + item.instruction);
         * } */
        //UnityEngine.Debug.Log(turnKnob.ToString());
        InstructionAndPicture instructionChosen    = null;
        ArrayList             instructionArrayList = new ArrayList();
        string categoryChosen = null;

        // first instruction: open the box
        if (instructionNum == 1)
        {
            InstructionAndPicture openBox = new InstructionAndPicture
            {
                instruction = "Unscrew fastners and remove lid from the gray box.",
                pic_index   = 5
            };
            instructionChosen = openBox;
        }
        else if (instructionNum == 2)
        {
            InstructionAndPicture takeCarabiners = new InstructionAndPicture
            {
                instruction = "Remove carabiners from box. Place them aside.",
                pic_index   = 10
            };
            instructionChosen = takeCarabiners;
        }
        else if (instructionNum == 49)
        {
            InstructionAndPicture returnCarabiners = new InstructionAndPicture
            {
                instruction = "Return carabiners to gray box",
                pic_index   = 10
            };
            instructionChosen = returnCarabiners;
        } //last instruction: close the box//last instruction: close the box//last instruction: close the box
        else if (instructionNum == 50)
        {
            InstructionAndPicture closeBox = new InstructionAndPicture
            {
                instruction = "Replace lid and screw in fastners.",
                pic_index   = 5
            };
            instructionChosen = closeBox;
        }
        else if (instructionNum > 50)
        {
            InstructionAndPicture finalStep = new InstructionAndPicture
            {
                instruction = "EVA Task Completed. Great job!"
            };
        }
        else
        {
            // Randomly choose from the 6 categories using math.random % categories.size()
            System.Random rnd = new System.Random();
            categoryChosen = (string)categories[rnd.Next(categories.Count)];
            //UnityEngine.Debug.Log(categoryChosen);


            if (categoryChosen != "Plug" && categoryChosen != "Knob")
            {
                ArrayList value;
                // Use math.random() % arraylist.size() to pick an instruction
                if (instruct_dict.TryGetValue(categoryChosen, out value))
                {
                    instructionArrayList = value;

                    instructionChosen = (InstructionAndPicture)instructionArrayList[rnd.Next(instructionArrayList.Count)];
                }
            }
            else if (categoryChosen == "Plug")
            {
                ArrayList value;
                if (instruct_dict.TryGetValue(categoryChosen, out value))
                {
                    instructionArrayList = value;
                    instructionChosen    = (InstructionAndPicture)instructionArrayList[0];
                }
            }
            else if (categoryChosen == "Knob")
            {
                ArrayList     value;
                System.Random r = new System.Random();

                if (instruct_dict.TryGetValue(categoryChosen, out value))
                {
                    instructionArrayList = value;

                    int temp_num = rnd.Next(instructionArrayList.Count);
                    int len      = instructionArrayList.Count;
                    instructionChosen = (InstructionAndPicture)instructionArrayList[temp_num];
                    //UnityEngine.Debug.Log(instructionChosen.instruction);
                    instructionChosen.instruction += r.Next(0, 100) + ".";
                    //UnityEngine.Debug.Log(instructionChosen.instruction);
                }
            }
        }

        if (instructionNum != 1 && instructionNum != 50 && instructionNum != 2 && instructionNum != 49)
        {
            // Delete from arraylist after use
            instructionArrayList.Remove(instructionChosen);

            // If it’s arraylist is now empty
            ArrayList test;
            if (instruct_dict.TryGetValue(categoryChosen, out test))
            {
                instructionArrayList = test;
                if (test.Count == 0)
                {
                    categories.Remove(categoryChosen);
                    UnityEngine.Debug.Log("Category successfully removed");
                }
            }
        }
        return(instructionChosen);
    }