//this is a conversion function to transfer the values in VegetablesScriptObj //into a new, instantiated SaladScriptObj SaladScriptObj NewSaladFromVeggie(VegetablesScriptObj veggie) { SaladScriptObj newSalad = ScriptableObject.CreateInstance <SaladScriptObj>(); newSalad.icon = veggie.icon; newSalad.veggieName = "Salad"; return(newSalad); }
//take the SaladScriptObj from the plate public SaladScriptObj DisplayObject() { SaladScriptObj temp = item; item = null; pic.color = Color.clear; return(temp); }
//function to "pick up" a veggie from a vegetable pile void GetNewVegetable(SaladScriptObj plateVeggie) { if (playerInfo.veggieQueue.Count < 2) { playerInfo.veggieQueue.Enqueue(plateVeggie); playerInfo.UpdateQueue(); } }
//take a veggie out from the player's queue and put it somewhere, & update the queue //Ambiguous so that it can be used in almost any situation that will be available SaladScriptObj TakeItemFromQueue() { if (playerInfo.veggieQueue.Count > 0) { SaladScriptObj tempItem = playerInfo.veggieQueue.Dequeue(); playerInfo.UpdateQueue(); return(tempItem); } return(null); }
//function that tests the customer order vs what the player has. If it's wrong, //the customwer will get mad, otherwise the salad is taken out of the queue and //the player gets 200 points void CheckCustomerOrder(SaladScriptObj playerSalad, CustomerScript customer) { SaladScriptObj custOrder = customer.order; if (playerSalad == custOrder) { TakeItemFromQueue(); playerInfo.score += 200; customer.OrderDelivered(this); } else { customer.CustomerGetsAngry(); } }
public void UpdateQueue() { for (int i = 0; i < maxHeldItems; i++) { //show the image of the veggie if there is one (or two) //Note: this enqueue-dequeue way is meant to read the veggie, //then return it back to the queue if (i < veggieQueue.Count) { SaladScriptObj tempVeg = veggieQueue.Dequeue(); veggieImages[i].color = Color.white; veggieImages[i].sprite = tempVeg.icon; veggieQueue.Enqueue(tempVeg); } //if there's no veggie, clear the image in the heldItems image else { veggieImages[i].color = Color.clear; veggieImages[i].sprite = null; } } }
//assign new SaladScriptObj to the plate public void Assign(SaladScriptObj obj) { item = obj; pic.color = Color.white; pic.sprite = obj.icon; }