BUY FOOD

using System.Collections; using System.Collections.Generic; using UnityEngine; public class BuyFood : MonoBehaviour { public int myMoney ; public int food ; public int drink ; public int fruit; int numberfood =0; int numberdrink =0; int numberfruit =0; bool gameOver = false; void Start () { } void Update () { if(gameOver == true) { } else { if(Buyfood ()) { myMoney = myMoney - food; print("BUY FOOD for "+food+" Bath" ); print("remaining money "+myMoney); numberfood = numberfood+1; if(BuyDrink ()) { myMoney = myMoney - drink; print("BUY DRINK for "+drink+" Bath" ); print("remaining money "+myMoney); numberdrink = numberdrink+1; if(BuyFruit ()) { myMoney = myMoney - fruit; print("BUY FRUIT for "+fruit+" Bath" ); print("remaining money "+myMoney); numberfruit = numberfruit+1; } } } if(BuyDrink ()) { myMoney = myMoney - drink; print("BUY DRINK for "+drink+" Bath" ); print("remaining money "+myMoney); numberdrink = numberdrink+1; if(BuyFruit ()) { myMoney = myMoney - fruit; print("BUY FRUIT for "+fruit+" Bath" ); print("remaining money "+myMoney); numberfruit = numberfruit+1; } } if(BuyFruit ()) { myMoney = myMoney - fruit; print("BUY FRUIT for "+fruit+" Bath" ); print("remaining money "+myMoney); numberfruit = numberfruit+1; } if(myMoney<=fruit) { gameOver = true; print("We dont have money anymore" ); print("remaining money "+myMoney); print("AND we have buy FOOD "+numberfood+" Time And Drink "+numberdrink+" Time and Fruit "+numberfruit+" Time"); } } } bool Buyfood () { return myMoney >= food ; } bool BuyDrink() { return myMoney >= drink ; } bool BuyFruit() { return myMoney >= fruit; } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.