Advertisement
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;
- using UnityEngine.SceneManagement;
- public class main : MonoBehaviour {
- //GameObjects
- public GameObject moneyobj;
- //Texts
- private Text mtext; //MoneyText
- public Text daytxt; //Day Text
- public Text jobtxt; //Job Text
- public Text restxt; //Resumo Text
- //Keys = Armazena float ou int
- string mk = "MoneyKey";
- string mlvl = "LevelKey";
- string mday = "DayKey";
- //Floats
- public static float money;
- public static int joblvl;
- public static int day;
- //Toggles
- public Toggle jobenable; //Checkbox do trab
- public Toggle roleenable; //Checkbox do role
- void Start () {
- mtext = moneyobj.GetComponent<Text>(); //Pegar script txt do obj
- money = 5f;
- joblvl = 1;
- day = 001;
- }
- void Update () {
- //Set Texts every tick
- SetMoneyText();
- SetDayText();
- SetJobText();
- //Chechar os Toggles e bloquear ativação simultanea
- if (jobenable.isOn)
- {
- roleenable.isOn = false;
- }
- if (roleenable.isOn)
- {
- jobenable.isOn = false;
- }
- if (money <=0)
- {
- SceneManager.LoadScene("wip");
- }
- }
- //Save e Load
- public void SaveGame()
- {
- PlayerPrefs.SetFloat(mk, money); //Salvar Float
- PlayerPrefs.SetInt(mlvl, joblvl); //Salvar Int
- PlayerPrefs.SetInt(mday, day);
- }
- public void LoadGame()
- {
- money = PlayerPrefs.GetFloat(mk); //Carregar Float
- joblvl = PlayerPrefs.GetInt(mlvl); //Carregar Int
- day = PlayerPrefs.GetInt(mday);
- }
- //Set Texts
- void SetMoneyText()
- {
- mtext.text = "$ " + money.ToString();
- }
- void SetDayText()
- {
- daytxt.text = "DIA " + day.ToString();
- }
- void SetJobText()
- {
- if (joblvl == 1)
- {
- jobtxt.text = "Fogueteiro";
- }
- else if (joblvl == 2)
- {
- jobtxt.text = "Aviaozinho";
- }
- else if (joblvl == 3)
- {
- jobtxt.text = "Vapor";
- }
- else if (joblvl == 4)
- {
- jobtxt.text = "Soldado";
- }
- else if (joblvl == 5)
- {
- jobtxt.text = "Gerente da boca";
- }
- if (joblvl == 6)
- {
- jobtxt.text = "Dono do Morro";
- }
- }
- //Mechanics
- public void Trabalhar()
- {
- float salary; //Quanto vai receber no total
- salary = joblvl * Random.Range(49, 501); //Calculo
- money += salary; //Definir dinheiro money = money + finalmoney
- //Definir resumo de acordo com o salario
- if (salary <= 100)
- {
- restxt.text = "Roubou um pobre" + "\n+$" + salary.ToString();
- }
- else if (salary <= 300)
- {
- restxt.text = "Assaltou uma velhota!" + "\n+$" + salary.ToString();
- }
- else if (salary <=600)
- {
- restxt.text = "Roubou um celular" + "\n+$" + salary.ToString();
- }
- }
- public void Rolezin()
- {
- float gasto;
- gasto = joblvl * Random.Range(1, 501); //calculo despesa
- money -= gasto; //Dinheiro final
- //Definir resumo de acordo com o gasto
- if (gasto <= 50)
- {
- restxt.text = "Barzinho" + "\n-$" + gasto.ToString();
- }
- else if (gasto <= 80)
- {
- restxt.text = "Foi num puteiro" + "\n-$" + gasto.ToString();
- }
- else if (gasto <= 200)
- {
- restxt.text = "Baseado + larica" + "\n-$" + gasto.ToString();
- }
- else if (gasto <= 400)
- {
- restxt.text = "Bailao" + "\n-$" + gasto.ToString();
- }
- else if (gasto <= 600)
- {
- restxt.text = "Bailao e ficou doidao" + "\n-$" + gasto.ToString();
- }
- }
- public void NextDay()
- {
- day += 1;
- if (jobenable.isOn)
- {
- Trabalhar();
- }
- if (roleenable.isOn)
- {
- Rolezin();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement