PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Scripts/AcidBase.js

http://acid-and-base.googlecode.com/
JavaScript | 31 lines | 26 code | 5 blank | 0 comment | 8 complexity | 2ba168c710225ace616f89f9e1eb5513 MD5 | raw file
 1private var enable : boolean;
 2private var txt : String;
 3
 4function Star(){
 5	enable = false;
 6	txt = "";
 7}
 8
 9function  OnCollisionEnter (col : Collision) {
10	if(col.collider.GetComponent(Properties) && gameObject.GetComponent(Properties)){ //If the objects contain chemical properties
11		var oneProperties = gameObject.GetComponent(Properties);
12		var twoProperties = col.collider.GetComponent(Properties);
13		
14		if(oneProperties.ph < 7 && twoProperties.ph > 7){//Acid + Base...
15			txt = "Acid + Base";
16		}
17		else if(oneProperties.ph > 7 && twoProperties.ph < 7){//Base + Acid...
18			txt = "Base + Acid";
19		}
20		
21		enable = true;
22		yield WaitForSeconds(2.0);
23		enable = false;
24	}
25}
26
27function OnGUI () {
28	if (enable){
29		GUI.Label (Rect (Screen.width/2 - 50, Screen.height/2 - 10, 100, 20), txt, "box");
30		}
31}