PageRenderTime 36ms CodeModel.GetById 26ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Scripts/WeedKillerInteract.js

http://acid-and-base.googlecode.com/
JavaScript | 64 lines | 63 code | 1 blank | 0 comment | 9 complexity | 90d1fb30ee05ac09fd4f9e992a1e5cf2 MD5 | raw file
 1var inRange : boolean = false;
 2var showGUI : boolean = false;
 3var ant;
 4var bred;
 5var acid;
 6var base;
 7var mcont;
 8function Start ()
 9{
10	ant = GameObject.Find("AntDialog").GetComponent("Tutorial");
11	bred = GameObject.Find("Big Red");
12	acid = GameObject.Find("Acid");
13	base = GameObject.Find("Base");
14	mcont = GameObject.Find("Master Controller Light");
15}
16function OnTriggerEnter (col : Collider)
17{
18	if(col.GetComponent(CharacterController) == null)
19		return;
20	inRange = true;
21}
22function OnTriggerExit (col : Collider)
23{
24	if(col.GetComponent(CharacterController) == null)
25		return;
26	inRange = false;
27}
28function Update () 
29{
30	if(inRange)
31	{
32		if(Input.GetKeyDown(KeyCode.E))
33		{
34			
35			showGUI = true;
36			ant.weedkiller = true;
37			bred.GetComponent("ModifiedController").enabled = false;
38			bred.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
39			acid.GetComponent("ModifiedController").enabled = false;
40			acid.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
41			base.GetComponent("ModifiedController").enabled = false;
42			base.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
43			mcont.both = false;
44		}
45	}
46	if(Input.GetKeyDown(KeyCode.Space) && showGUI)
47	{
48		showGUI = false;
49		bred.GetComponent("ModifiedController").enabled = true;
50		acid.GetComponent("ModifiedController").enabled = true;
51		base.GetComponent("ModifiedController").enabled = true;
52		mcont.both = true;
53	}
54}
55function OnGUI ()
56{
57	if(showGUI)
58	{
59		var enter : String = "Press Space to Continue";
60		var tutorialtext : String = "Soap + Water + Salt = Weed Killer";
61		GUI.Label (Rect (Screen.width/2 - (tutorialtext.length * 10)/2, Screen.height/2 - 10, tutorialtext.length * 10, 20), tutorialtext, "box");
62                GUI.Label (Rect (Screen.width/2 - (10*enter.length/2), Screen.height/2 + 10 + 10, (10*enter.length), 20), enter, "box");
63	}
64}