Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System;
- public class Player : MonoBehaviour {
- public float jumpFor;
- private static int score;
- private Rigidbody2D rb;
- private BoxCollider2D bc;
- private Animator an;
- private float time;
- public float timeToPoints;
- public static int Level = 0;
- private int[] pointLeve = {
- 5,
- 10,
- 15,
- 20,
- 25,
- 30,
- 35,
- 40,
- 45,
- 50
- };
- public static int pScore {
- get {return score; }
- set { score = value; }
- }
- // Use this for initialization
- void Start () {
- rb = this.GetComponent<Rigidbody2D>();
- bc = this.GetComponent<BoxCollider2D>();
- an = this.GetComponent<Animator>();;
- score = 0;
- time = 0;
- }
- // Update is called once per frame
- void Update () {
- if(Input.GetKeyDown("z")) {
- rb.AddForce(new Vector2(0,jumpFor),ForceMode2D.Force);
- an.Play("realy_jump");
- }
- if(Input.GetKey("s")) {
- an.Play("jump");
- bc.size = new Vector2(0.2537485f,0.1768517f);
- bc.offset = new Vector2(0.004158616f,0.0007894337f);
- }
- if(Input.GetKeyUp("s")) {
- an.Play("run");
- bc.size = new Vector2(0.1764001f,0.2035236f);
- bc.offset = new Vector2(-0.02117968f,0.003456682f);
- }
- time += Time.deltaTime;
- if(time >= timeToPoints) {
- int g = score;
- if(g >= 1000) {
- g = 0;
- if(Level < 9) {
- Level += 1;
- }else {
- Level = 9;
- }
- }
- score += pointLeve[Level];
- time = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement