Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. public float Health;
  2. public ParticleSystem Shootgun;
  3. public Action<float, float> ChangeHealth;
  4. public int Money;
  5. public List<Weapon> Weapons;
  6.  
  7. private float _currentHealth;
  8. private Animator _animator;
  9.  
  10. void Start()
  11. {
  12. _currentHealth = Health;
  13. _animator = GetComponent<Animator>();
  14. }
  15.  
  16. void Update()
  17. {
  18. if(Input.GetMouseButtonDown(0))
  19. {
  20. Shootgun.Play();
  21. _animator.Play("Shoot");
  22. }
  23. }
  24.  
  25. public void Attack(int damage)
  26. {
  27. _currentHealth = Mathf.Clamp(_currentHealth - damage, 0, Health);
  28. ChangeHealth?.Invoke(_currentHealth, Health);
  29. if(_currentHealth == 0)
  30. {
  31. Destroy(gameObject);
  32. }
  33. }
  34.  
  35. public void GetReward(int reward)
  36. {
  37. Money += reward;
  38. }
  39.  
  40. public void GetWeapon(Weapon weapon)
  41. {
  42. Weapons.Add(weapon);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement