Advertisement
Guest User

JobScript

a guest
Nov 19th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4.  
  5. [RequireComponent(typeof(Button))]
  6. public class Test : MonoBehaviour
  7. {
  8. [SerializeField] private int clickCount;
  9. [SerializeField] private int reloadCount;
  10.  
  11. private Button button;
  12.  
  13. private void Start()
  14. {
  15. button = GetComponent<Button>();
  16. }
  17.  
  18. public void ButtonClick()
  19. {
  20. clickCount++;
  21.  
  22. if (clickCount == 10)
  23. {
  24. clickCount = 0;
  25. reloadCount++;
  26.  
  27. if(reloadCount != 3)
  28. StartCoroutine("ButtonReload");
  29. else
  30. {
  31. button.interactable = false;
  32. button.enabled = false;
  33. }
  34. }
  35.  
  36. GameManager.balance += 50;
  37. }
  38.  
  39. private IEnumerator ButtonReload()
  40. {
  41. button.interactable = false;
  42. yield return new WaitForSeconds(2f);
  43. button.interactable = true;
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement