Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. using UnityEngine.SceneManagement;
  5.  
  6. public class PlayerControllerNew : MonoBehaviour {
  7.  
  8. public int restartLevel;
  9. public int changeSpeed;
  10.  
  11. public float speed;
  12.  
  13. private bool paused;
  14. private bool newHighscorebool;
  15.  
  16. private Rigidbody rb;
  17.  
  18. public Text ScoreText;
  19. public Text ScoreNum;
  20.  
  21. private float Timer = 0f;
  22. private float Score;
  23.  
  24. public AudioSource newHighscoreWin;
  25.  
  26. void Start()
  27. {
  28. rb = GetComponent<Rigidbody> ();
  29. Cursor.visible = (false);
  30.  
  31. TimerText.text = "Timer: ";
  32. ScoreText.text = "Score: ";
  33.  
  34. DeathCanvas.enabled = false;
  35.  
  36. newHighscorebool = false;
  37. }
  38.  
  39. void Update ()
  40. {
  41. //gets the value of transform.position.z of the ball and divides it by 2 to give the score a value
  42. Score = (int)transform.position.z / 2;
  43.  
  44. Timer = Timer + Time.deltaTime;
  45.  
  46. if (Score > PlayerPrefs.GetFloat ("Highscore")) {
  47. newHighscorebool = true;
  48. }
  49. }
  50.  
  51. void FixedUpdate ()
  52. {
  53. //player movement code
  54. float moveHorizontal = Input.GetAxis ("Horizontal");
  55.  
  56. float moveVertical = Input.GetAxis ("Vertical");
  57.  
  58. Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
  59.  
  60. rb.AddForce (movement * speed);
  61.  
  62. if (newHighscorebool == true) {
  63. newHighscoreWin.Play();
  64. Debug.Log ("newhs");
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement