Advertisement
kadyr

Untitled

Oct 16th, 2021
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public abstract class Gun : MonoBehaviour
  6. {
  7. protected float coolDown;
  8. protected bool auto;
  9. protected float speed;
  10. protected int damage;
  11.  
  12. private float timer;
  13.  
  14. public void Shoot()
  15. {
  16. if (Input.GetMouseButtonDown(0) || auto)
  17. {
  18. if (timer > coolDown)
  19. {
  20. OnShoot();
  21. timer = 0;
  22. }
  23. }
  24. }
  25.  
  26. private void Update()
  27. {
  28. timer += Time.deltaTime;
  29. }
  30.  
  31. protected void OnShoot() { }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement