Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class Game : MonoBehaviour
- {
- public Text moneyText;
- public Text[] CostText;
- public int money;
- public int moneyPerClick = 1;
- public int addMoney;
- public int farmS;
- public int level;
- private int clickNum;
- public int[] CostInt;
- //public int[] clikers = new int[] { moneyPerClick, };
- public bool isFirst;
- public bool isIdleFarm;
- public GameObject clickParent, clicktextPrefab;
- public GameObject[] points;
- private ClickObject[] clickTextPool = new ClickObject[10];
- void Start()
- {
- money = PlayerPrefs.GetInt("money");
- addMoney = PlayerPrefs.GetInt("addMoney");
- farmS = PlayerPrefs.GetInt("farmS");
- moneyPerClick = PlayerPrefs.GetInt("moneyPerClick");
- bool isFirst = PlayerPrefs.GetInt("isFirst") == 1 ? true : false;
- bool isIdleFarm = PlayerPrefs.GetInt("isIdleFarm") == 1 ? true : false;
- //bool IdleFarmButton = PlayerPrefs.GetInt("IdleFarmButton") == 1 ? true : false;
- for (int i = 0; i < clickTextPool.Length; i++)
- {
- clickTextPool[i] = Instantiate(clicktextPrefab, clickParent.transform).GetComponent<ClickObject>();
- }
- if (isIdleFarm == true)
- {
- StartCoroutine(IdleFarm());
- }
- //if (isFirst == false)
- //{
- //IdleFarmButton.interactable = false;
- //}
- }
- void Update()
- {
- money = PlayerPrefs.GetInt("money");
- //moneyText.text = money.ToString();
- moneyText.text = FormatNumbers.formatNumber(money);
- }
- public void ObjBuy()
- {
- if (money >= CostInt[0])
- {
- money -= CostInt[0];
- CostInt[0] += (int) Mathf.Round(CostInt[0] * 30 / 100);
- addMoney *= (int)Mathf.Round(CostInt[0] * 20 / 100);
- CostText[0].text = CostInt[0].ToString();
- PlayerPrefs.SetInt("addMoney", addMoney);
- PlayerPrefs.SetInt("money", money);
- }
- }
- public void addBuy()
- {
- if (money >= 20)
- {
- money -= 20;
- PlayerPrefs.SetInt("money", money);
- addMoney += 1;
- PlayerPrefs.SetInt("addMoney", addMoney);
- }
- }
- public void Clik()
- {
- money += moneyPerClick;
- PlayerPrefs.SetInt("money", money);
- ///clickTextPool[clickNum].StartMotion();
- clickNum = clickNum == clickTextPool.Length - 1 ? 0 : clickNum + 1;
- Debug.Log("Earth");
- }
- public void BuyIdleFarm()
- {
- if (money >= 20)
- {
- money -= 20;
- addMoney += 1;
- farmS += 1;
- PlayerPrefs.SetInt("money", money);
- PlayerPrefs.SetInt("addMoney", addMoney);
- PlayerPrefs.SetInt("farmS", farmS);
- StartCoroutine(IdleFarm());
- isIdleFarm = true;
- PlayerPrefs.SetInt("isIdleFarm", (true ? 1 : 0));
- IdleFarmButton.interactable = false;
- isFirst = false;
- PlayerPrefs.SetInt("isFirst", (false ? 1 : 0));
- //PlayerPrefs.SetInt("IdleFarmButton", (false ? 1 : 0));
- }
- }
- IEnumerator IdleFarm()
- {
- yield return new WaitForSeconds(farmS);
- money += addMoney;
- Debug.Log(money);
- PlayerPrefs.SetInt("money", money);
- //clickTextPool[clickNum].StartMotionIdle();
- //clickNum = clickNum == clickTextPool.Length - 1 ? 0 : clickNum + 1;
- StartCoroutine(IdleFarm());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment