Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        ingredientSelector = FindObjectOfType <IngredientSelector>();
        matchCalculator    = MatchCalculator.matchCalculator;
        float targetGemWidth = boardWidth / width;

        bELibrary = LibraryManager.instance.get <BELibrary>();

        RectTransform rt           = (RectTransform)availibleGems[0].gameObject.transform;
        float         tempGemWidth = rt.rect.width;

        beScalar = targetGemWidth / tempGemWidth;
        foreach (IBoardEntity be in availibleGems)
        {
            be.gameObject.transform.localScale = new Vector2(beScalar, beScalar);
        }

        gemWidth  = targetGemWidth;
        gemHeight = targetGemWidth;

        selectedIngredient           = null;
        DayManager.dayManager.start += () => {
            populateBoard();
            unlockBoard();
            //checkMatchesAfterHelper(1);
        };
        DayManager.dayManager.end += () => {
            clearBoard();
            started = false;
        };
    }
Ejemplo n.º 2
0
 public void Start()
 {
     ingredientSelector            = FindObjectOfType <IngredientSelector>();
     moneyScore                    = FindObjectOfType <MoneyScore>();
     moneyScore.moneyChangedEvent += checkMoneyBalance;
     moneyScore.updateMoneyBalance();
 }
 public static bool HasRecipeChoices( Map map, IngredientSelector ingredient )
 {
     return ingredient.allowedThingDefs.Any( td => RecipeSelector.HasRecipe( map, td ) );
 }
 public static bool HasRecipeChoices( IngredientSelector ingredient )
 {
     return ingredient.allowedThingDefs.Any( RecipeSelector.HasRecipe );
 }
Ejemplo n.º 5
0
        public static bool OnIngredientSelectorClicked(CraftingMenu __instance, int _selectorIndex)
        {
            try
            {
                IngredientSelector[] m_ingredientSelectors         = (IngredientSelector[])AccessTools.Field(typeof(CraftingMenu), "m_ingredientSelectors").GetValue(__instance);
                List <int>           ingredientSelectorCachedItems = (List <int>)AccessTools.Field(typeof(CraftingMenu), "ingredientSelectorCachedItems").GetValue(__instance);
                int m_lastRecipeIndex = (int)AccessTools.Field(typeof(CraftingMenu), "m_lastRecipeIndex").GetValue(__instance);
                List <KeyValuePair <int, Recipe> > m_complexeRecipes = (List <KeyValuePair <int, Recipe> >)AccessTools.Field(typeof(CraftingMenu), "m_complexeRecipes").GetValue(__instance);
                List <RecipeDisplay> m_recipeDisplays = (List <RecipeDisplay>)AccessTools.Field(typeof(CraftingMenu), "m_recipeDisplays").GetValue(__instance);
                DictionaryExt <int, CompatibleIngredient> m_availableIngredients = (DictionaryExt <int, CompatibleIngredient>)AccessTools.Field(typeof(CraftingMenu), "m_availableIngredients").GetValue(__instance);
                CharacterUI      m_characterUI        = (CharacterUI)AccessTools.Field(typeof(CraftingMenu), "m_characterUI").GetValue(__instance);
                ItemListSelector m_tempSelectorWindow = (ItemListSelector)AccessTools.Field(typeof(CraftingMenu), "m_tempSelectorWindow").GetValue(__instance);
                Transform        m_selectorWindowPos  = (Transform)AccessTools.Field(typeof(CraftingMenu), "m_selectorWindowPos").GetValue(__instance);
                bool             m_simpleMode         = (bool)AccessTools.Field(typeof(CraftingMenu), "m_simpleMode").GetValue(__instance);

                IngredientSelector ingredientSelector = m_ingredientSelectors[_selectorIndex];
                ingredientSelectorCachedItems.Clear();
                if (m_lastRecipeIndex != -1)
                {
                    if (m_complexeRecipes[m_lastRecipeIndex].Value.Ingredients[_selectorIndex].ActionType == RecipeIngredient.ActionTypes.AddGenericIngredient)
                    {
                        IList <int> stepCompatibleIngredients = m_recipeDisplays[m_lastRecipeIndex].GetStepCompatibleIngredients(_selectorIndex);
                        for (int i = 0; i < stepCompatibleIngredients.Count; i++)
                        {
                            if (m_availableIngredients.TryGetValue(stepCompatibleIngredients[i], out CompatibleIngredient _outValue) && _outValue.AvailableQty > 0)
                            {
                                ingredientSelectorCachedItems.Add(_outValue.ItemID);
                            }
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < m_availableIngredients.Count; j++)
                    {
                        if (m_availableIngredients.Values[j].AvailableQty > 0 || ingredientSelector.AssignedIngredient == m_availableIngredients.Values[j])
                        {
                            // lasyan3 : Disallow cleaning water without cooking pot
                            if (m_availableIngredients.Values[j].IsWaterItem && m_simpleMode)
                            {
                                continue;
                            }
                            // lasyan3 : Disallow use of rancid water
                            //if (m_availableIngredients.Values[j].IsWaterItem && m_availableIngredients.Values[j].ItemPrefab.ItemID == (int)eItemIDs.RancidWater) continue;
                            ingredientSelectorCachedItems.Add(m_availableIngredients.Values[j].ItemID);
                        }
                    }
                }
                if (ingredientSelectorCachedItems.Count > 0)
                {
                    m_tempSelectorWindow = m_characterUI.GetListSelector();
                    if ((bool)m_tempSelectorWindow)
                    {
                        m_tempSelectorWindow.onItemHovered = __instance.RefreshItemDetailDisplay;
                        m_tempSelectorWindow.onItemClicked = delegate(IItemDisplay _display)
                        {
                            __instance.IngredientSelectorHasChanged(_selectorIndex, _display?.RefItem.ItemID ?? (-1));
                            m_tempSelectorWindow.Hide();
                        };
                        m_tempSelectorWindow.Position = (((bool)m_selectorWindowPos) ? m_selectorWindowPos.position : __instance.transform.position);
                        m_tempSelectorWindow.Title    = ingredientSelector.Text;
                        m_tempSelectorWindow.ShowSelector(ingredientSelectorCachedItems, ingredientSelector.gameObject, m_lastRecipeIndex == -1);
                    }
                }
            }
            catch (Exception ex)
            {
                WorkInProgress.Instance.MyLogger.LogError("OnIngredientSelectorClicked: " + ex.Message);
            }
            return(false);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns true if the recipe has prerequisite ingredients, and those ingredients can currently be crafted.
 /// </summary>
 /// <param name="recipe"></param>
 /// <returns></returns>
 public static bool HasPrerequisiteChoices(Map map, RecipeDef recipe)
 {
     return
         (recipe.ingredients.Select(ing => new IngredientSelector(Manager.For(map), ing, 1, recipe))
          .Any(ins => IngredientSelector.HasRecipeChoices(map, ins)));
 }
Ejemplo n.º 7
0
 public static bool HasRecipeChoices(Map map, IngredientSelector ingredient)
 {
     return(ingredient.allowedThingDefs.Any(td => RecipeSelector.HasRecipe(map, td)));
 }