/Scripts/AcidColorChange.js

http://acid-and-base.googlecode.com/ · JavaScript · 39 lines · 36 code · 3 blank · 0 comment · 22 complexity · 6eb093c1f6c0af5f1e2c3038fc78509d MD5 · raw file

  1. function 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. mats[1].color = Color(255/255.0, 0, 0); // Color(R, G, B) - change to red
  7. yield WaitForSeconds(1.1); // pause for a sec
  8. mats[1].color =origColor; // change it back
  9. }
  10. }
  11. function Update(){
  12. var component = GameObject.Find("Acid/Acid03");
  13. var mats = component.renderer.materials;
  14. var current_ph = GetComponent(Properties).ph; // get current ph level
  15. if(current_ph == 7){
  16. mats[1].color = Color(80/255.0,235.0/255.0,63/255.0); // (R, G, B)
  17. }
  18. else if(current_ph == 6){
  19. mats[1].color = Color(171/255.0,255/255.0,0);
  20. }
  21. else if(current_ph == 5){
  22. mats[1].color = Color(1, 1, 0);
  23. }
  24. else if(current_ph == 4){
  25. mats[1].color = Color(255/255.0,222/255.0,0);
  26. }
  27. else if(current_ph == 3){
  28. mats[1].color = Color(255/255.0,125/255.0,0);
  29. }
  30. else if(current_ph == 2){
  31. mats[1].color = Color(255/255.0,100/255.0,0);
  32. }
  33. else if(current_ph == 1){
  34. mats[1].color = Color(166/255.0,28/255.0,0);
  35. }
  36. }