private void UpdateLiquidcolor(DrinkState drink) { var drinkSize = drink.GetTotalDrinkSize(); Color?accumulatedColor = null; foreach (var keyVar in drink.GetContents()) { for (var i = 0; i < keyVar.Value; i++) { if (accumulatedColor == null) { accumulatedColor = Ingredients.IngredientColorMap[keyVar.Key]; } else { accumulatedColor += Ingredients.IngredientColorMap[keyVar.Key]; } } } if (accumulatedColor == null) { return; } accumulatedColor = accumulatedColor / drinkSize; DrinkContents.GetComponent <Renderer>().material.color = accumulatedColor.Value; }
public void OnStartRendering(Entity entity) { initalLocalHeight = DrinkContents.gameObject.transform.localPosition.y; halfDrinkHeight = initalLocalHeight - DrinkBottom.gameObject.transform.localPosition.y; drinkState = entity.GetState <DrinkState>(); drinkState.DrinkAmountChanged += OnDrinkChanged; OnDrinkChanged(); }
public ExactDrinkorder(DrinkRecipe recipe, string ordererName) : base(DrinkOrderType.Exact, recipe.DrinkName) { Recipe = recipe; OrdererName = ordererName; DrinkPredicates = new List <DrinkPredicate>() { GlassHasContents, new DrinkPredicate(testDrink => DrinkState.IsIdentical(recipe.Contents, testDrink), IncorrectDrinkReason.WrongRecipe) }; }
public bool IsValidForOrder(DrinkState drink, out IncorrectDrinkReason reason) { foreach (var predicate in DrinkPredicates) { var success = predicate.test.Invoke(drink); if (!success) { reason = predicate.failure; return(false); } } reason = IncorrectDrinkReason.None; return(true); }
void Start() { playerModelDefaultRotation = playerModel.transform.localRotation; playerModelClimbRotation = Quaternion.identity; playerModelTauntRotation.SetLookRotation(new Vector3(0, 0, -1), new Vector3(0, 1, 0)); attackCollider.enabled = false; lightningGenerator.SetActive(false); // temp dashAttackCollider.enabled = false; shieldCollider.enabled = false; ShowShield(false); ShowHorn(false); playerAnimator = GetComponent <Animator>(); GameObject.FindGameObjectWithTag("GameSession").GetComponent <SavePlayerState>().RecoverPlayerStatusValues(this); staminaRecovery = 0.0f; fullStaminaRecovery = false; GameObject guiObject = GameObject.Find("GUI"); if (guiObject) { guiManager = guiObject.GetComponent <GUIManager>(); } activeRespawnPoint = initialPosition; cameraFade = GameObject.Find("PlayerCamera").GetComponent <CameraFade>(); attack = new AttackState(CalculateFramesFromTime(attackDuration)); cast = new CastState(CalculateFramesFromTime(castDuration)); climb = new ClimbState(); dash = new DashState(CalculateFramesFromTime(dashDuration)); dead = new DeadState(CalculateFramesFromTime(deadDuration)); defense = new DefenseState(); drink = new DrinkState(CalculateFramesFromTime(drinkDuration)); fall = new FallState(); fallcloud = new FallCloudState(CalculateFramesFromTime(fallCloudDuration)); hit = new HitState(CalculateFramesFromTime(hitDuration)); idle = new IdleState(); jump = new JumpState(CalculateFramesFromTime(GetComponent <PlayerMove>().timeToJumpApex)); refill = new RefillState(CalculateFramesFromTime(refillDuration)); taunt = new TauntState(CalculateFramesFromTime(tauntDuration)); walk = new WalkState(); SetState(idle); facingRight = true; jumpAvailable = true; climbLadderAvailable = false; beerRefillAvailable = false; justHit = false; jumpFrames = 0; framesInDelayCount = 0; camFollow = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFollow>(); colliderSize = GetComponent <BoxCollider>().size; godMode = false; }
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); }
public static bool Contains(DrinkState drinkState) { return(Recipes.Any(recipe => recipe.Contents.Equals(drinkState))); }
public DrinkRecipe(string drinkName, DrinkState contents) { DrinkName = drinkName; Contents = contents; }