PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Scripts/AcidColorChange.js

http://acid-and-base.googlecode.com/
JavaScript | 39 lines | 36 code | 3 blank | 0 comment | 22 complexity | 6eb093c1f6c0af5f1e2c3038fc78509d MD5 | raw file
 1function OnControllerColliderHit(hit : ControllerColliderHit) {
 2	if(hit.gameObject.name == "PseudoEnemy"){
 3		var component = GameObject.Find("Acid/Acid03");
 4		var mats = component.renderer.materials;
 5		var origColor = mats[1].color;
 6		
 7		mats[1].color = Color(255/255.0, 0, 0); // Color(R, G, B) - change to red
 8		yield WaitForSeconds(1.1); // pause for a sec
 9		mats[1].color =origColor; // change it back	
10	}
11}
12
13function Update(){
14	var component = GameObject.Find("Acid/Acid03");
15	var mats = component.renderer.materials;
16	var current_ph = GetComponent(Properties).ph; // get current ph level
17	
18	if(current_ph == 7){
19		mats[1].color = Color(80/255.0,235.0/255.0,63/255.0); // (R, G, B)
20	}
21	else if(current_ph == 6){
22		mats[1].color = Color(171/255.0,255/255.0,0);
23	}
24	else if(current_ph == 5){
25		mats[1].color = Color(1, 1, 0);
26	}
27	else if(current_ph == 4){
28		mats[1].color = Color(255/255.0,222/255.0,0);
29	}
30	else if(current_ph == 3){
31		mats[1].color = Color(255/255.0,125/255.0,0);
32	}
33	else if(current_ph == 2){
34		mats[1].color = Color(255/255.0,100/255.0,0);
35	}
36	else if(current_ph == 1){
37		mats[1].color = Color(166/255.0,28/255.0,0);
38	}
39}