Advertisement
Guest User

code

a guest
Apr 5th, 2020
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.58 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine.UI;
  4. using UnityEngine;
  5.  
  6. public class GameController : MonoBehaviour
  7. {
  8.  
  9.     public double money;
  10.     public double dpc;
  11.     public double health;
  12.     public double healthCap
  13.     {
  14.         get
  15.         {
  16.             return 10 * System.Math.Pow(2, stage - 1) * isBoss;
  17.         }
  18.     }
  19.     public double reward;
  20.     public int kills;
  21.     public int stage;
  22.     public int stageMax;
  23.     public int killsMax;
  24.     public int isBoss;
  25.     public int timer;
  26.     public int timerCap;
  27.  
  28.     public Text moneyText;
  29.     public Text dPCText;
  30.     public Text stageText;
  31.     public Text killsText;
  32.     public Text healthText;
  33.  
  34.     public GameObject back;
  35.     public GameObject forward;
  36.  
  37.     public Image healthBar;
  38.  
  39.     public void Start()
  40.     {
  41.        
  42.         stage = 1;
  43.         stageMax = 1;
  44.         killsMax = 10;
  45.         kills = 0;
  46.         healthCap = 10;
  47.         health = healthCap;
  48.         isBoss = 1;
  49.        
  50.        
  51.        
  52.     }
  53.  
  54.     public void Update()
  55.     {
  56.         moneyText.text = "$" + money.ToString("F2");
  57.         stageText.text = "Stage - " + stage;
  58.         killsText.text = kills + "/" + killsMax + " Kills";
  59.         healthText.text = health + "/" + healthCap + " HP";
  60.         dPCText.text = dpc + " dpc";
  61.  
  62.         healthBar.fillAmount = (float)(health / healthCap);
  63.  
  64.         if (stage > 1) back.gameObject.SetActive(true);
  65.         else
  66.             back.gameObject.SetActive(false);
  67.  
  68.         if (stage != stageMax) forward.gameObject.SetActive(true);
  69.         else
  70.             forward.gameObject.SetActive(false);
  71.  
  72.         IsBossChecker();
  73.     }
  74.     public void IsBossChecker()
  75.     {
  76.         if (stage % 5 == 0)
  77.         {
  78.             isBoss = 10;
  79.             stageText.text = "(Boss!) Stage - " + stage;
  80.         }
  81.         else
  82.             {
  83.                 isBoss = 1;
  84.             }
  85.     }
  86.  
  87.  
  88.  
  89.     public void Hit()
  90.     {
  91.         health -= dpc;
  92.         if (health <= 0)
  93.         {
  94.             money += System.Math.Ceiling(healthCap / 14);
  95.             if (stage == stageMax)
  96.             {
  97.                 kills += 1;
  98.                 if (kills >= killsMax)
  99.                 {
  100.                     kills = 0;
  101.                     stage += 1;
  102.                     stageMax += 1;
  103.  
  104.  
  105.                 }
  106.             }
  107.             IsBossChecker();
  108.             health = healthCap;
  109.  
  110.  
  111.         }
  112.     }
  113.  
  114.  
  115.     public void Back()
  116.     {
  117.         if (stage > 1) stage -= 1;
  118.     }
  119.  
  120.     public void Forward()
  121.     {
  122.         if (stage != stageMax) stage += 1;
  123.     }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement