Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TestHow : MonoBehaviour {
- public int Hundreds;
- public int Fifties;
- public int Twenties;
- public int Tens;
- public int Fives;
- public int Ones;
- public int GrandTotal;
- public bool TestRemove;
- public int RemovedHundreds;
- public int RemovedFifties;
- public int RemovedTwenties;
- public int RemovedTens;
- public int RemovedFives;
- public int RemovedOnes;
- public int TotalRemoved;
- // Update is called once per frame
- void Update ()
- {
- if(!TestRemove)
- GrandTotal = (Hundreds * 100) + (Fifties * 50) + (Twenties * 20) + (Tens * 10) + (Fives * 5) + (Ones * 1);
- if(TestRemove)
- {
- while (GrandTotal - 100 >= 150 && Hundreds > 0)
- {
- Hundreds--;
- RemovedHundreds++;
- GrandTotal = GrandTotal - 100;
- TotalRemoved = TotalRemoved + 100;
- }
- while (GrandTotal - 50 >= 150 && Fifties > 0)
- {
- Fifties--;
- RemovedFifties++;
- GrandTotal = GrandTotal - 50;
- TotalRemoved = TotalRemoved + 50;
- }
- while (GrandTotal - 20 >= 150 && Twenties > 0)
- {
- Twenties--;
- RemovedTwenties++;
- GrandTotal = GrandTotal - 20;
- TotalRemoved = TotalRemoved + 20;
- }
- while (GrandTotal - 10 >= 150 && Tens > 0)
- {
- Tens--;
- RemovedTens++;
- GrandTotal = GrandTotal - 10;
- TotalRemoved = TotalRemoved + 10;
- }
- while (GrandTotal - 5 >= 150 && Fives > 0)
- {
- Fives--;
- RemovedFives++;
- GrandTotal = GrandTotal - 5;
- TotalRemoved = TotalRemoved + 5;
- }
- while (GrandTotal - 1 >= 150 && Ones > 0)
- {
- Ones--;
- RemovedOnes++;
- GrandTotal = GrandTotal - 1;
- TotalRemoved = TotalRemoved + 1;
- }
- TestRemove = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement