Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class DollarPerSec : MonoBehaviour {
  6.  
  7. public UnityEngine.UI.Text dpsDisplay;
  8. public Click click;
  9. public ItemManager[] items;
  10.  
  11. private void Start()
  12. {
  13. StartCoroutine(AutoTick());
  14. }
  15.  
  16. private void Update()
  17. {
  18. dpsDisplay.text = GetDollarsPerSec() + " Dollars/sec";
  19. }
  20. public int GetDollarsPerSec()
  21. {
  22. int tick = 0;
  23. foreach(ItemManager item in items)
  24. {
  25. tick += item.count2 * item.tickValue;
  26.  
  27. }
  28. return tick;
  29. }
  30. public void AutoDollarsperSec()
  31. {
  32. click.gold += GetDollarsPerSec();
  33. }
  34. IEnumerator AutoTick()
  35. {
  36. while(true)
  37. {
  38. AutoDollarsperSec();
  39. yield return new WaitForSeconds(1);
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement