public void CheckForValidRecipe() { if (this.CheckStorage()) { return; } IOrderedEnumerable <Receipe> orderedEnumerable = null; IOrderedEnumerable <Receipe> orderedEnumerable2 = null; if (this._ingredients.Count > 0) { orderedEnumerable = from ar in this._receipeBook.AvailableReceipesCache where this._ingredients.All((ReceipeIngredient i) => ar._ingredients.Any((ReceipeIngredient i2) => i._itemID == i2._itemID)) where this.CanCarryProduct(ar) orderby ar._ingredients.Length select ar; orderedEnumerable2 = from ar in this._receipeBook.AvailableUpgradeCache where this._ingredients.All((ReceipeIngredient i) => ar._ingredients.Any((ReceipeIngredient i2) => i._itemID == i2._itemID)) where this.CanCarryProduct(ar) orderby ar._ingredients.Length select ar; this._validRecipe = orderedEnumerable.FirstOrDefault <Receipe>(); } else { this._validRecipe = null; } bool flag = this._validRecipe != null; if (flag) { if (!this.CanCarryProduct(this._validRecipe)) { Scene.HudGui.CraftingReceipeBacking.gameObject.SetActive(false); this._validRecipeFull = true; flag = false; } else { int num = 0; int num2 = this._validRecipe._ingredients.Sum((ReceipeIngredient i) => i._amount); foreach (ReceipeIngredient cogIngredients in this._ingredients) { ReceipeIngredient receipeIngredient = this._validRecipe._ingredients.First((ReceipeIngredient i) => i._itemID == cogIngredients._itemID); if (cogIngredients._amount > receipeIngredient._amount) { this._validRecipe = null; flag = false; break; } num += cogIngredients._amount; } this._validRecipeFull = false; this._validRecipeFill = (float)num / (float)num2; HudGui arg_25D_0 = Scene.HudGui; IOrderedEnumerable <Receipe> arg_25D_1; if (flag) { IOrderedEnumerable <Receipe> orderedEnumerable3 = from r in orderedEnumerable.Concat(orderedEnumerable2) orderby r._type, r._ingredients.Length select r; arg_25D_1 = orderedEnumerable3; } else { arg_25D_1 = null; } arg_25D_0.ShowValidCraftingRecipes(arg_25D_1); Scene.HudGui.CraftingReceipeBacking.gameObject.SetActive(false); if (num != num2 && flag) { Scene.HudGui.CraftingReceipeBacking.gameObject.SetActive(true); Scene.HudGui.CraftingReceipeProgress.fillAmount = this._validRecipeFill; flag = false; this._validRecipe = null; } } } else { Scene.HudGui.ShowValidCraftingRecipes(orderedEnumerable2); Scene.HudGui.CraftingReceipeBacking.gameObject.SetActive(false); } if (flag) { Scene.HudGui.HideUpgradesDistribution(); this._craftSfx2Emitter.Play(); base.gameObject.GetComponent <Renderer>().enabled = true; } if (!flag || !this.CanCraft) { this.CheckForValidUpgrade(); } }
public IEnumerator NameSearchResponse(TurnTaker tt) { // If the player's deck is empty, this does nothing regardless of their choices, so skip everything if (tt.Deck.Cards.Any()) { // "[This player] may name a keyword other than One-Shot." IOrderedEnumerable <string> keywords = from s in tt.Deck.Cards.SelectMany((Card c) => base.GameController.GetAllKeywords(c)).Distinct().Where((string s) => s.ToLower() != "one-shot") orderby s select s; keywords = keywords.Concat("Another keyword - find nothing, shuffle your deck".ToEnumerable()).OrderBy((string s) => s); List <SelectWordDecision> choice = new List <SelectWordDecision>(); IEnumerator selectCoroutine = base.GameController.SelectWord(base.GameController.FindHeroTurnTakerController(tt.ToHero()), keywords, SelectionType.SelectKeyword, choice, true, cardSource: GetCardSource()); if (base.UseUnityCoroutines) { yield return(base.GameController.StartCoroutine(selectCoroutine)); } else { base.GameController.ExhaustCoroutine(selectCoroutine); } if (DidSelectWord(choice)) { string chosen = GetSelectedWord(choice); // "[This player] reveals cards from the top of their deck until they reveal a card with the keyword they named, puts that card into play or into their hand, then shuffles the other revealed cards into their deck." List <RevealCardsAction> revealedCards = new List <RevealCardsAction>(); IEnumerator revealCoroutine = base.GameController.RevealCards(base.GameController.FindTurnTakerController(tt), tt.Deck, (Card c) => c.DoKeywordsContain(chosen), 1, revealedCards, revealedCardDisplay: RevealedCardDisplay.ShowMatchingCards, cardSource: GetCardSource()); if (base.UseUnityCoroutines) { yield return(base.GameController.StartCoroutine(revealCoroutine)); } else { base.GameController.ExhaustCoroutine(revealCoroutine); } RevealCardsAction revealed = revealedCards.FirstOrDefault(); if (revealed != null && revealed.FoundMatchingCards) { Card selectedCard = revealed.MatchingCards.FirstOrDefault(); List <MoveCardDestination> choices = new List <MoveCardDestination>(); choices.Add(new MoveCardDestination(tt.PlayArea)); choices.Add(new MoveCardDestination(tt.ToHero().Hand)); if (selectedCard != null) { IEnumerator moveCoroutine = base.GameController.SelectLocationAndMoveCard(base.GameController.FindHeroTurnTakerController(tt.ToHero()), selectedCard, choices, isPutIntoPlay: true, responsibleTurnTaker: base.TurnTaker, cardSource: GetCardSource()); if (base.UseUnityCoroutines) { yield return(base.GameController.StartCoroutine(moveCoroutine)); } else { base.GameController.ExhaustCoroutine(moveCoroutine); } revealed.MatchingCards.Remove(selectedCard); } IEnumerator replaceCoroutine = base.GameController.MoveCards(base.GameController.FindTurnTakerController(tt), revealed.RevealedCards.Where((Card c) => c != selectedCard), tt.Deck, responsibleTurnTaker: base.TurnTaker, cardSource: GetCardSource()); if (base.UseUnityCoroutines) { yield return(base.GameController.StartCoroutine(replaceCoroutine)); } else { base.GameController.ExhaustCoroutine(replaceCoroutine); } IEnumerator shuffleCoroutine = base.GameController.ShuffleLocation(tt.Deck, cardSource: GetCardSource()); if (base.UseUnityCoroutines) { yield return(base.GameController.StartCoroutine(shuffleCoroutine)); } else { base.GameController.ExhaustCoroutine(shuffleCoroutine); } } } } else { IEnumerator messageCoroutine = base.GameController.SendMessageAction(tt.Name + "'s deck has no cards for " + base.Card.Title + " to reveal.", Priority.Medium, GetCardSource()); if (base.UseUnityCoroutines) { yield return(base.GameController.StartCoroutine(messageCoroutine)); } else { base.GameController.ExhaustCoroutine(messageCoroutine); } } yield break; }