// Start is called before the first frame update public void OnPlate(VegitableType veg) { if (isEmpty) { currVegType = veg; plateText.text = veg.ToString(); isEmpty = false; } else { return; } }
public void ChopVegitable(VegitableType vegType, PlayerController curPlayer) { if (isChopping || (int)vegType == 0) { return; } currentPlayer = curPlayer; currentPlayer.isPlayerIdle = true; currVegie = vegType; isChopping = true; choppingBoardText.text = choppingBoardText.text + " " + vegType.ToString(); progressbarBase.enabled = true; progressbar.enabled = true; StartCoroutine(WaitForChoppingComplete(choppingTime)); }
void OnTriggerEnter2D(Collider2D col) { //Collect Vegitables if (col.gameObject.GetComponent <Vegitable>()) { Vegitable _vegitable = col.gameObject.GetComponent <Vegitable>(); if (collectedVegies.Count >= 2) { return; } foreach (VegitableType veg in collectedVegies) { if (veg == _vegitable.vegitableType) { return; } } collectedVegies.Add(_vegitable.vegitableType); ShowCollectedVegText(); } if (col.gameObject.GetComponent <ChoppingBoard>()) { ChoppingBoard _choppingBoard = col.gameObject.GetComponent <ChoppingBoard>(); if (collectedVegies.Count > 0) { //Chop Vegitables _choppingBoard.ChopVegitable(collectedVegies[0], this); collectedVegies.RemoveAt(0); transform.position += new Vector3(0, 1, 0); ShowCollectedVegText(); } else { //collect Chopped Vegitables choppedVegitables.Clear(); choppedVegitables = new List <VegitableType>(_choppingBoard.CollectChoppedVegitables()); _choppingBoard.choppedVegitables.Clear(); vegCollectedText.text = ""; for (int i = 0; i < choppedVegitables.Count; i++) { vegCollectedText.text = vegCollectedText.text + " " + choppedVegitables[i].ToString(); } vegCollectedText.color = Color.red; } } //Plate store one veg item if its empty else collect item from plate if (col.gameObject.GetComponent <Plate>()) { VegitableType plateVeg = col.gameObject.GetComponent <Plate>().CollectFromPlate(); if (plateVeg == 0 && collectedVegies.Count > 0) { col.gameObject.GetComponent <Plate>().OnPlate(collectedVegies[0]); collectedVegies.RemoveAt(0); } else if (plateVeg != 0) { foreach (VegitableType veg in collectedVegies) { if (veg == plateVeg) { return; } } collectedVegies.Add(plateVeg); } ShowCollectedVegText(); } //Trash if (col.gameObject.layer == 8) { if (collectedVegies.Count > 0) { collectedVegies.RemoveAt(0); } else { if (choppedVegitables.Count > 0) { choppedVegitables.RemoveAt(0); } } ShowCollectedVegText(); } //Serve Salad to Customer if (col.gameObject.GetComponent <Customer>()) { Customer _customer = col.gameObject.GetComponent <Customer>(); if (choppedVegitables.Count == _customer.saladRecipe.Count) { for (int i = 0; i < choppedVegitables.Count; i++) { if (choppedVegitables[i] != _customer.saladRecipe[i]) { goto failed; } } _customer.CustomerServedSuccessfully(); AddScore(_customer.scoreValue); if (_customer.progressBar.fillAmount < .7f) { isReadyForPickup = true; GamePlayManager.Instance.InitiatePickup(); } choppedVegitables.Clear(); ShowCollectedVegText(); return; } else { goto failed; } failed: _customer.DecreaseWaitingTimeFaster(); AddScore(-5); choppedVegitables.Clear(); ShowCollectedVegText(); } if (col.gameObject.GetComponent <Pickups>() && isReadyForPickup) { Pickups pickups = col.gameObject.GetComponent <Pickups>(); OnPickupCollect(pickups.pickupType); pickups.HidePickup(); } }