/Scripts/WeedKillerInteract.js
JavaScript | 64 lines | 63 code | 1 blank | 0 comment | 9 complexity | 90d1fb30ee05ac09fd4f9e992a1e5cf2 MD5 | raw file
- var inRange : boolean = false;
- var showGUI : boolean = false;
- var ant;
- var bred;
- var acid;
- var base;
- var mcont;
- function Start ()
- {
- ant = GameObject.Find("AntDialog").GetComponent("Tutorial");
- bred = GameObject.Find("Big Red");
- acid = GameObject.Find("Acid");
- base = GameObject.Find("Base");
- mcont = GameObject.Find("Master Controller Light");
- }
- function OnTriggerEnter (col : Collider)
- {
- if(col.GetComponent(CharacterController) == null)
- return;
- inRange = true;
- }
- function OnTriggerExit (col : Collider)
- {
- if(col.GetComponent(CharacterController) == null)
- return;
- inRange = false;
- }
- function Update ()
- {
- if(inRange)
- {
- if(Input.GetKeyDown(KeyCode.E))
- {
-
- showGUI = true;
- ant.weedkiller = true;
- bred.GetComponent("ModifiedController").enabled = false;
- bred.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- acid.GetComponent("ModifiedController").enabled = false;
- acid.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- base.GetComponent("ModifiedController").enabled = false;
- base.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- mcont.both = false;
- }
- }
- if(Input.GetKeyDown(KeyCode.Space) && showGUI)
- {
- showGUI = false;
- bred.GetComponent("ModifiedController").enabled = true;
- acid.GetComponent("ModifiedController").enabled = true;
- base.GetComponent("ModifiedController").enabled = true;
- mcont.both = true;
- }
- }
- function OnGUI ()
- {
- if(showGUI)
- {
- var enter : String = "Press Space to Continue";
- var tutorialtext : String = "Soap + Water + Salt = Weed Killer";
- GUI.Label (Rect (Screen.width/2 - (tutorialtext.length * 10)/2, Screen.height/2 - 10, tutorialtext.length * 10, 20), tutorialtext, "box");
- GUI.Label (Rect (Screen.width/2 - (10*enter.length/2), Screen.height/2 + 10 + 10, (10*enter.length), 20), enter, "box");
- }
- }