public void HandlePot() { if (resultPanel.transform.childCount == 1 & potState == PotState.cooking) { potState = PotState.finish; } if (resultPanel.transform.childCount == 0 & potState == PotState.finish) { potState = PotState.idle; anim.SetTrigger("Close"); } foreach (CrafterSlot s in slots) { if (!s.itemObj) { cookButton.interactable = false; } else { cookButton.interactable = true; } } }
public void StartCooking() { CurrentPotState = PotState.cooking; cookingItem.SetActive(true); cookedItem.SetActive(false); overcookedItem.SetActive(false); }
public void SetState(PotState state) { this.state = state; UpdateBtnText(); UpdateBtn(); potIcon.SetState(state, IsEmpty); }
// Use this for initialization void Start() { CurrentPotState = PotState.empty; ProcessSlider.gameObject.SetActive(false); Tip.gameObject.SetActive(false); cookingItem.SetActive(false); cookedItem.SetActive(false); overcookedItem.SetActive(false); }
public Rule(PotState middle, PotState left1, PotState left2, PotState right1, PotState right2, PotState nextGen) { this.Middle = middle; this.Left1 = left1; this.Left2 = left2; this.Right1 = right1; this.Right2 = right2; this.NextGen = nextGen; }
public void Reset() { ProcessSlider.value = 0; timer = 0; Tip.color = Color.yellow; CurrentPotState = PotState.empty; cookingItem.SetActive(false); cookedItem.SetActive(false); overcookedItem.SetActive(false); }
public Pot() { this.State = PotState.Empty; this.Number = 0; this.LeftNeighbor = null; this.RightNeighbor = null; this.NextGenState = PotState.Empty; }
// Update is called once per frame void Update() { if (CurrentPotState == PotState.empty) { cookingItem.SetActive(false); cookedItem.SetActive(false); overcookedItem.SetActive(false); ProcessSlider.gameObject.SetActive(false); Tip.gameObject.SetActive(false); } if (CurrentPotState == PotState.cooking) { cookingItem.SetActive(true); cookedItem.SetActive(false); overcookedItem.SetActive(false); ProcessSlider.gameObject.SetActive(true); Tip.gameObject.SetActive(true); timer += Time.deltaTime; ProcessSlider.value = Mathf.Clamp(timer / CookTime, 0, 1.01f); Tip.text = "Cooking..."; if (timer >= CookTime) { CurrentPotState = PotState.goodCook; timer = 0; } } if (CurrentPotState == PotState.goodCook) { cookingItem.SetActive(false); cookedItem.SetActive(true); overcookedItem.SetActive(false); Tip.text = "IT IS COOKED~~"; timer += Time.deltaTime; if (timer >= OverCookTime) { CurrentPotState = PotState.badCook; timer = 0; } } if (CurrentPotState == PotState.badCook) { cookingItem.SetActive(false); cookedItem.SetActive(false); overcookedItem.SetActive(true); Tip.text = "OverCooked..."; Tip.color = Color.grey; ProcessSlider.gameObject.SetActive(false); } }
public void Cook(float time) { if (potState == PotState.open) { foreach (CrafterSlot cs in slots) { cs.RemoveItem(cs.slot); } potState = PotState.cooking; anim.SetTrigger("Cook"); StartCoroutine(Harvest(1.0f)); } }
public override AIState ApplyAction(AIState currentState) { AIState cloneState = base.ApplyAction(currentState); int heldItemID = cloneState.CurrentPlayerState.HoldingItemID; MealState meal1; if (cloneState.ItemStateList[heldItemID].MyItemType == ItemType.POT) { PotState pot = (cloneState.ItemStateList[heldItemID] as PotState); meal1 = (cloneState.ItemStateList[pot.mealID] as MealState); } else { PlateState plate = (cloneState.ItemStateList[heldItemID] as PlateState); meal1 = (cloneState.ItemStateList[plate.mealID] as MealState); } //Transferring/combining it with the other meal if (cloneState.ItemStateList[id].MyItemType == ItemType.POT) { PotState pot = cloneState.ItemStateList[id] as PotState; MealState meal2 = cloneState.ItemStateList[pot.mealID] as MealState; int cookDuration = CombineCookDurations(meal1, meal2); meal2.cookDuration = cookDuration; meal2.ContainedIngredientIDs.AddRange(meal1.ContainedIngredientIDs); meal1.ContainedIngredientIDs.RemoveAll(x => true); meal1.cookDuration = 0; } else { PlateState plate = cloneState.ItemStateList[id] as PlateState; MealState meal2 = cloneState.ItemStateList[plate.mealID] as MealState; int cookDuration = CombineCookDurations(meal1, meal2); meal2.cookDuration = cookDuration; meal2.ContainedIngredientIDs.AddRange(meal1.ContainedIngredientIDs); meal1.ContainedIngredientIDs.RemoveAll(x => true); meal1.cookDuration = 0; } return(cloneState); }
public void SetState(PotState state, bool isEmpty) { switch (state) { case PotState.BrewPrep: sr.sprite = isEmpty ? aqua : ingredient; break; case PotState.BrewPrg: sr.sprite = boiling; break; case PotState.CraftPrep: sr.sprite = empty; break; } }
public override bool Equals(object obj) { PotState otherState = obj as PotState; if (otherState == null) { return(false); } if (otherState == this) { return(true); } return(this.ID == otherState.ID && this.mealID == otherState.mealID); }
protected void HandlePotState(PotState potState) { State = potState; switch (State) { case PotState.None: HotWaterSupply.Pause(); break; case PotState.Empty: HandlePotEmpty(); break; case PotState.NotEmpty: PlateIsOn = true; break; default: throw new ArgumentOutOfRangeException("potState"); } }
public void OpenOrClose() { if (potState == PotState.idle) { potState = PotState.open; anim.SetTrigger("Open"); craftPanel.SetActive(true); AudioManager.instance.Play("pot_open"); return; } if (potState == PotState.open) { potState = PotState.idle; anim.SetTrigger("Close"); craftPanel.SetActive(false); AudioManager.instance.Play("pot_close"); } }
public virtual AIState ApplyAction(AIState currentState) { AIState cloneState = currentState.Clone() as AIState; foreach (int id in cloneState.PotStateIndexList) { if (id == currentState.CurrentPlayerState.HoldingItemID) { continue; } PotState pot = cloneState.ItemStateList[id] as PotState; MealState meal = cloneState.ItemStateList[pot.mealID] as MealState; if (meal.IsSpawned()) { meal.CookIngredients(); } } return(cloneState); }
public void ApplyRules(IEnumerable <Rule> rules) { foreach (Rule rule in rules) { PotState l1 = this.LeftNeighbor?.State ?? PotState.Empty; PotState l2 = this.LeftNeighbor?.LeftNeighbor?.State ?? PotState.Empty; PotState r1 = this.RightNeighbor?.State ?? PotState.Empty; PotState r2 = this.RightNeighbor?.RightNeighbor?.State ?? PotState.Empty; if (rule.Middle == this.State && rule.Left1 == l1 && rule.Left2 == l2 && rule.Right1 == r1 && rule.Right2 == r2) { this.NextGenState = rule.NextGen; return; } } // if no rule matches the old NextGen value remains }
public override AIState ApplyAction(AIState currentState) { AIState cloneState = base.ApplyAction(currentState); int droppedItemID = cloneState.CurrentPlayerState.Drop(); if (cloneState.ItemStateList[id].MyItemType == ItemType.TABLE) { TableSpace table = cloneState.ItemStateList[id] as TableSpace; table.ItemIDOnTable = droppedItemID; } if (cloneState.ItemStateList[id].MyItemType == ItemType.BOARD) { BoardState board = cloneState.ItemStateList[id] as BoardState; board.HoldingItemID = droppedItemID; } if (cloneState.ItemStateList[id].MyItemType == ItemType.POT) { PotState pot = cloneState.ItemStateList[id] as PotState; MealState meal = cloneState.ItemStateList[pot.mealID] as MealState; (cloneState.ItemStateList[droppedItemID] as IngredientState).IsInMeal = true; meal.ContainedIngredientIDs.Add(droppedItemID); meal.cookDuration = Mathf.Min(meal.cookDuration, (meal.ContainedIngredientIDs.Count - 1) * MealState.COOK_TIME_PER_INGREDIENT); } if (cloneState.ItemStateList[id].MyItemType == ItemType.PLATE) { PlateState plate = cloneState.ItemStateList[id] as PlateState; MealState meal = cloneState.ItemStateList[plate.mealID] as MealState; (cloneState.ItemStateList[droppedItemID] as IngredientState).IsInMeal = true; meal.ContainedIngredientIDs.Add(droppedItemID); meal.cookDuration = Mathf.Min(meal.cookDuration, (meal.ContainedIngredientIDs.Count - 1) * MealState.COOK_TIME_PER_INGREDIENT); } return(cloneState); }
public void CheckPot(PotState potState) { HandlePotState(potState); }
public override void LoadState(ItemState state) { PotState pState = state as PotState; HeldMeal = GetItemManager().ItemList[pState.mealID] as Meal; }
public void Deserialize(ref SerializeContext context, ref NetworkReader reader) { State = (PotState)reader.ReadByte(); }
public void SetPotState(Pot _pot, PotState _potStateToSet) { _pot.potState = _potStateToSet; }
public override bool isValid(AIState currentState) { if (currentState.CurrentPlayerState.HandsFree()) { return(false); } int droppedItemID = currentState.CurrentPlayerState.HoldingItemID; if (droppedItemID == id) { return(false); } ItemState droppedItem = currentState.ItemStateList[droppedItemID]; if (!(droppedItem.MyItemType == ItemType.POT || droppedItem.MyItemType == ItemType.PLATE)) { return(false); } ItemState receivingItem = currentState.ItemStateList[id]; if (!(receivingItem.MyItemType == ItemType.POT || receivingItem.MyItemType == ItemType.PLATE)) { return(false); } MealState transferredMeal; if (droppedItem.MyItemType == ItemType.POT) { PotState pot = (droppedItem as PotState); transferredMeal = (currentState.ItemStateList[pot.mealID] as MealState); } else { PlateState plate = (droppedItem as PlateState); if (plate.IsSubmitted) { return(false); } transferredMeal = (currentState.ItemStateList[plate.mealID] as MealState); } if (!transferredMeal.IsSpawned() || transferredMeal.IsBurnt()) { return(false); } if (receivingItem.MyItemType == ItemType.POT) { PotState pot1 = receivingItem as PotState; MealState meal1 = currentState.ItemStateList[pot1.mealID] as MealState; return(meal1.MealSize() + transferredMeal.MealSize() <= PotState.MAX_ITEMS_PER_POT && !meal1.IsBurnt()); } else { PlateState plate1 = receivingItem as PlateState; MealState meal1 = currentState.ItemStateList[plate1.mealID] as MealState; return(!plate1.IsSubmitted && !meal1.IsBurnt()); } }
protected virtual void OnPotStateChanged(PotState state) { PotEventArgs pea = new PotEventArgs(state); PotStateChanged?.Invoke(this, pea); }
/// <summary> /// Used to get all of the valid actions for the current state /// </summary> /// <returns></returns> public List <Action> GetValidActions(AIState state) { List <Action> validActions = new List <Action>(); //Waiting around validActions.Add(new IdleAction()); //Things you can do when your hands are free if (state.CurrentPlayerState.HandsFree()) { //Spawning items foreach (IngredientType type in System.Enum.GetValues(typeof(IngredientType))) { SpawnAction spawnAction = new SpawnAction(type); if (spawnAction.isValid(state)) { validActions.Add(spawnAction); } } PickUpAction pickupAction; //Picking up everything //Ingredients foreach (int ingredientID in state.IngredientStateIndexList) { IngredientState ingredient = state.ItemStateList[ingredientID] as IngredientState; if (ingredient.IsSpawned && !ingredient.IsInMeal) { pickupAction = new PickUpAction(ingredient.ID); validActions.Add(pickupAction); } } //Pots foreach (int potID in state.PotStateIndexList) { PotState pot = state.ItemStateList[potID] as PotState; pickupAction = new PickUpAction(pot.ID); validActions.Add(pickupAction); } //Plates foreach (int plateID in state.PlateStateIndexList) { PlateState plate = state.ItemStateList[plateID] as PlateState; pickupAction = new PickUpAction(plate.ID); validActions.Add(pickupAction); } PrepareAction prepAction; foreach (int boardID in state.BoardStateIndexList) { BoardState bState = state.ItemStateList[boardID] as BoardState; if (!bState.IsFree()) { IngredientState iState = state.ItemStateList[bState.HoldingItemID] as IngredientState; if (iState != null && !iState.IsPrepared) { prepAction = new PrepareAction(boardID); validActions.Add(prepAction); } } } } //Things you can do when you have something in hand else { DropOffAction dropoffAction; TransferAction transferAction; ItemState itemState = state.ItemStateList[state.CurrentPlayerState.HoldingItemID]; ItemType type = itemState.MyItemType; if (type == ItemType.INGREDIENT) { //Putting things on the table foreach (int tableID in state.TableStateIndexList) { TableSpace table = state.ItemStateList[tableID] as TableSpace; if (table.IsFree()) { dropoffAction = new DropOffAction(table.ID); validActions.Add(dropoffAction); } } //Moving ingredients to a cutting board foreach (int boardID in state.BoardStateIndexList) { BoardState board = state.ItemStateList[boardID] as BoardState; if (board.IsFree()) { dropoffAction = new DropOffAction(board.ID); validActions.Add(dropoffAction); } } if ((itemState as IngredientState).IsPrepared) { //Moving ingredients to a pot foreach (int potID in state.PotStateIndexList) { PotState pot = state.ItemStateList[potID] as PotState; MealState meal = state.ItemStateList[pot.mealID] as MealState; if (meal.MealSize() + 1 <= PotState.MAX_ITEMS_PER_POT && !meal.IsBurnt()) { dropoffAction = new DropOffAction(pot.ID); validActions.Add(dropoffAction); } } //Moving ingredients to a plate foreach (int plateID in state.PlateStateIndexList) { PlateState plate = state.ItemStateList[plateID] as PlateState; MealState meal = state.ItemStateList[plate.mealID] as MealState; if (!plate.IsSubmitted && !meal.IsBurnt()) { dropoffAction = new DropOffAction(plate.ID); validActions.Add(dropoffAction); } } } } if (type == ItemType.POT) { PotState pot = itemState as PotState; MealState meal = state.ItemStateList[pot.mealID] as MealState; //Putting the pot on the table foreach (int tableID in state.TableStateIndexList) { TableSpace table = state.ItemStateList[tableID] as TableSpace; if (table.IsFree()) { dropoffAction = new DropOffAction(table.ID); validActions.Add(dropoffAction); } } //Moving meal to a pot transferAction = new TransferAction(Item.NOTHING_ID); foreach (int potID in state.PotStateIndexList) { transferAction.id = potID; if (transferAction.isValid(state)) { validActions.Add(transferAction); transferAction = new TransferAction(Item.NOTHING_ID); } } //Moving the meal to another plate foreach (int plateID in state.PlateStateIndexList) { transferAction.id = plateID; if (transferAction.isValid(state)) { validActions.Add(transferAction); transferAction = new TransferAction(Item.NOTHING_ID); } } } if (type == ItemType.PLATE) { PlateState plate = itemState as PlateState; //Putting things on the table foreach (int tableID in state.TableStateIndexList) { TableSpace table = state.ItemStateList[tableID] as TableSpace; if (table.IsFree()) { dropoffAction = new DropOffAction(table.ID); validActions.Add(dropoffAction); } } //If the plate is non-empty MealState heldMeal = state.ItemStateList[plate.mealID] as MealState; if (heldMeal.IsSpawned()) { //Submitting the meal if (heldMeal.IsCooked()) { SubmitOrderAction submitAction = new SubmitOrderAction(); validActions.Add(submitAction); } //Moving meal to a pot transferAction = new TransferAction(Item.NOTHING_ID); foreach (int potID in state.PotStateIndexList) { transferAction.id = potID; if (transferAction.isValid(state)) { validActions.Add(transferAction); transferAction = new TransferAction(Item.NOTHING_ID); } } //Moving the meal to another plate foreach (int plateID in state.PlateStateIndexList) { transferAction.id = plateID; if (transferAction.isValid(state)) { validActions.Add(transferAction); transferAction = new TransferAction(Item.NOTHING_ID); } } } } } return(validActions); }
public PotEventArgs(PotState state) { State = state; }
public void LoadPot(SavablePot _savablePot) { potState = (PotState)_savablePot.potStatus; }
public void SetPotState(PotState newPotState) { CurrentPotState = newPotState; UpdateModel(); }
public override bool isValid(AIState currentState) { if (currentState.CurrentPlayerState.HandsFree()) { return(false); } else { int droppedItemID = currentState.CurrentPlayerState.HoldingItemID; if (currentState.ItemStateList[droppedItemID].MyItemType == ItemType.MEAL || currentState.ItemStateList[droppedItemID].MyItemType == ItemType.TABLE || currentState.ItemStateList[droppedItemID].MyItemType == ItemType.BOARD) { return(false); } if (currentState.ItemStateList[id].MyItemType == ItemType.TABLE) { TableSpace table = currentState.ItemStateList[id] as TableSpace; return(table.IsFree()); } else if (currentState.ItemStateList[id].MyItemType == ItemType.BOARD) { BoardState board = currentState.ItemStateList[id] as BoardState; return((currentState.ItemStateList[droppedItemID].MyItemType == ItemType.INGREDIENT) && board.IsFree()); } else if (currentState.ItemStateList[id].MyItemType == ItemType.POT) { if (currentState.ItemStateList[droppedItemID].MyItemType != ItemType.INGREDIENT) { return(false); } else { if ((currentState.ItemStateList[droppedItemID] as IngredientState).IsPrepared && (currentState.ItemStateList[droppedItemID] as IngredientState).IsSpawned) { PotState pot = currentState.ItemStateList[id] as PotState; MealState meal = currentState.ItemStateList[pot.mealID] as MealState; return(meal.MealSize() + 1 <= PotState.MAX_ITEMS_PER_POT && !meal.IsBurnt()); } else { return(false); } } } else if (currentState.ItemStateList[id].MyItemType == ItemType.PLATE) { if (currentState.ItemStateList[droppedItemID].MyItemType != ItemType.INGREDIENT) { return(false); } else { PlateState plate = currentState.ItemStateList[id] as PlateState; MealState meal = currentState.ItemStateList[plate.mealID] as MealState; return((currentState.ItemStateList[droppedItemID] as IngredientState).IsPrepared && (currentState.ItemStateList[droppedItemID] as IngredientState).IsSpawned && !plate.IsSubmitted && !meal.IsBurnt()); } } else { return(false); } } }