Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. var offset:Vector3;
  2. var pos:Vector3;
  3. var cam :Camera;
  4. var fin :boolean;
  5. var init :Vector3;
  6. var timerText : UI.Text;
  7. var timerNumber : float;
  8. function Start () {
  9. fin=false;
  10. }
  11.  
  12. function Update () {
  13. timerNumber -= Time.deltaTime;
  14. timerText.text = "Time left: "+timerNumber.ToString("0");
  15. if (timerNumber.ToString("0") == "0"){
  16. timerNumber = 0;
  17. SceneManager.LoadScene("game_over1");
  18. }
  19.  
  20. }
  21.  
  22. function OnMouseDown()
  23. {
  24. offset=transform.position-cam.main.ScreenToWorldPoint(Input.mousePosition);
  25.  
  26.  
  27.  
  28. init=transform.position;
  29.  
  30.  
  31. }
  32.  
  33. function OnMouseDrag()
  34.  
  35. {
  36. if (fin==false){
  37. pos=cam.main.ScreenToWorldPoint(Input.mousePosition)+offset;
  38. transform.position=pos;
  39. }
  40. }
  41.  
  42. function OnTriggerEnter2D(other:Collider2D)
  43. {
  44. if(other.gameObject.name=="g1"){
  45. fin=true ;
  46.  
  47. transform.position=other.gameObject.transform.position;
  48. transform.position.z=-1;
  49. transform.position.y=1.97;
  50. transform.position.x=1.78;
  51. transform.localScale.x=0.4;
  52. transform.localScale.y=0.4;
  53. }
  54.  
  55. if(other.gameObject.name=="g2"){
  56. fin=true ;
  57.  
  58. transform.position=other.gameObject.transform.position;
  59. transform.position.z=-0.5;
  60. transform.position.y=-1.63;
  61. transform.position.x=1.89;
  62. transform.localScale.x=0.4;
  63. transform.localScale.y=0.4;
  64. }
  65.  
  66. if(other.gameObject.name=="g3"){
  67. fin=true ;
  68.  
  69. transform.position=other.gameObject.transform.position;
  70. transform.position.z=-1;
  71. transform.position.y=-1.66;
  72. transform.position.x=7.78;
  73. transform.localScale.x=0.4;
  74. transform.localScale.y=0.4;
  75. }
  76. }
  77. function OnMouseUp(){
  78. if( fin==false){
  79. transform.position=init;
  80. }
  81.  
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement