Пример #1
0
        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);
        }
Пример #2
0
        public static ConditionalActionSequence WaitForDrinkWithoutFailure(Entity entity, DrinkOrders.DrinkOrder drinkOrder, int timeoutInGameMins)
        {
            var waitForDrink = new ConditionalActionSequence("WaitForDrink");

            waitForDrink.Add(new DrinkIsInInventoryAction(drinkOrder, timeoutInGameMins));
            return(waitForDrink);
        }