Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public float Health;
- public ParticleSystem Shootgun;
- public Action<float, float> ChangeHealth;
- public int Money;
- public List<Weapon> Weapons;
- private float _currentHealth;
- private Animator _animator;
- void Start()
- {
- _currentHealth = Health;
- _animator = GetComponent<Animator>();
- }
- void Update()
- {
- if(Input.GetMouseButtonDown(0))
- {
- Shootgun.Play();
- _animator.Play("Shoot");
- }
- }
- public void Attack(int damage)
- {
- _currentHealth = Mathf.Clamp(_currentHealth - damage, 0, Health);
- ChangeHealth?.Invoke(_currentHealth, Health);
- if(_currentHealth == 0)
- {
- Destroy(gameObject);
- }
- }
- public void GetReward(int reward)
- {
- Money += reward;
- }
- public void GetWeapon(Weapon weapon)
- {
- Weapons.Add(weapon);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement