Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. Behavior:
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6.  
  7. public class BusinessTemplate : MonoBehaviour {
  8. //ID
  9. public int i;
  10. public DatabaseBusiness imp;
  11. //General
  12. float t = 0f;
  13. int level = 1;
  14. int totalb = 0;
  15. int invested = 0;
  16. float y;
  17. int yint;
  18. public float eff = 1;
  19. //Bool?!
  20. bool auto = false;
  21. //UI
  22. public GameObject ui;
  23. bool s = false;
  24. //public GameObject stat
  25. public Status stat;
  26. public WorldStuff a;
  27. public Text yield;
  28. public Text invtxt;
  29. public Text tb;
  30. public Text efftxt;
  31.  
  32. // Use this for initialization
  33. void Start()
  34. {
  35. ui.SetActive(s);
  36. }
  37.  
  38. // Update is called once per frame
  39. void Update()
  40. {
  41. //Levels
  42. switch (level)
  43. {
  44. case 2:
  45. imp.T[i].m += 2;
  46. imp.T[i].cost += 3;
  47. imp.T[i].tm -= 4;
  48. stat.storage += 100;
  49. break;
  50. case 3:
  51. imp.T[i].m += 2;
  52. imp.T[i].cost += 3;
  53. imp.T[i].tm -= 4;
  54. stat.storage += 300;
  55. break;
  56. /*default:
  57. imp.T[i].m = 2;
  58. imp.T[i].cost = 3;
  59. imp.T[i].tm = 12;
  60. stat.storage += 30;
  61. break;*/
  62. }
  63. //Time
  64. t = (t + Time.deltaTime) * (0.25f / a.m);
  65. imp.T[i].tm = imp.T[i].tm / eff;
  66. if ((imp.T[i].GI >= imp.T[i].m) && (t >= imp.T[i].tm) && !(imp.T[i].Product / stat.storage == 1))
  67. {
  68. imp.T[i].Product = imp.T[i].Product + (imp.T[i].m / 2);
  69. totalb++;
  70. imp.T[i].GI = imp.T[i].GI - imp.T[i].m;
  71. t = 0;
  72. }
  73. //Stats
  74. y = ((a.m * 60) / imp.T[i].tm);
  75. yield.text = imp.T[i].ProdName + "per hour " + y.ToString("F1");
  76. invtxt.text = "Total invested " + invested.ToString();
  77. tb.text = "Total " + imp.T[i].ProdName + " produced " + totalb.ToString();
  78. efftxt.text = "Efficency " + (eff * 100).ToString() + "%";
  79. //Automation
  80. if ((auto) && (imp.T[i].GI < 2))
  81. {
  82. Invest();
  83. }
  84. }
  85.  
  86. public void Upgrade()
  87. {
  88. level++;
  89. }
  90.  
  91. void OnMouseOver()
  92. {
  93. if (Input.GetMouseButtonDown(0))
  94. {
  95. // Whatever you want it to do.
  96. s = !s;
  97. ui.SetActive(s);
  98. }
  99. }
  100.  
  101. public void Invest()
  102. {
  103. stat.money -= imp.T[i].cost;
  104. invested += imp.T[i].cost;
  105. imp.T[i].GI++;
  106. }
  107.  
  108. public void automate()
  109. {
  110. auto = true;
  111. }
  112. }
  113. _______________________________________________________________________________________________________________________________________
  114. Database:
  115. using System.Collections;
  116. using System.Collections.Generic;
  117. using UnityEngine;
  118.  
  119. public class DatabaseBusiness : MonoBehaviour {
  120. public Corp[] T;
  121.  
  122. // Use this for initialization
  123. void Start () {
  124.  
  125. }
  126.  
  127. // Update is called once per frame
  128. void Update () {
  129.  
  130. }
  131. }
  132.  
  133. [System.Serializable]
  134. public class Corp
  135. {
  136. public string Name;
  137. public int GI;
  138. public int Product;
  139. public int m;
  140. public float tm;
  141. public int Storage = 0;
  142. public string ProdName;
  143. public int cost;
  144.  
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement