public static GameAction GetRandomOrder(Entity entity, int orderTimeOurInMins = 120) { var randomValue = Random.value; if (randomValue <= 0.20) { var drinkOrder = new ExactDrinkorder(DrinkRecipes.GetRandomDrinkRecipe(), entity.GetState <NameState>().Name); return(OrderDrink(entity, drinkOrder, DialogueSelector.GetExactDrinkOrderConversation(drinkOrder.Recipe.DrinkName, entity), orderTimeoutInMins: orderTimeOurInMins)); } if (randomValue <= 0.40) { return(OrderDrink(entity, new NonAlcoholicDrinkOrder(entity.GetState <NameState>().Name), new OrderNonAlcoholicDrinkConversation(), orderTimeoutInMins: orderTimeOurInMins)); } if (randomValue <= 0.60) { var ingredient = Ingredients.DispensedIngredients.PickRandom(); return(OrderDrink(entity, new IncludingIngredientOrder(ingredient, entity.GetState <NameState>().Name), new OrderDrinkIncludingIngredientConversation(ingredient), orderTimeoutInMins: orderTimeOurInMins)); } if (randomValue <= 0.80) { var ingredient = Ingredients.DispensedIngredients.PickRandom(); return(OrderDrink(entity, new ExcludingIngredientOrder(ingredient, entity.GetState <NameState>().Name), new OrderDrinkExcludingIngredientConversation(ingredient), orderTimeoutInMins: orderTimeOurInMins)); } return(OrderDrink(entity, new ExactDrinkorder(DrinkRecipes.Beer, entity.GetState <NameState>().Name), DialogueSelector.GetExactDrinkOrderConversation("Beer", entity), orderTimeoutInMins: orderTimeOurInMins)); }
public static ConditionalActionSequence GoToPaypointAndOrderDrink(Entity entity, DrinkRecipe drinkRecipe, int orderTimeoutInMins = 20) { var orderDrink = new ConditionalActionSequence("OrderDrinkIfPossible"); orderDrink.Add(QueueForDrinkOrder(entity, 10, 20)); DrinkOrders.ExactDrinkorder drinkOrder = new DrinkOrders.ExactDrinkorder(drinkRecipe, entity.GetState <NameState>().Name); orderDrink.Add(DrinkOrders.OrderDrink(entity, drinkOrder, DialogueSelector.GetExactDrinkOrderConversation(drinkOrder.Recipe.DrinkName, entity), orderTimeoutInMins: orderTimeoutInMins)); return(orderDrink); }
public static GameAction GetRandomAlcoholicDrinkOrderWithoutFailure(Entity entity, int orderTimeOurInMins = 20) { var drinkOrder = new ExactDrinkorder(DrinkRecipes.GetRandomAlcoholicDrinkRecipe(), entity.GetState <NameState>().Name); return(OrderDrinkWithoutFailure(entity, drinkOrder, DialogueSelector.GetExactDrinkOrderConversation(drinkOrder.Recipe.DrinkName, entity, required: Required.Yes), orderTimeOurInMins)); }
public static GameAction GetRandomAlcoholicDrinkOrder(Entity entity, Conversation correctDrinkConversation = null, Conversation incorrectDrinkConversation = null, Dictionary <String, GameAction> otherDrinkActions = null, int orderTimeOurInMins = 20) { var drinkOrder = new ExactDrinkorder(DrinkRecipes.GetRandomAlcoholicDrinkRecipe(), entity.GetState <NameState>().Name); return(OrderDrink(entity, drinkOrder, DialogueSelector.GetExactDrinkOrderConversation(drinkOrder.Recipe.DrinkName, entity, required: Required.Yes), correctDrinkConversation, incorrectDrinkConversation, otherDrinkActions, orderTimeOurInMins)); }
public static ConditionalActionSequence WaitForDrink(Entity entity, string drinkOrIngerdientOrdered, DrinkOrders.DrinkOrder drinkOrder, int timeoutInGameMins, bool retry = false, Conversation correctDrinkConversation = null, Conversation incorrectDrinkConversation = null, Dictionary <String, GameAction> otherDrinkActions = null) { var waitForDrink = new ConditionalActionSequence("WaitForDrink"); waitForDrink.Add(new OnFailureDecorator( new DrinkIsInInventoryAction(drinkOrder, timeoutInGameMins), //TODO: Need to account for the "No drink" case here. () => { if (entity.GetState <InventoryState>().Child != null) { if (retry) //If retry is true then you are stuck until you don't fail. { ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, WaitForDrink(entity, drinkOrIngerdientOrdered, drinkOrder, 99999, true, correctDrinkConversation, incorrectDrinkConversation)); ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, new ConversationAction(new Dialogues.OrderDrinkRetryConverstation())); ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, new DestoryEntityInInventoryAction()); } else { var drinkInHand = entity.GetState <InventoryState>().Child.HasState <DrinkState>() ? entity.GetState <InventoryState>().Child.GetState <DrinkState>() : null; var otherDrinkResponse = drinkInHand != null && otherDrinkActions != null ? otherDrinkActions.Keys.First(otherDrink => DrinkState.IsIdentical(drinkInHand, DrinkRecipes.GetDrinkRecipe(otherDrink).Contents)) : null; if (otherDrinkResponse != null) { ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, otherDrinkActions[otherDrinkResponse]); } else { if (incorrectDrinkConversation == null) { var reason = entity.GetState <ActionBlackboardState>().IncorrectDrinkReason; bool destroyDrink = false; var conversation = DialogueSelector.GetIncorrectDrinkOrderConversation(drinkOrIngerdientOrdered, entity, reason, out destroyDrink); ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, new ConversationAction(conversation)); if (destroyDrink) { ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, new DestoryEntityInInventoryAction()); } } else { ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, new ConversationAction(incorrectDrinkConversation)); } ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, new UpdateMoodAction(Mood.Angry)); } } ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, new EndDrinkOrderAction()); ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, new ReleaseWaypointAction()); } else { bool destroyDrink; var timeoutConversation = DialogueSelector.GetIncorrectDrinkOrderConversation(drinkOrIngerdientOrdered, entity, IncorrectDrinkReason.Timeout, out destroyDrink); ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, new ConversationAction(timeoutConversation)); ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, new EndDrinkOrderAction()); ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, new ReleaseWaypointAction()); ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(entity, new UpdateMoodAction(Mood.Angry)); } }) ); waitForDrink.Add(new ClearConversationAction()); //Only if not failed if (correctDrinkConversation != null) { waitForDrink.Add(new ConversationAction(correctDrinkConversation)); } else { waitForDrink.Add(new ConversationAction(DialogueSelector.GetCorrectDrinkOrderConversation(entity))); } waitForDrink.Add(new TriggerAnimationAction(AnimationEvent.ItemTakeTrigger)); waitForDrink.Add(new ModifyMoneyAction(Constants.DrinkSucsessMoney, PaymentType.DrinkSale)); waitForDrink.Add(new EndDrinkOrderAction()); waitForDrink.Add(new ReleaseWaypointAction()); waitForDrink.Add(new UpdateMoodAction(Mood.Happy)); return(waitForDrink); }