Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma strict
- private var isStopped:boolean = false;
- private var isDead:boolean = false;
- var speed : float = 6.0;
- var jumpSpeed : float ;
- var gravity : float = 20.0;
- private var moveDirection : Vector3 = Vector3.zero;
- private var isJumping:boolean = false;
- var characAnimation:GameObject ;
- var scriptdistance:ScriptDistance;
- var explosion:GameObject;
- var explosionForce: float = 5;
- var explosionRadius: float = 5;
- //var upwardsModifier: float = 0;
- function Update()
- {
- if (isStopped == false){
- var controller : CharacterController = GetComponent(CharacterController);
- if (controller.isGrounded){
- if(isJumping == true){
- isJumping = false;
- characAnimation.GetComponent(Animator).SetBool("jump", isJumping);
- //characAnimation.GetComponent(Animator).Play("Jump Start");
- characAnimation.GetComponent(Animator).Play("Jump Landing");
- }
- // We are grounded, so recalculate
- //move direction directly from axes
- moveDirection = Vector3 (1,0,0);
- //moveDirection = transForceMode.TransformDirection(moveDirection);
- moveDirection *= speed;
- if (Input.GetButton ("Jump")&& isJumping == false){
- //&& isJumping == false)
- //characAnimation.GetComponent(Animator).SetTrigger ("Jump") ;
- moveDirection.y = jumpSpeed;
- isJumping = true;
- //animator.SetTrigger ("Jump") ;
- characAnimation.GetComponent(Animator).SetBool("jump", isJumping);
- Debug.Log("isJumping" +isJumping);
- }
- }
- //moveDirection.z = Input.GetAxis("Horizontal");
- //moveDirection.z *= speed;
- // Apply gravity
- moveDirection.y -= gravity * Time.deltaTime ;
- characAnimation.GetComponent(Animator).SetFloat("MoveDirectionY", moveDirection.y);
- // Move the controller
- controller.Move(moveDirection * Time.deltaTime);
- }
- }
- function death(type:int){
- Time.timeScale = 0.5;
- isDead = true;
- isStopped = true;
- switch (type){
- case 0:
- case 1:
- Debug.Log("outch");
- //Instantiate(explosion, transform.position,transform.rotation);//GetComponent.<Rigidbody>().AddExplosionForce(explosionForce, transform.position, explosionRadius, 3.0);
- //rigidbody.AddExplosionForce(explosionForce, Vector3(0,0,0), explosionRadius);
- //characAnimation.GetComponent(Animator).SetBool("DeathHitWall", true);
- //moveDirection.y = 0;
- //moveDirection.x = 0;
- //moveDirection.z = 0;
- break;
- case 2:
- //GetComponent.<Rigidbody>().AddExplosionForce(explosionForce, Vector3(0,0,0), explosionRadius);
- //characAnimation.GetComponent(Animator).SetBool("DeathTrip", true);
- //controller.Move(Vector3(0,0.5,0));
- //moveDirection.y = 1;
- break;
- }
- Invoke("endDeath",1);
- //scriptdistance.Death();
- }
- function endDeath(){
- Time.timeScale = 1;
- var oldMaxCoins = PlayerPrefs.GetInt("MaxCoins");
- var newMaxCoins = GetComponent (GetCollectibles).getCoins();
- if (newMaxCoins > oldMaxCoins){
- PlayerPrefs.SetInt("MaxCoins",newMaxCoins);
- PlayerPrefs.Save();
- Application.LoadLevel(Application.loadedLevel);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement