Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Behavior:
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class BusinessTemplate : MonoBehaviour {
- //ID
- public int i;
- public DatabaseBusiness imp;
- //General
- float t = 0f;
- int level = 1;
- int totalb = 0;
- int invested = 0;
- float y;
- int yint;
- public float eff = 1;
- //Bool?!
- bool auto = false;
- //UI
- public GameObject ui;
- bool s = false;
- //public GameObject stat
- public Status stat;
- public WorldStuff a;
- public Text yield;
- public Text invtxt;
- public Text tb;
- public Text efftxt;
- // Use this for initialization
- void Start()
- {
- ui.SetActive(s);
- }
- // Update is called once per frame
- void Update()
- {
- //Levels
- switch (level)
- {
- case 2:
- imp.T[i].m += 2;
- imp.T[i].cost += 3;
- imp.T[i].tm -= 4;
- stat.storage += 100;
- break;
- case 3:
- imp.T[i].m += 2;
- imp.T[i].cost += 3;
- imp.T[i].tm -= 4;
- stat.storage += 300;
- break;
- /*default:
- imp.T[i].m = 2;
- imp.T[i].cost = 3;
- imp.T[i].tm = 12;
- stat.storage += 30;
- break;*/
- }
- //Time
- t = (t + Time.deltaTime) * (0.25f / a.m);
- imp.T[i].tm = imp.T[i].tm / eff;
- if ((imp.T[i].GI >= imp.T[i].m) && (t >= imp.T[i].tm) && !(imp.T[i].Product / stat.storage == 1))
- {
- imp.T[i].Product = imp.T[i].Product + (imp.T[i].m / 2);
- totalb++;
- imp.T[i].GI = imp.T[i].GI - imp.T[i].m;
- t = 0;
- }
- //Stats
- y = ((a.m * 60) / imp.T[i].tm);
- yield.text = imp.T[i].ProdName + "per hour " + y.ToString("F1");
- invtxt.text = "Total invested " + invested.ToString();
- tb.text = "Total " + imp.T[i].ProdName + " produced " + totalb.ToString();
- efftxt.text = "Efficency " + (eff * 100).ToString() + "%";
- //Automation
- if ((auto) && (imp.T[i].GI < 2))
- {
- Invest();
- }
- }
- public void Upgrade()
- {
- level++;
- }
- void OnMouseOver()
- {
- if (Input.GetMouseButtonDown(0))
- {
- // Whatever you want it to do.
- s = !s;
- ui.SetActive(s);
- }
- }
- public void Invest()
- {
- stat.money -= imp.T[i].cost;
- invested += imp.T[i].cost;
- imp.T[i].GI++;
- }
- public void automate()
- {
- auto = true;
- }
- }
- _______________________________________________________________________________________________________________________________________
- Database:
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class DatabaseBusiness : MonoBehaviour {
- public Corp[] T;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- }
- }
- [System.Serializable]
- public class Corp
- {
- public string Name;
- public int GI;
- public int Product;
- public int m;
- public float tm;
- public int Storage = 0;
- public string ProdName;
- public int cost;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement