Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4.  
  5. public class Player : MonoBehaviour {
  6.  
  7.  
  8. public float jumpFor;
  9. private static int score;
  10. private Rigidbody2D rb;
  11. private BoxCollider2D bc;
  12. private Animator an;
  13. private float time;
  14. public float timeToPoints;
  15.  
  16. public static int Level = 0;
  17.  
  18. private int[] pointLeve = {
  19. 5,
  20. 10,
  21. 15,
  22. 20,
  23. 25,
  24. 30,
  25. 35,
  26. 40,
  27. 45,
  28. 50
  29. };
  30.  
  31. public static int pScore {
  32. get {return score; }
  33. set { score = value; }
  34. }
  35.  
  36. // Use this for initialization
  37. void Start () {
  38. rb = this.GetComponent<Rigidbody2D>();
  39. bc = this.GetComponent<BoxCollider2D>();
  40. an = this.GetComponent<Animator>();;
  41. score = 0;
  42. time = 0;
  43. }
  44.  
  45. // Update is called once per frame
  46. void Update () {
  47. if(Input.GetKeyDown("z")) {
  48. rb.AddForce(new Vector2(0,jumpFor),ForceMode2D.Force);
  49. an.Play("realy_jump");
  50. }
  51. if(Input.GetKey("s")) {
  52. an.Play("jump");
  53. bc.size = new Vector2(0.2537485f,0.1768517f);
  54. bc.offset = new Vector2(0.004158616f,0.0007894337f);
  55. }
  56. if(Input.GetKeyUp("s")) {
  57. an.Play("run");
  58. bc.size = new Vector2(0.1764001f,0.2035236f);
  59. bc.offset = new Vector2(-0.02117968f,0.003456682f);
  60. }
  61. time += Time.deltaTime;
  62. if(time >= timeToPoints) {
  63. int g = score;
  64. if(g >= 1000) {
  65. g = 0;
  66. if(Level < 9) {
  67. Level += 1;
  68. }else {
  69. Level = 9;
  70. }
  71. }
  72. score += pointLeve[Level];
  73. time = 0;
  74. }
  75.  
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement