/Scripts/AcidBase.js
http://acid-and-base.googlecode.com/ · JavaScript · 31 lines · 26 code · 5 blank · 0 comment · 8 complexity · 2ba168c710225ace616f89f9e1eb5513 MD5 · raw file
- private var enable : boolean;
- private var txt : String;
- function Star(){
- enable = false;
- txt = "";
- }
- function OnCollisionEnter (col : Collision) {
- if(col.collider.GetComponent(Properties) && gameObject.GetComponent(Properties)){ //If the objects contain chemical properties
- var oneProperties = gameObject.GetComponent(Properties);
- var twoProperties = col.collider.GetComponent(Properties);
-
- if(oneProperties.ph < 7 && twoProperties.ph > 7){//Acid + Base...
- txt = "Acid + Base";
- }
- else if(oneProperties.ph > 7 && twoProperties.ph < 7){//Base + Acid...
- txt = "Base + Acid";
- }
-
- enable = true;
- yield WaitForSeconds(2.0);
- enable = false;
- }
- }
- function OnGUI () {
- if (enable){
- GUI.Label (Rect (Screen.width/2 - 50, Screen.height/2 - 10, 100, 20), txt, "box");
- }
- }