PageRenderTime 15ms CodeModel.GetById 2ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/Scripts/ThoughtBubble.js

http://acid-and-base.googlecode.com/
JavaScript | 97 lines | 80 code | 10 blank | 7 comment | 21 complexity | ab04321e4c9e6586df9dc646db4857ab MD5 | raw file
 1var inRangeA:boolean;
 2var inRangeB:boolean;
 3var inRangeR:boolean;
 4
 5var thoughtText:String;
 6
 7var custom:GUIStyle;
 8var defaultstyle:GUIStyle;
 9
10enum CharacterThought { Red=0, Acid=1, Base=2 }
11
12var focusedCharacter : CharacterThought;
13
14var showA:boolean;
15var showB:boolean;
16var showR:boolean;
17
18function Start()
19{
20	inRangeA = false;
21	inRangeB = false;
22	inRangeR = false;
23	showA = false;
24	showB = false;
25	showR = false;
26}
27
28function OnGUI () 
29{
30	//Show the contents of the menu if it is active
31	switch (focusedCharacter)
32	{
33		case CharacterThought.Red:
34			if(showR)
35			{
36				// Make a background box
37				GUI.Box (Rect ((Screen.width-400)/2,(Screen.height-400)/2,400,400), "",custom);
38				GUI.Label (Rect ((Screen.width-200)/2,(Screen.height)/2,400,200), thoughtText,defaultstyle);
39			}
40		break;
41		case CharacterThought.Acid:
42			if(showA)
43			{
44				// Make a background box
45				GUI.Box (Rect ((Screen.width-400)/2,(Screen.height-400)/2,400,400), "",custom);
46				GUI.Label (Rect ((Screen.width-200)/2,(Screen.height)/2,400,200), thoughtText,defaultstyle);
47			}
48		break;
49		case CharacterThought.Base:
50			if(showB)
51			{
52				// Make a background box
53				GUI.Box (Rect ((Screen.width-400)/2,(Screen.height-400)/2,400,400), "",custom);
54				GUI.Label (Rect ((Screen.width-200)/2,(Screen.height)/2,400,200), thoughtText,defaultstyle);			}
55		break;
56	}
57} 
58
59function OnTriggerEnter (col : Collider) {
60	var property : Properties = col.GetComponent(Properties);
61	if(property == null)
62		return;
63	if(property.abType == AcidOrBase.Base)
64		inRangeB = true;
65	else
66		inRangeA = true;
67}
68
69/*
70* If Acid or Base leave, they are not in range.
71*/
72function OnTriggerExit (col : Collider) {
73	var property : Properties = col.GetComponent(Properties);
74	if(property == null)
75		return;
76	if(property.abType == AcidOrBase.Base)
77		inRangeB = false;
78	else
79		inRangeA = false;
80}
81
82function Update () 
83{
84	var mcontrol = gameObject.Find("Master Controller Light").GetComponent(MasterController_edit);
85	if(mcontrol.getActivePlayer() == 0 && inRangeR)
86		showR = true;
87	else
88		showR = false;
89	if(mcontrol.getActivePlayer() == 1 && inRangeA)
90		showA = true;
91	else
92		showA = false;
93	if(mcontrol.getActivePlayer() == 2 && inRangeB)
94		showB = true;
95	else
96		showB = false;
97}