Advertisement
CassataGames

Untitled

Feb 23rd, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.27 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class TestHow : MonoBehaviour {
  6.  
  7.     public int Hundreds;
  8.     public int Fifties;
  9.     public int Twenties;
  10.     public int Tens;
  11.     public int Fives;
  12.     public int Ones;
  13.  
  14.     public int GrandTotal;
  15.     public bool TestRemove;
  16.  
  17.     public int RemovedHundreds;
  18.     public int RemovedFifties;
  19.     public int RemovedTwenties;
  20.     public int RemovedTens;
  21.     public int RemovedFives;
  22.     public int RemovedOnes;
  23.     public int TotalRemoved;
  24.    
  25.     // Update is called once per frame
  26.     void Update ()
  27.     {
  28.         if(!TestRemove)
  29.             GrandTotal = (Hundreds * 100) + (Fifties * 50) + (Twenties * 20) + (Tens * 10) + (Fives * 5) + (Ones * 1);
  30.         if(TestRemove)
  31.         {
  32.             while (GrandTotal - 100 >= 150 && Hundreds > 0)
  33.             {
  34.                 Hundreds--;
  35.                 RemovedHundreds++;
  36.                 GrandTotal = GrandTotal - 100;
  37.                 TotalRemoved = TotalRemoved + 100;
  38.             }
  39.             while (GrandTotal - 50 >= 150 && Fifties > 0)
  40.             {
  41.                 Fifties--;
  42.                 RemovedFifties++;
  43.                 GrandTotal = GrandTotal - 50;
  44.                 TotalRemoved = TotalRemoved + 50;
  45.             }
  46.             while (GrandTotal - 20 >= 150 && Twenties > 0)
  47.             {
  48.                 Twenties--;
  49.                 RemovedTwenties++;
  50.                 GrandTotal = GrandTotal - 20;
  51.                 TotalRemoved = TotalRemoved + 20;
  52.             }
  53.             while (GrandTotal - 10 >= 150 && Tens > 0)
  54.             {
  55.                 Tens--;
  56.                 RemovedTens++;
  57.                 GrandTotal = GrandTotal - 10;
  58.                 TotalRemoved = TotalRemoved + 10;
  59.             }
  60.             while (GrandTotal - 5 >= 150 && Fives > 0)
  61.             {
  62.                 Fives--;
  63.                 RemovedFives++;
  64.                 GrandTotal = GrandTotal - 5;
  65.                 TotalRemoved = TotalRemoved + 5;
  66.             }
  67.             while (GrandTotal - 1 >= 150 && Ones > 0)
  68.             {
  69.                 Ones--;
  70.                 RemovedOnes++;
  71.                 GrandTotal = GrandTotal - 1;
  72.                 TotalRemoved = TotalRemoved + 1;
  73.             }
  74.             TestRemove = false;
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement