PageRenderTime 28ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/Scripts/WeedKillerInteract.js

http://acid-and-base.googlecode.com/
JavaScript | 64 lines | 63 code | 1 blank | 0 comment | 9 complexity | 90d1fb30ee05ac09fd4f9e992a1e5cf2 MD5 | raw file
  1. var inRange : boolean = false;
  2. var showGUI : boolean = false;
  3. var ant;
  4. var bred;
  5. var acid;
  6. var base;
  7. var mcont;
  8. function Start ()
  9. {
  10. ant = GameObject.Find("AntDialog").GetComponent("Tutorial");
  11. bred = GameObject.Find("Big Red");
  12. acid = GameObject.Find("Acid");
  13. base = GameObject.Find("Base");
  14. mcont = GameObject.Find("Master Controller Light");
  15. }
  16. function OnTriggerEnter (col : Collider)
  17. {
  18. if(col.GetComponent(CharacterController) == null)
  19. return;
  20. inRange = true;
  21. }
  22. function OnTriggerExit (col : Collider)
  23. {
  24. if(col.GetComponent(CharacterController) == null)
  25. return;
  26. inRange = false;
  27. }
  28. function Update ()
  29. {
  30. if(inRange)
  31. {
  32. if(Input.GetKeyDown(KeyCode.E))
  33. {
  34. showGUI = true;
  35. ant.weedkiller = true;
  36. bred.GetComponent("ModifiedController").enabled = false;
  37. bred.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
  38. acid.GetComponent("ModifiedController").enabled = false;
  39. acid.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
  40. base.GetComponent("ModifiedController").enabled = false;
  41. base.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
  42. mcont.both = false;
  43. }
  44. }
  45. if(Input.GetKeyDown(KeyCode.Space) && showGUI)
  46. {
  47. showGUI = false;
  48. bred.GetComponent("ModifiedController").enabled = true;
  49. acid.GetComponent("ModifiedController").enabled = true;
  50. base.GetComponent("ModifiedController").enabled = true;
  51. mcont.both = true;
  52. }
  53. }
  54. function OnGUI ()
  55. {
  56. if(showGUI)
  57. {
  58. var enter : String = "Press Space to Continue";
  59. var tutorialtext : String = "Soap + Water + Salt = Weed Killer";
  60. GUI.Label (Rect (Screen.width/2 - (tutorialtext.length * 10)/2, Screen.height/2 - 10, tutorialtext.length * 10, 20), tutorialtext, "box");
  61. GUI.Label (Rect (Screen.width/2 - (10*enter.length/2), Screen.height/2 + 10 + 10, (10*enter.length), 20), enter, "box");
  62. }
  63. }