Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. #pragma strict
  2.  
  3.  
  4. private var isStopped:boolean = false;
  5. private var isDead:boolean = false;
  6.  
  7.  
  8. var speed : float = 6.0;
  9. var jumpSpeed : float ;
  10. var gravity : float = 20.0;
  11. private var moveDirection : Vector3 = Vector3.zero;
  12. private var isJumping:boolean = false;
  13. var characAnimation:GameObject ;
  14. var scriptdistance:ScriptDistance;
  15.  
  16.  
  17.  
  18. var explosion:GameObject;
  19. var explosionForce: float = 5;
  20. var explosionRadius: float = 5;
  21. //var upwardsModifier: float = 0;
  22.  
  23.  
  24.  
  25. function Update()
  26. {
  27.  
  28.  
  29. if (isStopped == false){
  30. var controller : CharacterController = GetComponent(CharacterController);
  31.  
  32. if (controller.isGrounded){
  33.  
  34. if(isJumping == true){
  35. isJumping = false;
  36. characAnimation.GetComponent(Animator).SetBool("jump", isJumping);
  37. //characAnimation.GetComponent(Animator).Play("Jump Start");
  38. characAnimation.GetComponent(Animator).Play("Jump Landing");
  39.  
  40.  
  41. }
  42.  
  43.  
  44.  
  45.  
  46.  
  47. // We are grounded, so recalculate
  48. //move direction directly from axes
  49. moveDirection = Vector3 (1,0,0);
  50. //moveDirection = transForceMode.TransformDirection(moveDirection);
  51. moveDirection *= speed;
  52.  
  53.  
  54. if (Input.GetButton ("Jump")&& isJumping == false){
  55. //&& isJumping == false)
  56. //characAnimation.GetComponent(Animator).SetTrigger ("Jump") ;
  57. moveDirection.y = jumpSpeed;
  58. isJumping = true;
  59. //animator.SetTrigger ("Jump") ;
  60. characAnimation.GetComponent(Animator).SetBool("jump", isJumping);
  61. Debug.Log("isJumping" +isJumping);
  62. }
  63. }
  64.  
  65.  
  66. //moveDirection.z = Input.GetAxis("Horizontal");
  67. //moveDirection.z *= speed;
  68.  
  69. // Apply gravity
  70. moveDirection.y -= gravity * Time.deltaTime ;
  71. characAnimation.GetComponent(Animator).SetFloat("MoveDirectionY", moveDirection.y);
  72.  
  73. // Move the controller
  74. controller.Move(moveDirection * Time.deltaTime);
  75. }
  76.  
  77.  
  78.  
  79. }
  80.  
  81. function death(type:int){
  82.  
  83. Time.timeScale = 0.5;
  84. isDead = true;
  85. isStopped = true;
  86.  
  87.  
  88. switch (type){
  89. case 0:
  90. case 1:
  91. Debug.Log("outch");
  92. //Instantiate(explosion, transform.position,transform.rotation);//GetComponent.<Rigidbody>().AddExplosionForce(explosionForce, transform.position, explosionRadius, 3.0);
  93. //rigidbody.AddExplosionForce(explosionForce, Vector3(0,0,0), explosionRadius);
  94. //characAnimation.GetComponent(Animator).SetBool("DeathHitWall", true);
  95. //moveDirection.y = 0;
  96. //moveDirection.x = 0;
  97. //moveDirection.z = 0;
  98. break;
  99. case 2:
  100. //GetComponent.<Rigidbody>().AddExplosionForce(explosionForce, Vector3(0,0,0), explosionRadius);
  101. //characAnimation.GetComponent(Animator).SetBool("DeathTrip", true);
  102. //controller.Move(Vector3(0,0.5,0));
  103. //moveDirection.y = 1;
  104. break;
  105. }
  106.  
  107. Invoke("endDeath",1);
  108.  
  109. //scriptdistance.Death();
  110.  
  111.  
  112. }
  113.  
  114.  
  115. function endDeath(){
  116. Time.timeScale = 1;
  117.  
  118. var oldMaxCoins = PlayerPrefs.GetInt("MaxCoins");
  119. var newMaxCoins = GetComponent (GetCollectibles).getCoins();
  120. if (newMaxCoins > oldMaxCoins){
  121. PlayerPrefs.SetInt("MaxCoins",newMaxCoins);
  122. PlayerPrefs.Save();
  123.  
  124. Application.LoadLevel(Application.loadedLevel);
  125.  
  126. }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement