Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.SceneManagement;
  6.  
  7. public class main : MonoBehaviour {
  8.  
  9. //GameObjects
  10. public GameObject moneyobj;
  11.  
  12. //Texts
  13. private Text mtext; //MoneyText
  14. public Text daytxt; //Day Text
  15. public Text jobtxt; //Job Text
  16. public Text restxt; //Resumo Text
  17.  
  18. //Keys = Armazena float ou int
  19. string mk = "MoneyKey";
  20. string mlvl = "LevelKey";
  21. string mday = "DayKey";
  22.  
  23. //Floats
  24. public static float money;
  25. public static int joblvl;
  26. public static int day;
  27.  
  28. //Toggles
  29. public Toggle jobenable; //Checkbox do trab
  30. public Toggle roleenable; //Checkbox do role
  31.  
  32. void Start () {
  33.  
  34. mtext = moneyobj.GetComponent<Text>(); //Pegar script txt do obj
  35.  
  36. money = 5f;
  37.  
  38. joblvl = 1;
  39.  
  40. day = 001;
  41.  
  42. }
  43.  
  44. void Update () {
  45.  
  46. //Set Texts every tick
  47. SetMoneyText();
  48. SetDayText();
  49. SetJobText();
  50.  
  51. //Chechar os Toggles e bloquear ativação simultanea
  52. if (jobenable.isOn)
  53. {
  54. roleenable.isOn = false;
  55. }
  56.  
  57. if (roleenable.isOn)
  58. {
  59. jobenable.isOn = false;
  60. }
  61.  
  62. if (money <=0)
  63. {
  64. SceneManager.LoadScene("wip");
  65. }
  66.  
  67. }
  68.  
  69.  
  70. //Save e Load
  71. public void SaveGame()
  72. {
  73. PlayerPrefs.SetFloat(mk, money); //Salvar Float
  74. PlayerPrefs.SetInt(mlvl, joblvl); //Salvar Int
  75. PlayerPrefs.SetInt(mday, day);
  76. }
  77.  
  78. public void LoadGame()
  79. {
  80. money = PlayerPrefs.GetFloat(mk); //Carregar Float
  81. joblvl = PlayerPrefs.GetInt(mlvl); //Carregar Int
  82. day = PlayerPrefs.GetInt(mday);
  83. }
  84.  
  85.  
  86. //Set Texts
  87. void SetMoneyText()
  88. {
  89. mtext.text = "$ " + money.ToString();
  90. }
  91.  
  92. void SetDayText()
  93. {
  94. daytxt.text = "DIA " + day.ToString();
  95. }
  96.  
  97. void SetJobText()
  98. {
  99. if (joblvl == 1)
  100. {
  101. jobtxt.text = "Fogueteiro";
  102. }
  103.  
  104. else if (joblvl == 2)
  105. {
  106. jobtxt.text = "Aviaozinho";
  107. }
  108.  
  109. else if (joblvl == 3)
  110. {
  111. jobtxt.text = "Vapor";
  112. }
  113.  
  114. else if (joblvl == 4)
  115. {
  116. jobtxt.text = "Soldado";
  117. }
  118.  
  119. else if (joblvl == 5)
  120. {
  121. jobtxt.text = "Gerente da boca";
  122. }
  123.  
  124. if (joblvl == 6)
  125. {
  126. jobtxt.text = "Dono do Morro";
  127. }
  128. }
  129.  
  130. //Mechanics
  131. public void Trabalhar()
  132. {
  133.  
  134. float salary; //Quanto vai receber no total
  135.  
  136. salary = joblvl * Random.Range(49, 501); //Calculo
  137.  
  138. money += salary; //Definir dinheiro money = money + finalmoney
  139.  
  140. //Definir resumo de acordo com o salario
  141. if (salary <= 100)
  142. {
  143. restxt.text = "Roubou um pobre" + "\n+$" + salary.ToString();
  144. }
  145. else if (salary <= 300)
  146. {
  147. restxt.text = "Assaltou uma velhota!" + "\n+$" + salary.ToString();
  148. }
  149. else if (salary <=600)
  150. {
  151. restxt.text = "Roubou um celular" + "\n+$" + salary.ToString();
  152. }
  153. }
  154.  
  155. public void Rolezin()
  156. {
  157. float gasto;
  158.  
  159. gasto = joblvl * Random.Range(1, 501); //calculo despesa
  160.  
  161. money -= gasto; //Dinheiro final
  162.  
  163. //Definir resumo de acordo com o gasto
  164. if (gasto <= 50)
  165. {
  166. restxt.text = "Barzinho" + "\n-$" + gasto.ToString();
  167. }
  168. else if (gasto <= 80)
  169. {
  170. restxt.text = "Foi num puteiro" + "\n-$" + gasto.ToString();
  171. }
  172. else if (gasto <= 200)
  173. {
  174. restxt.text = "Baseado + larica" + "\n-$" + gasto.ToString();
  175. }
  176. else if (gasto <= 400)
  177. {
  178. restxt.text = "Bailao" + "\n-$" + gasto.ToString();
  179. }
  180. else if (gasto <= 600)
  181. {
  182. restxt.text = "Bailao e ficou doidao" + "\n-$" + gasto.ToString();
  183. }
  184.  
  185. }
  186.  
  187. public void NextDay()
  188. {
  189. day += 1;
  190.  
  191. if (jobenable.isOn)
  192. {
  193. Trabalhar();
  194. }
  195.  
  196. if (roleenable.isOn)
  197. {
  198. Rolezin();
  199. }
  200. }
  201. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement