Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class DollarPerSec : MonoBehaviour {
- public UnityEngine.UI.Text dpsDisplay;
- public Click click;
- public ItemManager[] items;
- private void Start()
- {
- StartCoroutine(AutoTick());
- }
- private void Update()
- {
- dpsDisplay.text = GetDollarsPerSec() + " Dollars/sec";
- }
- public int GetDollarsPerSec()
- {
- int tick = 0;
- foreach(ItemManager item in items)
- {
- tick += item.count2 * item.tickValue;
- }
- return tick;
- }
- public void AutoDollarsperSec()
- {
- click.gold += GetDollarsPerSec();
- }
- IEnumerator AutoTick()
- {
- while(true)
- {
- AutoDollarsperSec();
- yield return new WaitForSeconds(1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement