Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.41 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class Brewery_Behavior : MonoBehaviour {
  7.     public int GI = 0;
  8.     public int beer = 0;
  9.     float t = 0f;
  10.     int m = 2;
  11.     float tm = 15;
  12.     int level = 1;
  13.     int totalb = 0;
  14.     int invested = 0;
  15.     int cost;
  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.         ui.SetActive(s);
  35.     }
  36.    
  37.     // Update is called once per frame
  38.     void Update () {
  39.         //Levels
  40.         switch (level)
  41.         {
  42.             case 2:
  43.                 m = 4;
  44.                 cost = 8;
  45.                 tm = 8;
  46.                 stat.storage += 100;
  47.                 break;
  48.             case 3:
  49.                 m = 6;
  50.                 cost = 5;
  51.                 tm = 4;
  52.                 stat.storage += 300;
  53.                 break;
  54.             default:
  55.                 m = 2;
  56.                 cost = 3;
  57.                 tm = 12;
  58.                 stat.storage += 30;
  59.                 break;
  60.         }
  61.         //time
  62.         t = (t + Time.deltaTime)*(0.25f/a.m);
  63.         tm = tm / eff;
  64.         if ((GI >= m)&&(t>=tm)&&!(beer/stat.storage == 1)) {
  65.             beer = beer + (m/2);
  66.             totalb++;
  67.             GI = GI - m;
  68.             t = 0;
  69.         }
  70.         //Stats
  71.         y = ((a.m * 60) / tm);
  72.         yield.text = "Beer per hour " + y.ToString("F1");
  73.         invtxt.text = "Total invested " + invested.ToString();
  74.         tb.text = "Total beer produced " + totalb.ToString();
  75.         efftxt.text = "Efficency " + (eff * 100).ToString() + "%";
  76.         //Automation
  77.         if ((auto)&&(GI < 2))
  78.         {
  79.             Invest();
  80.         }
  81.     }
  82.  
  83.     public void Upgrade ()
  84.     {
  85.         level++;
  86.     }
  87.  
  88.     void OnMouseOver()
  89.     {
  90.         if (Input.GetMouseButtonDown(0))
  91.         {
  92.             // Whatever you want it to do.
  93.             ui.SetActive(s);
  94.             s = !s;
  95.         }
  96.     }
  97.  
  98.     public void Invest ()
  99.     {
  100.         stat.money -= cost;
  101.         invested += cost;
  102.         GI++;
  103.     }
  104.  
  105.     public void automate ()
  106.     {
  107.         auto = true;
  108.     }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement