Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. #pragma strict
  2.  
  3. public var groundLevel = -0.384;
  4. public var jumpHigh = false;
  5.  
  6. function playerFall() {
  7. Debug.Log("aPE - player fall -");
  8. transform.position.y -= 0.5;
  9. transform.rotation.z += 0.5;
  10. yield WaitForSeconds (0.3);
  11. transform.position.y -= 0.5;
  12. transform.rotation.z += 0.5;
  13. //1
  14. yield WaitForSeconds (0.3);
  15. transform.rotation.z += 0.5;
  16. transform.position.y -= 0.5;
  17. yield WaitForSeconds (0.3);
  18. transform.rotation.z += 0.5;
  19. transform.position.y -= 0.5;
  20. //2
  21. yield WaitForSeconds (0.3);
  22. transform.position.y -= 0.5;
  23. transform.rotation.z += 0.5;
  24. yield WaitForSeconds (0.3);
  25. transform.position.y -= 0.5;
  26. transform.rotation.z += 0.5;
  27. //3
  28. yield WaitForSeconds (0.3);
  29. transform.position.y -= 0.5;
  30. transform.rotation.z += 0.5;
  31. yield WaitForSeconds (0.3);
  32. transform.position.y -= 0.5;
  33. //4
  34. transform.rotation.z += 0.5;
  35. yield WaitForSeconds (0.3);
  36. transform.position.y -= 0.5;
  37. yield WaitForSeconds (0.3);
  38. transform.position.y -= 0.5;
  39. //5
  40. }
  41.  
  42. function playerDeath () {
  43. Debug.Log("aPE - player death -");
  44. Destroy (gameObject);
  45. yield WaitForSeconds(1);
  46. Application.Quit();
  47. }
  48.  
  49. function playerJump () {
  50. Debug.Log("aPE - player jump -");
  51.  
  52.  
  53.  
  54. if(jumpHigh == false) {
  55.  
  56.  
  57.  
  58. transform.position.y += 0.1;
  59. yield WaitForSeconds (0.01);
  60. transform.position.y += 0.1;
  61.  
  62. yield WaitForSeconds (0.01);
  63. transform.position.y += 0.1;
  64. yield WaitForSeconds (0.01);
  65. transform.position.y += 0.1;
  66.  
  67. yield WaitForSeconds (0.01);
  68. transform.position.y += 0.1;
  69. yield WaitForSeconds (0.01);
  70. transform.position.y += 0.1;
  71.  
  72. transform.position.y -= 0.1;
  73. yield WaitForSeconds (0.01);
  74. transform.position.y -= 0.1;
  75.  
  76. yield WaitForSeconds (0.01);
  77. transform.position.y -= 0.1;
  78. yield WaitForSeconds (0.01);
  79. transform.position.y -= 0.1;
  80.  
  81. yield WaitForSeconds (0.01);
  82. transform.position.y -= 0.1;
  83. yield WaitForSeconds (0.01);
  84. transform.position.y -= 0.1;
  85. }
  86.  
  87.  
  88.  
  89. if(jumpHigh == true) {
  90.  
  91.  
  92.  
  93. transform.position.y += 0.1;
  94. yield WaitForSeconds (0.01);
  95. transform.position.y += 0.1;
  96.  
  97. yield WaitForSeconds (0.01);
  98. transform.position.y += 0.1;
  99. yield WaitForSeconds (0.01);
  100. transform.position.y += 0.1;
  101.  
  102. yield WaitForSeconds (0.01);
  103. transform.position.y += 0.1;
  104. yield WaitForSeconds (0.01);
  105. transform.position.y += 0.1;
  106.  
  107. transform.position.y += 0.1;
  108. yield WaitForSeconds (0.01);
  109. transform.position.y += 0.1;
  110.  
  111. yield WaitForSeconds (0.01);
  112. transform.position.y += 0.1;
  113. yield WaitForSeconds (0.01);
  114. transform.position.y += 0.1;
  115.  
  116. yield WaitForSeconds (0.01);
  117. transform.position.y += 0.1;
  118. yield WaitForSeconds (0.01);
  119. transform.position.y += 0.1;
  120.  
  121. transform.position.y -= 0.1;
  122. yield WaitForSeconds (0.01);
  123. transform.position.y -= 0.1;
  124.  
  125. yield WaitForSeconds (0.01);
  126. transform.position.y -= 0.1;
  127. yield WaitForSeconds (0.01);
  128. transform.position.y -= 0.1;
  129.  
  130. yield WaitForSeconds (0.01);
  131. transform.position.y -= 0.1;
  132. yield WaitForSeconds (0.01);
  133. transform.position.y -= 0.1;
  134.  
  135. transform.position.y -= 0.1;
  136. yield WaitForSeconds (0.01);
  137. transform.position.y -= 0.1;
  138.  
  139. yield WaitForSeconds (0.01);
  140. transform.position.y -= 0.1;
  141. yield WaitForSeconds (0.01);
  142. transform.position.y -= 0.1;
  143.  
  144. yield WaitForSeconds (0.01);
  145. transform.position.y -= 0.1;
  146. yield WaitForSeconds (0.01);
  147. transform.position.y -= 0.1;
  148. }
  149.  
  150. }
  151.  
  152.  
  153. function Start () {
  154. Debug.Log("aPE 0.12 is running");
  155. }
  156.  
  157. function Update () {
  158. if (transform.position.y <= groundLevel -4) {
  159. playerDeath();
  160. }
  161.  
  162. if (transform.position.z >= 5.738) {
  163. playerFall();
  164. }
  165. if (transform.position.z <= -10.202) {
  166. playerFall();
  167. }
  168. if (transform.position.x >= 4.609) {
  169. playerFall();
  170. }
  171. if (transform.position.x <= -8.261) {
  172. playerFall();
  173. }
  174. if (Input.GetKeyDown(KeyCode.Space)) {
  175. playerJump();
  176. }
  177.  
  178.  
  179.  
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement