Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Spine.Unity;
  5. using Spine;
  6. using UnityEngine.UI;
  7.  
  8. public class Police : MonoBehaviour
  9. {
  10. public float startHealth =100;
  11.  
  12. private float health;
  13.  
  14. [SpineAnimation]
  15. public string stand;
  16.  
  17. [SpineAnimation]
  18. public string attack;
  19.  
  20. [SpineAnimation]
  21. public string die;
  22.  
  23. public SkeletonAnimation SkelAnim;
  24.  
  25.  
  26. public Image HealthBar;
  27.  
  28.  
  29. void Start()
  30. {
  31.  
  32. health = startHealth;
  33.  
  34.  
  35. SkelAnim = GetComponent<SkeletonAnimation>();
  36.  
  37. SkelAnim.state.SetAnimation(0,stand,true);
  38.  
  39.  
  40. }
  41.  
  42. public void TakeDamge (float amount)
  43.  
  44. {
  45.  
  46. health -= amount;
  47.  
  48. HealthBar.fillAmount = health/startHealth;
  49.  
  50. if (health <=0)
  51. {
  52.  
  53. Destroy(gameObject);
  54. }
  55.  
  56. }
  57.  
  58. void update(){}
  59.  
  60.  
  61. void OnTriggerEnter2D (Collider2D collider)
  62.  
  63. {
  64. Debug.Log("im hit");
  65.  
  66. health -=1f;
  67.  
  68. SkelAnim.state.SetAnimation(0,attack,true);
  69.  
  70.  
  71.  
  72.  
  73. }
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement