Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- private float HealthBarLength;
- public int maxHealth = 100;
- public int curHealth = 100;
- private Vector3 startPos;
- public GameObject player;
- public Animator thisAnimator;
- private AnimationState state;
- private bool dropKickIsPlaying;
- private Animator anim;
- private int damage;
- public GameObject Loser;
- public GameObject pipe, ballPrefab;
- // Use this for initialization
- void Start()
- {
- HealthBarLength = Screen.width / 3;
- startPos = player.transform.position;
- thisAnimator = GetComponent<Animator>();
- anim = GetComponent<Animator>();
- damage = 100;
- }
- // Update is called once per frame
- void Update()
- {
- AddjustCurrentHealth(0);
- //BackFlip();
- if (Input.GetKeyDown(KeyCode.Mouse0))
- {
- Instantiate(ballPrefab, pipe.transform.position, Quaternion.identity);
- }
- Debug.Log(("Position: " + "X: " + pipe.transform.position.x + " Y: " + pipe.transform.position.y + " Z: " + pipe.transform.position.z));
- //thisAnimator.SetBool("DropKick", dropKickIsPlaying);
- // thisAnimator.SetBool("DropKickIsPlaying", dropKickIsPlaying);
- if (player.transform.position.y < -30)
- {
- player.transform.position = startPos;
- curHealth -= damage;
- }
- /*if (Input.GetKeyDown(KeyCode.E))
- {
- thisAnimator.Play("DRokKikck");
- if(thisAnimator.GetCurrentAnimatorStateInfo(0).IsName("MyGunGetAnim")
- {
- thisAnimator.Stop();
- }
- }*/
- }
- void OnGUI()
- {
- GUI.Box(new Rect(10, 10, HealthBarLength, 30), curHealth + "/" + maxHealth);
- }
- public void AddjustCurrentHealth(int adj)
- {
- curHealth += adj;
- if (curHealth < 0)
- curHealth = 0;
- if (curHealth > maxHealth)
- curHealth = maxHealth;
- if (maxHealth < 1)
- {
- maxHealth = 1;
- }
- if (curHealth <= 0)
- {
- Time.timeScale = 0;
- Loser.active = true;
- }
- //HealthBarLength = (Screen.width / 3) * (curHealth / (float)maxHealth);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement