public void AddDirtyPlate(Plate plate) { // put the clean plate into the top of the cleanPile (physically) var topPileSlot = _dirtyPlates.Count == 0 ? Slot : _dirtyPlates.Last().Slot; // plates are parented to the Slot of the previous one plate.transform.SetParent(topPileSlot); plate.transform.SetPositionAndRotation(topPileSlot.transform.position, Quaternion.identity); _dirtyPlates.Add(plate); }
public override bool TryToDropIntoSlot(IPickable pickableToDrop) { if (CurrentPickable == null) { return(TryDropIfNotOccupied(pickableToDrop)); } return(CurrentPickable switch { CookingPot cookingPot => cookingPot.TryToDropIntoSlot(pickableToDrop), Ingredient ingredient => ingredient.TryToDropIntoSlot(pickableToDrop), Plate plate => plate.TryToDropIntoSlot(pickableToDrop), _ => false });
/// <summary> /// The first two dirty plate slots are visible, all subsequent are placed out of player's sight /// </summary> private void AddPileDirtyPlatesRecursively(Plate plate) { Plate nextPlate = plate.Slot.GetComponentInChildren <Plate>(); if (nextPlate != null) { nextPlate.transform.SetParent(null); AddPileDirtyPlatesRecursively(nextPlate); } _dirtyPlates.Push(plate); int dirtySize = _dirtyPlates.Count; Transform dirtySlot = dirtySize <= 2 ? dirtySlots[dirtySize - 1] : dirtySlots[2]; plate.transform.SetParent(dirtySlot); plate.transform.SetPositionAndRotation(dirtySlot.transform.position, dirtySlot.transform.rotation); }
private bool TryAddIngredients(List <Ingredient> ingredients) { if (!IsEmpty()) { return(false); } if (Plate.CheckSoupIngredients(ingredients) == false) { return(false); } Ingredients.AddRange(ingredients); foreach (var ingredient in Ingredients) { ingredient.transform.SetParent(Slot); ingredient.transform.SetPositionAndRotation(Slot.transform.position, Quaternion.identity); } SetLiquidLevelAndColor(); IsCookFinished = true; UpdateIngredientsUI(); return(true); }
public override bool TryToDropIntoSlot(IPickable pickableToDrop) { switch (pickableToDrop) { case Ingredient ingredient: if (ingredient.Status != IngredientStatus.Processed) { Debug.Log("[CookingPot] Only accept chopped/processed ingredients"); return(false); } if (ingredient.Type == IngredientType.Onion || ingredient.Type == IngredientType.Tomato || ingredient.Type == IngredientType.Mushroom) { return(TryDrop(pickableToDrop)); } Debug.Log("[CookingPot] Only accept Onions, tomatoes or Mushrooms"); return(false); case Plate plate: if (IsEmpty()) { if (plate.IsEmpty() == false && Plate.CheckSoupIngredients(plate.Ingredients)) { // Drop soup back into CookingPot TryAddIngredients(plate.Ingredients); plate.RemoveAllIngredients(); return(false); } } if (IsCookFinished && !IsBurned) { if (IsBurned) { return(false); } if (plate.IsClean == false) { return(false); } bool isSoup = Plate.CheckSoupIngredients(this.Ingredients); if (!isSoup) { return(false); } plate.AddIngredients(this.Ingredients); EmptyPan(); return(false); } break; default: Debug.LogWarning("[ChoppingBoard] Refuse everything else"); return(false); } return(false); }