SelectNone() публичный Метод

public SelectNone ( ) : void
Результат void
Пример #1
0
    //*******************************************************


    //Includes all the GUI elements
    //*******************************************************
    public void OnGUI()
    {
		if (atWall6 && Input.GetKeyDown("e"))
		{
			GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor = false;
			//If at wall terminal show default cursor instead
		}


		/*
		if (!atWall6)
		{  //If not at wall terminal jack in - "show crosshair"

        } 
		else if (Input.GetKeyDown("e"))
        {
            GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor = false;
            //If at wall terminal show default cursor instead
        }
		*/

        if (guiEnabled)
        {
            GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "Arrays Puzzle");



            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }

            GUI.SetNextControlName("textarea");
            GUI.TextArea(new Rect(Screen.width * 0.2f, Screen.width * 0.04f, Screen.width * 0.75f, Screen.height * 0.75f), code);

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }
            editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
            editor.SelectNone();

            GUI.skin.label.fontSize = 12;


            GUI.Label(new Rect(Screen.width * 0.12f, Screen.height * 0.34f, Screen.width * 0.04f, Screen.height * 0.05f), ("index"));                     //print statement title
            ind = GUI.TextField(new Rect(Screen.width * 0.12f, Screen.height * 0.38f, Screen.width * 0.04f, Screen.height * 0.05f), ind);
            GUI.Label(new Rect(Screen.width * 0.16f, Screen.height * 0.34f, Screen.width * 0.04f, Screen.height * 0.05f), ("value"));                     //print statement title
            val = GUI.TextField(new Rect(Screen.width * 0.16f, Screen.height * 0.38f, Screen.width * 0.04f, Screen.height * 0.05f), val);

            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.38f, Screen.width * 0.1f, Screen.height * 0.05f), "Assign index"))
            {
                GUI.FocusControl("Textarea");
                
                if (!isNumber(ind))
                {
                    errorString = invalid;
                    showError = true;
                }
                else
                {
                    int.TryParse(ind, out index);
					int.TryParse(val, out value);

					if (index > 4 || index < 0)
                    {
                        errorString = outOfRange;
                        showError = true;
                    }
                    else
                    {
                        string s = "steps[" + index + "] = " + value + ";\n\t\t";
						boxes[index] = value;
						editor = goToNextLine(editor, code);
                        code = addToCode(code, editor, s);
                    }
                }

            }


            
            // Button that activates the user's code
            if (GUI.Button(new Rect(Screen.width * 0.6f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Submit"))
            {
                //assign the actual turret index to whatever is in the ind field
				GameObject.Find("Initialization").GetComponent<CubeCreationStage8>().moveBlock1(boxes[0]);
				GameObject.Find("Initialization").GetComponent<CubeCreationStage8>().moveBlock2(boxes[1]);
				GameObject.Find("Initialization").GetComponent<CubeCreationStage8>().moveBlock3(boxes[2]);
				GameObject.Find("Initialization").GetComponent<CubeCreationStage8>().moveBlock4(boxes[3]);
				GameObject.Find("Initialization").GetComponent<CubeCreationStage8>().moveBlock5(boxes[4]);
				
				resume();
            }

            // Button that closes the UI and disregards changes
            if (GUI.Button(new Rect(Screen.width * 0.7f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Cancel"))
            {
                resume();
                code = restoreCode();
                converted = false;
                showError = false;
            }


            // Button that restores the code in the indArea to its original state
            if (GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Reset") || reset)
            {
                code = restoreCode();
                converted = false;
                showError = false;
				int i = 0;
				while(i<5)
				{
					boxes[i]=1;
					i++;
				}
            }



        }

    }
Пример #2
0
		//*******************************************************
		
		
		//Includes all the GUI elements
		//*******************************************************
		public void OnGUI()
		{
			if (atWall9_1 && Input.GetKeyDown("e"))
			{
				//GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor = false;
				//If at wall terminal show default cursor instead
			}
			
			
			if (guiEnabled)
			{
				GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "Arrays Puzzle");
				
				if (showError)
				{
					GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
					if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
					{
						showError = false;
					}
				}
				
				GUI.SetNextControlName("Textarea");
				GUI.TextArea(new Rect(Screen.width * 0.24f, Screen.width * 0.04f, Screen.width * 0.75f, Screen.height * 0.75f), code);
				
				if (showError)
				{
					GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
					if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
					{
						showError = false;
					}
				}
				editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
				editor.SelectNone();
				
				GUI.skin.label.fontSize = 12;

				
				if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.32f, Screen.width * 0.2f, Screen.height * 0.1f), "Instantiate Sheild"))
				{

				if(instantiated)
				{
					showError = true;
					errorString = already;
				}
				else
				{
					GUI.FocusControl("Textarea");
					string s = "Sheild sh = new Sheild();\n\t\t";
					positionG = countLinesBefore(code, editor.pos);
					instantiated = true;
					editor.pos=1;
					editor = goToNextLine(editor, code);
					code = addToCode(code, editor, s);
				}
				}

				if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.44f, Screen.width * 0.2f, Screen.height * 0.1f), "Generate Sheild"))
				{
				if(!instantiated)
				{
						showError = true;
						errorString = invalid;
				}
				else
				{
					GUI.FocusControl("Textarea");
					string s = "generate(sh);\n\t\t";
					editor.pos=1;
					editor = goToNextLine(editor, code);
					code = addToCode(code, editor, s);
					generated = true;
					positionG = countLinesBefore(code, editor.pos);
				}
				}
				
				// Button that activates the user's code
				if (GUI.Button(new Rect(Screen.width * 0.4f, Screen.height * 0.9f, Screen.width * 0.15f, Screen.height * 0.08f), "Submit"))
				{
				if(generated)
				GameObject.Find("Initialization").GetComponent<InitialStage9>().activate(1);
					resume();
				}
				
				// Button that closes the UI and disregards changes
				if (GUI.Button(new Rect(Screen.width * 0.6f, Screen.height * 0.9f, Screen.width * 0.15f, Screen.height * 0.08f), "Cancel"))
				{
					resume();
					code = restoreCode();
					instantiated = false;
					generated = false;
					showError = false;
				}
				
				
				// Button that restores the code in the indArea to its original state
				if (GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.9f, Screen.width * 0.15f, Screen.height * 0.08f), "Reset") || reset)
				{
					code = restoreCode();
					instantiated = false;
					generated = false;
					showError = false;
				}

				
			}
			
		}
Пример #3
0
    //*******************************************************


    //Includes all the GUI elements
    //*******************************************************
    public void OnGUI()
    {
        if (!atWall)
        {  //If not at wall terminal jack in - "show crosshair"
            Vector3 mPos = Input.mousePosition;
            //GUI.DrawTexture (new Rect (mPos.x - 32, Screen.height - mPos.y - 32, 64, 64), cursorImage);
        }
        else if (atWall && Input.GetKeyDown("e"))
        {

            //If at wall terminal show default cursor instead
        }

        if (guiEnabled)
        {
            GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "List of Functions");

            GUI.SetNextControlName("textarea");
            GUI.TextArea(new Rect(Screen.width * 0.2f, Screen.width * 0.04f, Screen.width * 0.75f, Screen.height * 0.75f), code);
            editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
            editor.SelectNone();

            /*	GUI.Label(new Rect(500, 500, 200, 200), string.Format("Selected text: {0}\nPos: {1}\nSelect pos: {2}\nLines Before: {3}\nLines After: {4}",
                                                      editor.SelectedText,
                                                      editor.pos,
                                                      0,
                                                      countLinesBefore(code,editor.pos),
                                                      countLinesAfter(code,editor.pos)));*/

            int temp;

            GUI.Label(new Rect(Screen.width * 0.12f, Screen.height * 0.14f, Screen.width * 0.04f, Screen.height * 0.05f), ("string"));						//print statement title
            text = GUI.TextField(new Rect(Screen.width * 0.12f, Screen.height * 0.18f, Screen.width * 0.04f, Screen.height * 0.05f), text);    			//print statement textfield

            // for loop starting value textfield
            //*******************************************************
            string fs = GUI.TextField(new Rect(Screen.width * 0.12f, Screen.height * 0.28f, Screen.width * 0.04f, Screen.height * 0.05f), forStart.ToString());
            if (int.TryParse(fs, out temp))
            {
                forStart = Mathf.Clamp(temp, 0, 100);
            }
            else if (fs == "")
            {
                forStart = 0;
            }
            //*******************************************************
            GUI.Label(new Rect(Screen.width * 0.12f, Screen.height * 0.24f, Screen.width * 0.04f, Screen.height * 0.05f), ("start"));  	//for loop parameter title

            //for loop ending value textfield
            //*******************************************************
            string ff = GUI.TextField(new Rect(Screen.width * 0.16f, Screen.height * 0.28f, Screen.width * 0.04f, Screen.height * 0.05f), forFinish.ToString());
            if (int.TryParse(ff, out temp))
            {
                forFinish = Mathf.Clamp(temp, 0, 100);
            }
            else if (ff == "")
            {
                forFinish = 0;
            }
            //*******************************************************
            GUI.Label(new Rect(Screen.width * 0.16f, Screen.height * 0.24f, Screen.width * 0.04f, Screen.height * 0.05f), ("finish"));  	//for loop parameter title

            // Button that inserts a print statement
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.18f, Screen.width * 0.1f, Screen.height * 0.05f), "Printout"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                if (text.ToLower() == "hello world")
                {
                    puzzle1Complete = true;
                }

                if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                {
                    int num = getNumOfTabs(code, editor.pos);
                    code = addToCode(code, editor, "System.out.println(\"" + text + "\");\n" + addedTabs(num));
                    output = output.Insert(output.Length, text + "\n");
                }
            }

            // Button that inserts a for loop
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.28f, Screen.width * 0.1f, Screen.height * 0.05f), "For Loop"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                int num = getNumOfTabs(code, editor.pos);
                if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                {
                    code = addToCode(code, editor, "For(int counter=" + fs + ";counter<=" + ff + ";counter++){\n" + addedTabs(num) + "\t\n" + addedTabs(num) + "}\n" + addedTabs(num));
                }
            }

            // Button inserts a while loop
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.38f, Screen.width * 0.1f, Screen.height * 0.05f), "While Loop"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                int num = getNumOfTabs(code, editor.pos);
                if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                    code = addToCode(code, editor, "while(){\n" + addedTabs(num) + "\t\n" + addedTabs(num) + "}\n" + addedTabs(num));
            }


            // Button that activates the user's code
            if (GUI.Button(new Rect(Screen.width * 0.6f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Submit"))
            {
                TextChanger.Update();
                if (puzzle1Complete)
                {
                    code = restoreCode();
                    GameObject.Find("ButtonTrigger").GetComponent<ButtonTrigger>().puzzleComplete = true;
                    audio.PlayOneShot(missionComplete);
                    puzzle1Complete = false;
                }
                resume();
            }

            // Button that closes the UI and disregards changes
            if (GUI.Button(new Rect(Screen.width * 0.7f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Cancel"))
            {
                resume();
            }

            // Button that restores the code in the textArea to its original state
            if (GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Reset"))
            {
                code = restoreCode();
                text = "";
                output = "";
                forStart = 0;
                forFinish = 0;
            }
        }
    }
Пример #4
0
    //*******************************************************


    //Includes all the GUI elements
    //*******************************************************
    public void OnGUI()
    {

        if (!atWall)
        {  //If not at wall terminal jack in - "show crosshair"
            //Vector3 mPos = Input.mousePosition;
            //GUI.DrawTexture (new Rect (mPos.x - 32, Screen.height - mPos.y - 32, 64, 64), cursorImage);
        }
        else if (atWall && Input.GetKeyDown("e"))
        {
           // GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor = false;
            //If at wall terminal show default cursor instead
        }

        if (guiEnabled)
        {
            GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "Indentation");

            GUI.SetNextControlName("textarea");
            GUI.TextArea(new Rect(Screen.width * 0.2f, Screen.width * 0.04f, Screen.width * 0.75f, Screen.height * 0.75f), code);
            editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
            editor.SelectNone();

            /*			GUI.Label(new Rect(500, 500, 200, 200), string.Format("Selected text: {0}\nPos: {1}\nSelect pos: {2}\nLines Before: {3}\nLines After: {4}",
                                                      height1,
                                                      height2,
                                                      height3,
                                                      countLinesBefore(code,editor.pos),
                                                      height4));*/


            // Button that inserts a tab 
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.18f, Screen.width * 0.1f, Screen.height * 0.05f), "Add Tab"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                //if((countLinesBefore(code,editor.pos)>=2)&&(countLinesAfter(code,editor.pos)>=2)&&isBlankLine(code,edi
                code = addToCode(code, editor, "\t");
                if (added)
                {
                    if (countLinesBefore(code, editor.pos) == 0)
                        height1--;
                    else if (countLinesBefore(code, editor.pos) == 1)
                        height2--;
                    else if (countLinesBefore(code, editor.pos) == 2)
                        height3--;
                    else if (countLinesBefore(code, editor.pos) == 3)
                        height4--;
                    else if (countLinesBefore(code, editor.pos) == 4)
                        height5--;
                    else if (countLinesBefore(code, editor.pos) == 5)
                        height6--;
                    else if (countLinesBefore(code, editor.pos) == 6)
                        height7--;
                }
            }

            // Button that inserts a for loop
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.28f, Screen.width * 0.1f, Screen.height * 0.05f), "Erase Tab"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                code = deleteFromCode(code, editor);
                if (deleted)
                {
                    if (countLinesBefore(code, editor.pos) == 0)
                        height1++;
                    else if (countLinesBefore(code, editor.pos) == 1)
                        height2++;
                    else if (countLinesBefore(code, editor.pos) == 2)
                        height3++;
                    else if (countLinesBefore(code, editor.pos) == 3)
                        height4++;
                    else if (countLinesBefore(code, editor.pos) == 4)
                        height5++;
                    else if (countLinesBefore(code, editor.pos) == 5)
                        height6++;
                    else if (countLinesBefore(code, editor.pos) == 6)
                        height7++;
                }
            }


            // Button that activates the user's code
            if (GUI.Button(new Rect(Screen.width * 0.6f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Submit"))
            {
                TextChanger.Update();
                GameObject.Find("Cube1").GetComponent<MoveBlockStage3>().height += height1;
                GameObject.Find("Cube2").GetComponent<MoveBlockStage3>().height += height2;
                GameObject.Find("Cube3").GetComponent<MoveBlockStage3>().height += height3;
                GameObject.Find("Cube4").GetComponent<MoveBlockStage3>().height += height4;
                GameObject.Find("Cube5").GetComponent<MoveBlockStage3>().height += height5;
                GameObject.Find("Cube6").GetComponent<MoveBlockStage3>().height += height6;
                GameObject.Find("Cube7").GetComponent<MoveBlockStage3>().height += height7;

                int cube1 = GameObject.Find("Cube1").GetComponent<MoveBlockStage3>().height;
                int cube2 = GameObject.Find("Cube2").GetComponent<MoveBlockStage3>().height;
                int cube3 = GameObject.Find("Cube3").GetComponent<MoveBlockStage3>().height;
                int cube4 = GameObject.Find("Cube4").GetComponent<MoveBlockStage3>().height;
                int cube5 = GameObject.Find("Cube5").GetComponent<MoveBlockStage3>().height;
                int cube6 = GameObject.Find("Cube6").GetComponent<MoveBlockStage3>().height;
                int cube7 = GameObject.Find("Cube7").GetComponent<MoveBlockStage3>().height;

                if ((cube1 == 0) && (cube2 == -1) && (cube3 == -2) && (cube4 == -3) && (cube5 == -2) && (cube6 == -1) && (cube7 == 0))
                    audio.PlayOneShot(missionComplete);

                height1 = 0;
                height2 = 0;
                height3 = 0;
                height4 = 0;
                height5 = 0;
                height6 = 0;
                height7 = 0;
                resume();
            }

            // Button that closes the UI and disregards changes
            if (GUI.Button(new Rect(Screen.width * 0.7f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Cancel"))
            {
                resume();
            }

            // Button that restores the code in the textArea to its original state
            if (GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Reset"))
            {
                code = restoreCode();
                height1 = 0;
                height2 = 0;
                height3 = 0;
                height4 = 0;
                height5 = 0;
                height6 = 0;
                height7 = 0;

                GameObject.Find("Cube1").GetComponent<MoveBlockStage3>().height = 0;
                GameObject.Find("Cube2").GetComponent<MoveBlockStage3>().height = 0;
                GameObject.Find("Cube3").GetComponent<MoveBlockStage3>().height = 0;
                GameObject.Find("Cube4").GetComponent<MoveBlockStage3>().height = 0;
                GameObject.Find("Cube5").GetComponent<MoveBlockStage3>().height = 0;
                GameObject.Find("Cube6").GetComponent<MoveBlockStage3>().height = 0;
                GameObject.Find("Cube7").GetComponent<MoveBlockStage3>().height = 0;

            }
        }
    }
Пример #5
0
    //*******************************************************


    //Includes all the GUI elements
    //*******************************************************
    public void OnGUI()
    {
        //if(!(Physics.Raycast(outwardRay, out hit,15f))){
        if (!atScanner && !MakeOrder.atOrderWall)
        {  //If not at wall terminal jack in - "show crosshair"

        }
        else if (atScanner && Input.GetKeyDown("e"))
        {
            
            //If at wall terminal show default cursor instead
        }


        if (guiEnabled)
        {
            GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "System Input Puzzle");

            //GUI.Label(new Rect(500, 500, 200, 200), string.Format("Selected text: {0}\n",showError));

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }
            GUI.SetNextControlName("textarea");
            GUI.TextArea(new Rect(Screen.width * 0.2f, Screen.width * 0.04f, Screen.width * 0.75f, Screen.height * 0.75f), code);

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }
            editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
            editor.SelectNone();

            GUI.skin.label.fontSize = 12;

            //variable textfield
            //*******************************************************
            var = GUI.TextField(new Rect(Screen.width * 0.16f, Screen.height * 0.28f, Screen.width * 0.04f, Screen.height * 0.05f), var);

            //*******************************************************
            GUI.Label(new Rect(Screen.width * 0.16f, Screen.height * 0.24f, Screen.width * 0.04f, Screen.height * 0.05f), ("variable"));  	//for loop parameter title

            // Button that inserts a scanner
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.18f, Screen.width * 0.14f, Screen.height * 0.05f), "Create a Scanner"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                {
                    int num = getNumOfTabs(code, editor.pos);
                    code = addToCode(code, editor, "Scanner reader = new Scanner(System.in);\n" + addedTabs(num));
                    scannerCreated = true;
                }
                else
                {
                    errorString = cantType;
                    showError = true;
                }
            }

            // Button that assigns a scanner to a variable
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.28f, Screen.width * 0.14f, Screen.height * 0.05f), "Assign scanner to variable"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                if (scannerCreated)
                {
                    int num = getNumOfTabs(code, editor.pos);
                    if (var == "order")
                    {
                        if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                        {
                            code = addToCode(code, editor, "order = reader.nextLine();");
							scannerAssigned = true;
                        }
                        else
                        {
                            errorString = cantType;
                            showError = true;
                        }
                    }
                    else
                    {
                        errorString = noVariableError;
                        showError = true;
                    }
                }
                else
                {
                    errorString = noScannerError;
                    showError = true;
                }
            }

            // Button that activates the user's code
            if (GUI.Button(new Rect(Screen.width * 0.6f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Submit"))
            {
                if ((scannerCreated) && (scannerAssigned))
                    puzzle2Complete = true;
                resume();
            }

            // Button that closes the UI and disregards changes
            if (GUI.Button(new Rect(Screen.width * 0.7f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Cancel"))
            {
                resume();
            }


            // Button that restores the code in the textArea to its original state
            if (GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Reset"))
            {
                code = restoreCode();
                output = "";
                var = "";
                showError = false;
                scannerCreated = false;
                scannerAssigned = false;
            }

        }

    }
Пример #6
0
    //*******************************************************


    //Includes all the GUI elements
    //*******************************************************
    public void OnGUI()
    {

        if (!atPlayerWall)
        {  //If not at wall terminal jack in - "show crosshair"
            Vector3 mPos = Input.mousePosition;
            //GUI.DrawTexture (new Rect (mPos.x - 32, Screen.height - mPos.y - 32, 64, 64), cursorImage);
        }
        else if (atPlayerWall && Input.GetKeyDown("e"))
        {
            //GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor=false;
            //If at wall terminal show default cursor instead
        }

        if (guiEnabled)
        {
            GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "List of Functions");

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.3f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }
            GUI.SetNextControlName("textarea");
            GUI.TextArea(new Rect(Screen.width * 0.2f, Screen.width * 0.04f, Screen.width * 0.75f, Screen.height * 0.75f), code);

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.3f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }

            editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
            editor.SelectNone();
            editor.MoveLineEnd();

            int temp;




            // Button that inserts the method that shoots a bullet
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.48f, Screen.width * 0.1f, Screen.height * 0.05f), "Cheat now!"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                code = "public class game{\n" +
                        "\tpublic static void main(String[] args){\n" +
                        "\t\tint rolledNumber = (int)(Math.random() * 6 ) + 1;\n" +
                        "\t\tswitch(rolledNumber){\n" +
                        "\t\t\tcase 1:\n" +
                        "\t\t\t\ttopFace = 1;\n" +
                        "\t\t\tcase 2:\n" +
                        "\t\t\t\ttopFace = 2;\n" +
                        "\t\t\tcase 3:\n" +
                        "\t\t\t\ttopFace = 3;\n" +
                        "\t\t\tcase 4:\n" +
                        "\t\t\t\ttopFace = 4;\n" +
                        "\t\t\tcase 5:\n" +
                        "\t\t\t\ttopFace = 5;\n" +
                        "\t\t\tcase 6:\n" +
                        "\t\t\t\ttopFace = 6;\n" +
                        "\t\t}\n" +
                        "\t\ttopFace = 6;\n" +
                        "\t}\n" +
                        "}";
                facesClicked = true;
            }

            // Button that activates the user's code
            if (GUI.Button(new Rect(Screen.width * 0.6f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Submit"))
            {
                TextChanger.Update();
                if (facesClicked)
                {
                    GameObject.Find("Initialization").GetComponent<PoisonTime>().cheating = true;
                    GameObject.Find("d67").GetComponent<DiceRotateLoaded>().loaded = true;

                }
                resume();
            }

            // Button that closes the UI and disregards changes
            if (GUI.Button(new Rect(Screen.width * 0.7f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Cancel"))
            {
                resume();
            }

            // Button that restores the code in the textArea to its original state
            if (GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Reset"))
            {
                code = restoreCode();
                text = "";
                //output="";
                forStart = 0;
                forFinish = 0;
                value = 0;
            }
        }
    }
Пример #7
0
    //*******************************************************


    //Includes all the GUI elements
    //*******************************************************
    public void OnGUI()
    {
        //	if (Input.GetMouseButtonDown (0) && editor.pos != 0) {
        //			position = editor.pos;
        //	}
        //if(!(Physics.Raycast(outwardRay, out hit,15f))){
        if (!atWall6)
        {  //If not at wall terminal jack in - "show crosshair"

        }
        else
            if (Input.GetKeyDown("e"))
            {
                GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor = false;
                //If at wall terminal show default cursor instead
            }


        if (guiEnabled)
        {
            GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "Ints and Doubles Puzzle");


            //GUI.Label(new Rect(500, 500, 200, 200), string.Format("Selected text: {0}\n",showError));

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }

            GUI.SetNextControlName("textarea");
            GUI.TextArea(new Rect(Screen.width * 0.2f, Screen.width * 0.04f, Screen.width * 0.75f, Screen.height * 0.75f), code);

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }
            editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
            editor.SelectNone();

            GUI.skin.label.fontSize = 12;


            //*******************************************************
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.18f, Screen.width * 0.1f, Screen.height * 0.05f), "Change int to double"))
            {
                //		GUI.FocusControl ("textarea");
                //		editor = goToNexpowertyLine(editor,code);				
                //		if ((countLinesBefore (code, editor.pos) >= 2) && (countLinesAfter (code, editor.pos) >= 2) && isBlankLine (code, editor.pos)) {
                //			int num = getNumOfTabs (code, editor.pos);
                code = "public class game{\n" +
                    "\tpublic static void main(String[] args){\n" +
                        "\t\tif(buttonClicked){\n" +
                        "\t\t\tdouble power = " + power + ";\n" +
                        "\t\t\tlaunchBurger(power);\n" +
                        "\t\t}\n" +
                        "\t}\n" +
                        "}";
                converted = true;
                showError = false;


            }



            GUI.Label(new Rect(Screen.width * 0.12f, Screen.height * 0.34f, Screen.width * 0.04f, Screen.height * 0.05f), ("value"));						//print statement title
            text = GUI.TextField(new Rect(Screen.width * 0.12f, Screen.height * 0.38f, Screen.width * 0.04f, Screen.height * 0.05f), text);

            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.38f, Screen.width * 0.1f, Screen.height * 0.05f), "Assign power"))
            {
                GUI.FocusControl("textarea");
                editor = goToNexpowertyLine(editor, code);
                if (!isNumber(text))
                {
                    errorString = invalid;
                    showError = true;
                }
                else
                {
                    float.TryParse(text, out power);

                    if (text.Contains(".") && !converted)
                    {
                        errorString = badInput;
                        showError = true;
                    }
                    else if (converted)
                    {
                        code = "public class game{\n" +
                            "\tpublic static void main(String[] args){\n" +
                                "\t\tif(buttonClicked){\n" +
                                "\t\t\tdouble power = " + power + ";\n" +
                                "\t\t\tlaunchBurger(power);\n" +
                                "\t\t}\n" +
                                "\t}\n" +
                                "}";
                    }
                    else
                    {
                        code = "public class game{\n" +
                            "\tpublic static void main(String[] args){\n" +
                                "\t\tif(buttonClicked){\n" +
                                "\t\t\tint power = " + power + ";\n" +
                                "\t\t\tlaunchBurger(power);\n" +
                                "\t\t}\n" +
                                "\t}\n" +
                                "}";
                    }
                }

            }


            // Button that activates the user's code
            if (GUI.Button(new Rect(Screen.width * 0.6f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Submit"))
            {
                //assign the actual turret power to whatever is in the text field
                GameObject.Find("turret").GetComponentInChildren<TurretShoot>().bulletImpulse = power * 25;

                resume();
            }

            // Button that closes the UI and disregards changes
            if (GUI.Button(new Rect(Screen.width * 0.7f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Cancel"))
            {
                resume();
                code = restoreCode();
                converted = false;
                showError = false;
            }


            // Button that restores the code in the textArea to its original state
            if (GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Reset") || reset)
            {
                code = restoreCode();
                converted = false;
                showError = false;
                GameObject.Find("turret").GetComponentInChildren<TurretShoot>().bulletImpulse = 50;
                power = 2;


            }

        }

    }
Пример #8
0
    //*******************************************************


    //Includes all the GUI elements
    //*******************************************************
    public void OnGUI()
    {
        int temp;
        //	if (Input.GetMouseButtonDown (0) && editor.pos != 0) {
        //			position = editor.pos;
        //	}
        //if(!(Physics.Raycast(outwardRay, out hit,15f))){
        if (!atWall6)
        {  //If not at wall terminal jack in - "show crosshair"

        }
        else
            if (Input.GetKeyDown("e"))
            {
               // GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor = false;
                //If at wall terminal show default cursor instead
            }


        if (guiEnabled)
        {
            GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "Selection Statement Puzzle");


            //GUI.Label(new Rect(500, 500, 200, 200), string.Format("Selected text: {0}\n",showError));

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }

            GUI.SetNextControlName("textarea");
            GUI.TextArea(new Rect(Screen.width * 0.2f, Screen.width * 0.04f, Screen.width * 0.75f, Screen.height * 0.75f), code);

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }
            editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
            editor.SelectNone();

            GUI.skin.label.fontSize = 12;


            //*******************************************************
            // Button that erases unwanted code
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.18f, Screen.width * 0.1f, Screen.height * 0.05f), "Remove code"))
            {
                //		GUI.FocusControl ("textarea");
                //		editor = goToNextEmptyLine(editor,code);				
                //		if ((countLinesBefore (code, editor.pos) >= 2) && (countLinesAfter (code, editor.pos) >= 2) && isBlankLine (code, editor.pos)) {
                //			int num = getNumOfTabs (code, editor.pos);
                code = "public class game{\n" +
                    "\tpublic static void main(String[] args){\n" +
                        "\t\tif(turretTriggered){\n" +
                        "\t\t\t\n" +
                        "\t\t}\n" +
                        "\t}\n" +
                        "}";
                codereset = true;
                shootAdded = false;
                showError = false;
                ifAdded = false;
                codereset = false;
                turnAdded = false;

                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().turret_case = 0;
                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().forStart = 0;
                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().forFinish = 0;
                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().numIsConstant = false;
            }
            //			else 
            //			{
            //				errorString = cantType;
            //			showError = true;
            //		}
            //	}

            // for loop starting value textfield
            //*******************************************************
            string fs = GUI.TextField(new Rect(Screen.width * 0.12f, Screen.height * 0.28f, Screen.width * 0.04f, Screen.height * 0.05f), forStart.ToString());
            if (int.TryParse(fs, out temp))
            {
                forStart = Mathf.Clamp(temp, 0, 50);
            }
            else if
            (fs == "")
            {
                forStart = 0;
            }
            //*******************************************************
            GUI.Label(new Rect(Screen.width * 0.12f, Screen.height * 0.24f, Screen.width * 0.04f, Screen.height * 0.05f), ("start"));  	//for loop parameter title

            //for loop ending value textfield
            //*******************************************************
            string ff = GUI.TextField(new Rect(Screen.width * 0.16f, Screen.height * 0.28f, Screen.width * 0.04f, Screen.height * 0.05f), forFinish.ToString());
            if (int.TryParse(ff, out temp))
            {
                forFinish = Mathf.Clamp(temp, 0, 100);
            }
            else if (ff == "")
            {
                forFinish = 0;
            }
            //*******************************************************
            GUI.Label(new Rect(Screen.width * 0.16f, Screen.height * 0.24f, Screen.width * 0.04f, Screen.height * 0.05f), ("finish"));  	//for loop parameter title

            // Button that inserts a for loop
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.28f, Screen.width * 0.1f, Screen.height * 0.05f), "For Loop"))
            {
                if (!ifAdded)
                {
                    GUI.FocusControl("textarea");
                    editor = goToNextEmptyLine(editor, code);
                    int num = getNumOfTabs(code, editor.pos);
                    if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                    {
                        if (ff.CompareTo(fs) >= 0)
                        {
                            code = addToCode(code, editor, "For(int i=" + fs + ";i<=" + ff + ";i++){\n" + addedTabs(num) + "\t\n" + addedTabs(num) + "}");
                        }
                        else
                        {
                            code = addToCode(code, editor, "For(int i=" + fs + ";i>=" + ff + ";i--){\n" + addedTabs(num) + "\t\n" + addedTabs(num) + "}");
                        }
                        ifAdded = true;
                    }
                }
                else
                {
                    errorString = oneForLoop;
                    showError = true;
                }
            }

            GUI.Label(new Rect(Screen.width * 0.12f, Screen.height * 0.34f, Screen.width * 0.04f, Screen.height * 0.05f), ("value"));						//print statement title
            text = GUI.TextField(new Rect(Screen.width * 0.12f, Screen.height * 0.38f, Screen.width * 0.04f, Screen.height * 0.05f), text);

            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.38f, Screen.width * 0.1f, Screen.height * 0.05f), "Shoot"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                if (ifAdded)
                {
                    if (!shootAdded)
                    {
                        int.TryParse(text, out temp);
                        if ((!text.Equals("")) && (text.Equals("i") || ((temp >= 0) && (temp < 51))))
                        {
                            int num = getNumOfTabs(code, editor.pos);

                            if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                            {
                                code = addToCode(code, editor, "shoot(" + text + ");\n" + addedTabs(num));
                                shootAdded = true;
                            }
                            else
                            {
                                errorString = cantType;
                                showError = true;
                            }
                        }
                        else
                        {
                            errorString = badInput;
                            showError = true;
                        }
                    }
                    else
                    {
                        errorString = oneShoot;
                        showError = true;
                    }
                }
                else
                {
                    errorString = oneForLoop;
                    showError = true;
                }
            }

            // Button that opens level door
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.48f, Screen.width * 0.1f, Screen.height * 0.05f), "Turn Turret"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                if (ifAdded)
                {
                    int num = getNumOfTabs(code, editor.pos);

                    if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                    {
                        code = addToCode(code, editor, "turnTurret();");
                        turnAdded = true;
                    }
                    else
                    {
                        errorString = cantType;
                        showError = true;
                    }
                }
                else
                {
                    errorString = oneForLoop;
                    showError = true;
                }
            }
          
            // Button that activates the user's code
            if (GUI.Button(new Rect(Screen.width * 0.6f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Submit"))
            {
                if (ifAdded)
                {
                    doForLoop(forStart, forFinish, text);
                }
                resume();
            }

            // Button that closes the UI and disregards changes
            if (GUI.Button(new Rect(Screen.width * 0.7f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Cancel"))
            {
                resume();
                code = restoreCode();
                shootAdded = false;
                showError = false;
                ifAdded = false;
                codereset = false;
                turnAdded = false;
                //doorOpen = false;
                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().turret_case = 1;
                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().forStart = 0;
                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().forFinish = 0;
                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().numIsConstant = true;
                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().numOfBullets = 1;
            }


            // Button that restores the code in the textArea to its original state
            if (GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Reset") || reset)
            {
                code = restoreCode();
                shootAdded = false;
                showError = false;
                ifAdded = false;
                codereset = false;
                turnAdded = false;

                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().turret_case = 1;
                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().forStart = 0;
                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().forFinish = 0;
                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().numIsConstant = true;
                GameObject.Find("PlayButton").GetComponentInChildren<ButtonTriggerStage6>().numOfBullets = 1;

                reset = false;
            }

        }

    }
Пример #9
0
		//*******************************************************
		
		
		//Includes all the GUI elements
		//*******************************************************
		public void OnGUI()
		{
			if (atWall9_3 && Input.GetKeyDown("e"))
			{
				//GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor = false;
				//If at wall terminal show default cursor instead
			}
			
			
			if (guiEnabled)
			{
				GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "Sheild Object");
				
				if (showError)
				{
					GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
					if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
					{
						showError = false;
					}
				}
				
				GUI.SetNextControlName("textarea");
				GUI.TextArea(new Rect(Screen.width * 0.24f, Screen.width * 0.04f, Screen.width * 0.75f, Screen.height * 0.75f), code);
				
				if (showError)
				{
					GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
					if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
					{
						showError = false;
					}
				}
				editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
				editor.SelectNone();
				
				GUI.skin.label.fontSize = 12;

				
				if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.38f, Screen.width * 0.2f, Screen.height * 0.1f), "Add setColor() method"))
				{
					GUI.FocusControl("Textarea");
					
					string s = "public void setColor(Color newColor){ \n\t\t"+
									"color = newColor;\n\t"+
								"}\n\t";
					editor.pos = 274;
					code = addToCode(code, editor, s);

				}
				
				
				
				// Button that activates the user's code
				if (GUI.Button(new Rect(Screen.width * 0.4f, Screen.height * 0.9f, Screen.width * 0.15f, Screen.height * 0.08f), "Submit"))
				{
					setAdded = true;
					resume();
				}
				
				// Button that closes the UI and disregards changes
				if (GUI.Button(new Rect(Screen.width * 0.6f, Screen.height * 0.9f, Screen.width * 0.15f, Screen.height * 0.08f), "Cancel"))
				{
					resume();
					code = restoreCode();
					instantiated = false;
					generated = false;
					showError = false;
				}
				
				
				// Button that restores the code in the indArea to its original state
				if (GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.9f, Screen.width * 0.15f, Screen.height * 0.08f), "Reset") || reset)
				{
					code = restoreCode();
					instantiated = false;
					generated = false;
					showError = false;
				}
				
			}
			
		}
Пример #10
0
 private static bool PerformOperation(TextEditor te, UIUnityEvents.TextEditOp operation)
 {
     switch (operation)
     {
         case UIUnityEvents.TextEditOp.MoveLeft:
         {
             te.MoveLeft();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveRight:
         {
             te.MoveRight();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveUp:
         {
             te.MoveUp();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveDown:
         {
             te.MoveDown();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveLineStart:
         {
             te.MoveLineStart();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveLineEnd:
         {
             te.MoveLineEnd();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveTextStart:
         {
             te.MoveTextStart();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveTextEnd:
         {
             te.MoveTextEnd();
             break;
         }
         case UIUnityEvents.TextEditOp.MovePageUp:
         case UIUnityEvents.TextEditOp.MovePageDown:
         case UIUnityEvents.TextEditOp.SelectPageUp:
         case UIUnityEvents.TextEditOp.SelectPageDown:
         {
             Debug.Log(string.Concat("Unimplemented: ", operation));
             break;
         }
         case UIUnityEvents.TextEditOp.MoveGraphicalLineStart:
         {
             te.MoveGraphicalLineStart();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveGraphicalLineEnd:
         {
             te.MoveGraphicalLineEnd();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveWordLeft:
         {
             te.MoveWordLeft();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveWordRight:
         {
             te.MoveWordRight();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveParagraphForward:
         {
             te.MoveParagraphForward();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveParagraphBackward:
         {
             te.MoveParagraphBackward();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveToStartOfNextWord:
         {
             te.MoveToStartOfNextWord();
             break;
         }
         case UIUnityEvents.TextEditOp.MoveToEndOfPreviousWord:
         {
             te.MoveToEndOfPreviousWord();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectLeft:
         {
             te.SelectLeft();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectRight:
         {
             te.SelectRight();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectUp:
         {
             te.SelectUp();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectDown:
         {
             te.SelectDown();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectTextStart:
         {
             te.SelectTextStart();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectTextEnd:
         {
             te.SelectTextEnd();
             break;
         }
         case UIUnityEvents.TextEditOp.ExpandSelectGraphicalLineStart:
         {
             te.ExpandSelectGraphicalLineStart();
             break;
         }
         case UIUnityEvents.TextEditOp.ExpandSelectGraphicalLineEnd:
         {
             te.ExpandSelectGraphicalLineEnd();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectGraphicalLineStart:
         {
             te.SelectGraphicalLineStart();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectGraphicalLineEnd:
         {
             te.SelectGraphicalLineEnd();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectWordLeft:
         {
             te.SelectWordLeft();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectWordRight:
         {
             te.SelectWordRight();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectToEndOfPreviousWord:
         {
             te.SelectToEndOfPreviousWord();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectToStartOfNextWord:
         {
             te.SelectToStartOfNextWord();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectParagraphBackward:
         {
             te.SelectParagraphBackward();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectParagraphForward:
         {
             te.SelectParagraphForward();
             break;
         }
         case UIUnityEvents.TextEditOp.Delete:
         {
             return te.Delete();
         }
         case UIUnityEvents.TextEditOp.Backspace:
         {
             return te.Backspace();
         }
         case UIUnityEvents.TextEditOp.DeleteWordBack:
         {
             return te.DeleteWordBack();
         }
         case UIUnityEvents.TextEditOp.DeleteWordForward:
         {
             return te.DeleteWordForward();
         }
         case UIUnityEvents.TextEditOp.Cut:
         {
             return te.Cut();
         }
         case UIUnityEvents.TextEditOp.Copy:
         {
             te.Copy();
             break;
         }
         case UIUnityEvents.TextEditOp.Paste:
         {
             return te.Paste();
         }
         case UIUnityEvents.TextEditOp.SelectAll:
         {
             te.SelectAll();
             break;
         }
         case UIUnityEvents.TextEditOp.SelectNone:
         {
             te.SelectNone();
             break;
         }
         default:
         {
             goto case UIUnityEvents.TextEditOp.SelectPageDown;
         }
     }
     return false;
 }
Пример #11
0
    //*******************************************************


    //Includes all the GUI elements
    //*******************************************************
    public void OnGUI()
    {
        //	if (Input.GetMouseButtonDown (0) && editor.pos != 0) {
        //			position = editor.pos;
        //	}
        //if(!(Physics.Raycast(outwardRay, out hit,15f))){
        if (!atWall5)
        {  //If not at wall terminal jack in - "show crosshair"

        }
        else if (atWall5 && Input.GetKeyDown("e"))
        {
           // GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor = false;
            //If at wall terminal show default cursor instead
        }


        if (guiEnabled)
        {
            GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "Selection Statement Puzzle");


            //GUI.Label(new Rect(500, 500, 200, 200), string.Format("Selected text: {0}\n",showError));

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }

            GUI.SetNextControlName("textarea");
            GUI.TextArea(new Rect(Screen.width * 0.2f, Screen.width * 0.04f, Screen.width * 0.75f, Screen.height * 0.75f), code);

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.2f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }
            editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
            editor.SelectNone();

            GUI.skin.label.fontSize = 12;


            //*******************************************************
            // Button that inserts an if statement
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.18f, Screen.width * 0.14f, Screen.height * 0.05f), "Insert if statement"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                {
                    int num = getNumOfTabs(code, editor.pos);
                    code = addToCode(code, editor, "If(ballMoving){\n" + addedTabs(num) + "\t\n" + addedTabs(num) + "}\n" + addedTabs(num) + "else{\n" + addedTabs(num) + "\t\n" + addedTabs(num) + "}");
                    ifAdded = true;
                }
                else
                {
                    errorString = oneIf;
                    showError = true;
                }
            }

            // Button that adds a function that closes the gate
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.28f, Screen.width * 0.14f, Screen.height * 0.05f), "Close gate"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                if (ifAdded)
                {
                    int num = getNumOfTabs(code, editor.pos);

                    if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                    {
                        code = addToCode(code, editor, "closeGate();");
                        if (countLinesBefore(code, editor.pos) == 10)
                        {
                            elseVar = "gateLowered";
                        }
                        else
                        {
                            ifVar = "gateLowered";
                        }
                    }
                    else
                    {
                        errorString = cantType;
                        showError = true;
                    }
                }
                else
                {
                    errorString = noIfStatement;
                    showError = true;
                }
            }

            // Button that adds a function that closes the gate
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.38f, Screen.width * 0.14f, Screen.height * 0.05f), "Open hole"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                if (ifAdded)
                {
                    int num = getNumOfTabs(code, editor.pos);

                    if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                    {
                        code = addToCode(code, editor, "openHole();");
                        if (countLinesBefore(code, editor.pos) == 10)
                        {
                            elseVar = "holeOpened";
                        }
                        else
                        {
                            ifVar = "holeOpened";
                        }
                    }
                    else
                    {
                        errorString = cantType;
                        showError = true;
                    }
                }
                else
                {
                    errorString = noIfStatement;
                    showError = true;
                }
            }

            // Button that opens level door
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.48f, Screen.width * 0.14f, Screen.height * 0.05f), "Open Door"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                if (ifAdded)
                {
                    int num = getNumOfTabs(code, editor.pos);

                    if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                    {
                        code = addToCode(code, editor, "openDoor();");
                        if (countLinesBefore(code, editor.pos) == 10)
                        {
                            elseVar = "doorOpen";
                        }
                        else
                        {
                            ifVar = "doorOpen";
                        }
                    }
                    else
                    {
                        errorString = cantType;
                        showError = true;
                    }
                }
                else
                {
                    errorString = noIfStatement;
                    showError = true;
                }
            }
           
            // Button that activates the user's code
            if (GUI.Button(new Rect(Screen.width * 0.6f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Submit"))
            {
                switch (ifVar)
                {
                    case ("doorOpen"):
                        doorOpen = true;
                        break;
                    case ("gateLowered"):
                        gateLowered = true;
                        break;
                    case ("holeOpened"):
                        holeOpened = true;
                        break;
                }
                switch (elseVar)
                {
                    case ("doorOpen"):
                        action = 3;
                        break;
                    case ("gateLowered"):
                        action = 1;
                        break;
                    case ("holeOpened"):
                        action = 2;
                        break;
                }
                resume();
            }
            // Button that closes the UI and disregards changes
            if (GUI.Button(new Rect(Screen.width * 0.7f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Cancel"))
            {
                resume();
                code = restoreCode();
                showError = false;
                ifAdded = false;
                doorOpen = false;
            }


            // Button that restores the code in the textArea to its original state
            if (GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Reset"))
            {
                code = restoreCode();
                showError = false;
                ifAdded = false;
                doorOpen = false;
            }
            if (reset)
            {
                code = restoreCode();
                showError = false;
                ifAdded = false;
                doorOpen = false;
                holeOpened = false;
                gateLowered = false;
                ballMoving = true;
                doorOpenDone = false;
                holeOpenedDone = false;
                gateLoweredDone = false;
                reset = false;
                action = -1;
                ifVar = "";
                elseVar = "";
            }

        }

    }
Пример #12
0
    //*******************************************************


    //Includes all the GUI elements
    //*******************************************************
    public void OnGUI()
    {

        if (!atOpponentWall)
        {  //If not at wall terminal jack in - "show crosshair"
            Vector3 mPos = Input.mousePosition;
            //GUI.DrawTexture (new Rect (mPos.x - 32, Screen.height - mPos.y - 32, 64, 64), cursorImage);
        }
        else if (atOpponentWall && Input.GetKeyDown("e"))
        {
            //GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor=false;
            //If at wall terminal show default cursor instead
        }

        if (guiEnabled)
        {
            GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "List of Functions");

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.3f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }
            GUI.SetNextControlName("textarea");
            GUI.TextArea(new Rect(Screen.width * 0.3f, Screen.width * 0.04f, Screen.width * 0.65f, Screen.height * 0.75f), code);

            if (showError)
            {
                GUI.Label(new Rect(Screen.width * 0.4f, Screen.height * 0.45f, Screen.width * 0.3f, Screen.height * 0.1f), errorString);
                if (GUI.Button(new Rect(Screen.width * 0.47f, Screen.height * 0.55f, Screen.width * 0.06f, Screen.height * 0.04f), "sorry"))
                {
                    showError = false;
                }
            }

            editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
            editor.SelectNone();
            editor.MoveLineEnd();


        

            int temp;



            // for loop starting value textfield
            //*******************************************************
            string fs = GUI.TextField(new Rect(Screen.width * 0.22f, Screen.height * 0.28f, Screen.width * 0.04f, Screen.height * 0.05f), forStart.ToString());
            if (int.TryParse(fs, out temp))
            {
                forStart = Mathf.Clamp(temp, 0, 100);
            }
            else if (fs == "")
            {
                forStart = 0;
            }
            //*******************************************************
            GUI.Label(new Rect(Screen.width * 0.22f, Screen.height * 0.24f, Screen.width * 0.04f, Screen.height * 0.05f), ("start"));  	//for loop parameter title

            //for loop ending value textfield
            //*******************************************************
            string ff = GUI.TextField(new Rect(Screen.width * 0.26f, Screen.height * 0.28f, Screen.width * 0.04f, Screen.height * 0.05f), forFinish.ToString());
            if (int.TryParse(ff, out temp))
            {
                forFinish = Mathf.Clamp(temp, 0, 100);
            }
            else if (ff == "")
            {
                forFinish = 0;
            }
            //*******************************************************

            string val = GUI.TextField(new Rect(Screen.width * 0.22f, Screen.height * 0.56f, Screen.width * 0.04f, Screen.height * 0.05f), value.ToString());
            if (int.TryParse(val, out temp))
            {
                value = Mathf.Clamp(temp, 0, 100);
            }
            else if (val == "")
            {
                value = 0;
            }


            GUI.Label(new Rect(Screen.width * 0.26f, Screen.height * 0.24f, Screen.width * 0.04f, Screen.height * 0.05f), ("finish"));  	//for loop parameter title


            // Button that inserts a Random generator function
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.28f, Screen.width * 0.2f, Screen.height * 0.1f), "Assign a Random int between"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                int num = getNumOfTabs(code, editor.pos);
                if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                {
                    randClicked = true;
                    if (!switchClicked && !facesClicked)
                        rand1 = true;
                    if ((forFinish == 6) && (forStart == 1))
                    {
                        randCorrect = true;
                        code = addToCode(code, editor, "rolledNumber = (int)(Math.random() * " + ff + " + " + fs + ");\n" + addedTabs(num));
                    }
                    else
                    {
                        randCorrect = false;
                        errorString = randFalseError;
                        showError = true;
                    }
                }
                else
                {
                    errorString = cantType;
                    showError = true;
                }

            }
            // Button inserts a switch statement
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.42f, Screen.width * 0.2f, Screen.height * 0.1f), "Add Switch Statement"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                editor.MoveLineEnd();
                int num = getNumOfTabs(code, editor.pos);
                if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                {
                    if (!switchClicked)
                    {
                        code = addToCode(code, editor, "switch(rolledNumber){\n" +
                                addedTabs(num) + "\tcase 1:\n" + "\t\t"
                                + addedTabs(num) + "\n"
                                + addedTabs(num) + "\t\tbreak;\n"
                                + addedTabs(num) + "\tcase 2:\n" + "\t\t"
                                + addedTabs(num) + "\n"
                                + addedTabs(num) + "\t\tbreak;\n"
                                + addedTabs(num) + "\tcase 3:\n" + "\t\t"
                                + addedTabs(num) + "\n"
                                + addedTabs(num) + "\t\tbreak;\n"
                                + addedTabs(num) + "\tcase 4:\n" + "\t\t"
                                + addedTabs(num) + "\n"
                                + addedTabs(num) + "\t\tbreak;\n"
                                + addedTabs(num) + "\tcase 5:\n" + "\t\t"
                                + addedTabs(num) + "\n"
                                + addedTabs(num) + "\t\tbreak;\n"
                                + addedTabs(num) + "\tcase 6:\n" + "\t\t"
                                + addedTabs(num) + "\n"
                                + addedTabs(num) + "\t\tbreak;\n"
                                + addedTabs(num) + "\tdefault:\n"
                                + addedTabs(num) + "\t\tSystem.out.println(\"Wrong value, check your random generation\");");
                        switchClicked = true;
                    }
                    else
                    {
                        errorString = switch1Error;
                        showError = true;
                    }
                    if (randClicked && !facesClicked)
                        switch2 = true;
                }
                else
                {
                    errorString = cantType;
                    showError = true;
                }
            }


            // Button that assigns a number to face
            if (GUI.Button(new Rect(Screen.width * 0.02f, Screen.height * 0.56f, Screen.width * 0.2f, Screen.height * 0.1f), "Assign an int to topFace"))
            {
                GUI.FocusControl("textarea");
                editor = goToNextEmptyLine(editor, code);
                if (randClicked && switchClicked)
                    face3 = true;

                if (((value == 1) || (value == 2) || (value == 3) || (value == 4) || (value == 5)) && !randClicked && !switchClicked)
                {
                    errorString = cheatError;
                    showError = true;

                }
                else if ((countLinesBefore(code, editor.pos) >= 2) && (countLinesAfter(code, editor.pos) >= 2) && isBlankLine(code, editor.pos))
                {
                    if (countLinesBefore(code, editor.pos) == 7)
                        if (value == 1)
                            case1 = true;
                        else
                            case1 = false;
                    if (countLinesBefore(code, editor.pos) == 10)
                        if (value == 2)
                            case2 = true;
                        else
                            case2 = false;
                    if (countLinesBefore(code, editor.pos) == 13)
                        if (value == 3)
                            case3 = true;
                        else
                            case3 = false;
                    if (countLinesBefore(code, editor.pos) == 16)
                        if (value == 4)
                            case4 = true;
                        else
                            case4 = false;
                    if (countLinesBefore(code, editor.pos) == 19)
                        if (value == 5)
                            case5 = true;
                        else
                            case5 = false;
                    if (countLinesBefore(code, editor.pos) == 22)
                        if (value == 6)
                            case6 = true;
                        else
                            case6 = false;

                    if ((case1) && (case2) && (case3) && (case4) && (case5) && (case6))
                        facesCorrect = true;
                    if ((value > 6) || (value < 1))
                    {
                        errorString = wrongFace;
                        showError = true;
                    }
                    else
                    {
                        facesClicked = true;
                        code = addToCode(code, editor, "topFace = " + value + " ;");
                    }

                }
                else
                {
                    errorString = cantType;
                    showError = true;
                }
            }

            // Button that activates the user's code
            if (GUI.Button(new Rect(Screen.width * 0.6f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Submit"))
            {
                TextChanger.Update();
                if (facesCorrect && face3 && switch2 && rand1 && randCorrect)
                {
					audio.PlayOneShot (missionComplete);
                    GameObject.Find("d6").GetComponent<DiceRotateLoaded>().loaded = false;
                    GameObject.Find("Initialization").GetComponent<PoisonTime>().cheating = false;
                }

                resume();
            }

            // Button that closes the UI and disregards changes
            if (GUI.Button(new Rect(Screen.width * 0.7f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Cancel"))
            {
                code = restoreCode();
                resetValues();
                resume();
            }

            // Button that restores the code in the textArea to its original state
            if (GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.9f, Screen.width * 0.08f, Screen.height * 0.05f), "Reset"))
            {
                code = restoreCode();
            }
        }
    }