/Scripts/ThoughtBubble.js
http://acid-and-base.googlecode.com/ · JavaScript · 97 lines · 80 code · 10 blank · 7 comment · 21 complexity · ab04321e4c9e6586df9dc646db4857ab MD5 · raw file
- var inRangeA:boolean;
- var inRangeB:boolean;
- var inRangeR:boolean;
- var thoughtText:String;
- var custom:GUIStyle;
- var defaultstyle:GUIStyle;
- enum CharacterThought { Red=0, Acid=1, Base=2 }
- var focusedCharacter : CharacterThought;
- var showA:boolean;
- var showB:boolean;
- var showR:boolean;
- function Start()
- {
- inRangeA = false;
- inRangeB = false;
- inRangeR = false;
- showA = false;
- showB = false;
- showR = false;
- }
- function OnGUI ()
- {
- //Show the contents of the menu if it is active
- switch (focusedCharacter)
- {
- case CharacterThought.Red:
- if(showR)
- {
- // Make a background box
- GUI.Box (Rect ((Screen.width-400)/2,(Screen.height-400)/2,400,400), "",custom);
- GUI.Label (Rect ((Screen.width-200)/2,(Screen.height)/2,400,200), thoughtText,defaultstyle);
- }
- break;
- case CharacterThought.Acid:
- if(showA)
- {
- // Make a background box
- GUI.Box (Rect ((Screen.width-400)/2,(Screen.height-400)/2,400,400), "",custom);
- GUI.Label (Rect ((Screen.width-200)/2,(Screen.height)/2,400,200), thoughtText,defaultstyle);
- }
- break;
- case CharacterThought.Base:
- if(showB)
- {
- // Make a background box
- GUI.Box (Rect ((Screen.width-400)/2,(Screen.height-400)/2,400,400), "",custom);
- GUI.Label (Rect ((Screen.width-200)/2,(Screen.height)/2,400,200), thoughtText,defaultstyle); }
- break;
- }
- }
- function OnTriggerEnter (col : Collider) {
- var property : Properties = col.GetComponent(Properties);
- if(property == null)
- return;
- if(property.abType == AcidOrBase.Base)
- inRangeB = true;
- else
- inRangeA = true;
- }
- /*
- * If Acid or Base leave, they are not in range.
- */
- function OnTriggerExit (col : Collider) {
- var property : Properties = col.GetComponent(Properties);
- if(property == null)
- return;
- if(property.abType == AcidOrBase.Base)
- inRangeB = false;
- else
- inRangeA = false;
- }
- function Update ()
- {
- var mcontrol = gameObject.Find("Master Controller Light").GetComponent(MasterController_edit);
- if(mcontrol.getActivePlayer() == 0 && inRangeR)
- showR = true;
- else
- showR = false;
- if(mcontrol.getActivePlayer() == 1 && inRangeA)
- showA = true;
- else
- showA = false;
- if(mcontrol.getActivePlayer() == 2 && inRangeB)
- showB = true;
- else
- showB = false;
- }