Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. {
  2. private float HealthBarLength;
  3. public int maxHealth = 100;
  4. public int curHealth = 100;
  5. private Vector3 startPos;
  6. public GameObject player;
  7. public Animator thisAnimator;
  8. private AnimationState state;
  9. private bool dropKickIsPlaying;
  10. private Animator anim;
  11. private int damage;
  12. public GameObject Loser;
  13. public GameObject pipe, ballPrefab;
  14.  
  15. // Use this for initialization
  16. void Start()
  17. {
  18. HealthBarLength = Screen.width / 3;
  19. startPos = player.transform.position;
  20. thisAnimator = GetComponent<Animator>();
  21. anim = GetComponent<Animator>();
  22. damage = 100;
  23. }
  24.  
  25. // Update is called once per frame
  26. void Update()
  27. {
  28. AddjustCurrentHealth(0);
  29. //BackFlip();
  30.  
  31. if (Input.GetKeyDown(KeyCode.Mouse0))
  32. {
  33. Instantiate(ballPrefab, pipe.transform.position, Quaternion.identity);
  34. }
  35.  
  36. Debug.Log(("Position: " + "X: " + pipe.transform.position.x + " Y: " + pipe.transform.position.y + " Z: " + pipe.transform.position.z));
  37.  
  38. //thisAnimator.SetBool("DropKick", dropKickIsPlaying);
  39.  
  40. // thisAnimator.SetBool("DropKickIsPlaying", dropKickIsPlaying);
  41.  
  42. if (player.transform.position.y < -30)
  43. {
  44. player.transform.position = startPos;
  45. curHealth -= damage;
  46. }
  47.  
  48. /*if (Input.GetKeyDown(KeyCode.E))
  49. {
  50. thisAnimator.Play("DRokKikck");
  51.  
  52. if(thisAnimator.GetCurrentAnimatorStateInfo(0).IsName("MyGunGetAnim")
  53. {
  54. thisAnimator.Stop();
  55. }
  56. }*/
  57.  
  58. }
  59.  
  60. void OnGUI()
  61. {
  62. GUI.Box(new Rect(10, 10, HealthBarLength, 30), curHealth + "/" + maxHealth);
  63.  
  64. }
  65.  
  66. public void AddjustCurrentHealth(int adj)
  67. {
  68.  
  69. curHealth += adj;
  70.  
  71. if (curHealth < 0)
  72. curHealth = 0;
  73.  
  74. if (curHealth > maxHealth)
  75. curHealth = maxHealth;
  76.  
  77. if (maxHealth < 1)
  78. {
  79. maxHealth = 1;
  80. }
  81.  
  82. if (curHealth <= 0)
  83. {
  84. Time.timeScale = 0;
  85. Loser.active = true;
  86. }
  87.  
  88. //HealthBarLength = (Screen.width / 3) * (curHealth / (float)maxHealth);
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement