コード例 #1
0
 public static void update()
 {
     foreach (Industry ind in Main.instance.player.builtItems)
     {
         GameObject go;
         enchantInvenList.TryGetValue(ind, out go);
         if (go != null)
         {
             go.transform.Find("Quantity").GetComponent <Text>().text = Main.AsCurrency(ind.quantityStored) + " / " + Main.AsCurrency(10000);
         }
         else
         {
             enchantIngredList.TryGetValue(ind, out go);
             if (go != null)
             {
                 //int v = (ind.quantityStored > int.MaxValue ? 999999999 : BigInteger.ToInt32(ind.quantityStored));
                 //ItemStack stack = new ItemStack(ind, v);
                 Enchantment e = GameRegistry.GetEnchantmentByItem(ind.industryItem);
                 go.transform.Find("Quantity").GetComponent <Text>().text = Main.AsCurrency(ind.quantityStored) + " / " + Main.AsCurrency(e.ingredientQuantity);
             }
         }
     }
     foreach (ItemStack stack in Main.instance.player.miscInventory)
     {
         GameObject go;
         enchantMiscInvenList.TryGetValue(stack, out go);
         Enchantment e = GameRegistry.GetEnchantmentByItem(stack.item);
         if (go != null && e != null)
         {
             go.transform.Find("Quantity").GetComponent <Text>().text = Main.AsCurrency(stack.stackSize) + " / " + Main.AsCurrency(e.ingredientQuantity);
         }
     }
 }
コード例 #2
0
        private static void FilterEnchantIngredients(int filter)
        {
            GameObject            go;
            List <GameObjectPair> ingreds = new List <GameObjectPair>();

            for (var i = 0; i < inventoryList2.childCount; i++)
            {
                go = inventoryList2.GetChild(i).gameObject;
                KeyValuePair <ItemStack, GameObject> stack = enchantMiscInvenList.FirstOrDefault(x => x.Value == go);
                KeyValuePair <Industry, GameObject>  ind   = enchantIngredList.FirstOrDefault(x => x.Value == go);
                Enchantment ench = null;
                if (stack.Key != null)
                {
                    ench = GameRegistry.GetEnchantmentByItem(stack.Key.item);
                }
                if (ind.Key != null)
                {
                    ench = GameRegistry.GetEnchantmentByItem(ind.Key.industryItem);
                }
                if (ench != null && (filter < 0 || ((int)ench.enchantSlotRestriction & filter) > 0))
                {
                    go.SetActive(true);
                    //go.transform.localPosition = new Vector3(6, (i * -125) - 5, 0);
                    ingreds.Add(new GameObjectPair(go.transform, ind.Key, stack.Key));
                }
                else
                {
                    if (ench != null)
                    {
                        go.SetActive(false);
                    }
                }
            }

            /*for(var i = 0; i < inventoryList2.childCount; i++) {
             *      Transform t = inventoryList2.GetChild(i);
             *      KeyValuePair<ItemStack, GameObject> stack;
             *      stack = enchantMiscInvenList.FirstOrDefault(x => x.Value == t.gameObject);
             *      KeyValuePair<Industry, GameObject> ind;
             *      ind = enchantIngredList.FirstOrDefault(x => x.Value == t.gameObject);
             *      ingreds.Add(new GameObjectPair(t, ind.Key, stack.Key));
             * }*/
            ingreds.Sort((x, y) => {
                var v = y.val.CompareTo(x.val);
                return(v != 0 ? v : x.name.CompareTo(y.name));
            });
            for (var i = 0; i < ingreds.Count; i++)
            {
                ingreds[i].t.localPosition = new Vector3(6, (i * -125) - 5, 0);
            }

            ((RectTransform)inventoryList2).SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, ingreds.Count * 126 + 5);
            inventoryList2.transform.localPosition = Vector3.zero;
        }
コード例 #3
0
        public void addItemToInventory(ItemStack stack, Quest theQuest, bool doNotify)
        {
            int         v    = addItemToInventory(stack);
            Enchantment ench = GameRegistry.GetEnchantmentByItem(stack.item);

            //TODO: does not seem to be working correctly
            if (v == stack.stackSize || (ench != null && v >= ench.ingredientQuantity && v - stack.stackSize < ench.ingredientQuantity))
            {
                //Debug.Log(stack.item.name + " +" + stack.stackSize + " = " + v + "|" + (ench != null?""+ench.ingredientQuantity:"no enchant"));
                NotificationItem notify = new NotificationItem(theQuest.heroName, "Found: " + Main.ToTitleCase(stack.item.name) + "\nAdded to your stocks", SpriteLoader.getSpriteForResource("items/" + stack.item.name));
                GuiManager.ShowNotification(notify);
            }
        }
コード例 #4
0
 public static void addInput2(ItemStack selectedStack)
 {
     if (selectedStack != null)
     {
         inputImg2.sprite = SpriteLoader.getSpriteForResource("items/" + selectedStack.item.name);
         inputStack2      = new ItemStack(selectedStack.item, GameRegistry.GetEnchantmentByItem(selectedStack.item).ingredientQuantity);
         preSelectedStack = selectedStack;
         selectedStack    = null;
     }
     else
     {
         inputImg2.sprite = GuiManager.instance.gray_square;
         inputStack2      = null;
         preSelectedStack = null;
     }
     doOutput();
 }
コード例 #5
0
 public GameObjectPair(Transform t, Industry ind, ItemStack stack)
 {
     this.t     = t;
     this.ind   = ind;
     this.stack = stack;
     if (ind != null)
     {
         Enchantment ench = GameRegistry.GetEnchantmentByItem(ind.industryItem);
         val  = (ind.quantityStored >= ench.ingredientQuantity ? 1 : 0);
         name = ind.unlocalizedName;
     }
     else if (stack != null)
     {
         Enchantment ench = GameRegistry.GetEnchantmentByItem(stack.item);
         val  = (stack.stackSize >= ench.ingredientQuantity ? 1 : 0);
         name = stack.item.name;
     }
 }
コード例 #6
0
        private void enchantRandomItem(Quest theQuest)
        {
            ItemStack newRelic = theQuest.determineRelic();

            if (newRelic != null)
            {
                //Debug.Log("Genie is enchanting an item");
                newRelic = QuestManager.makeRelic(newRelic, this, theQuest.heroName);
                //Debug.Log("Enchanting a(n) " + newRelic.item.name);
                Item item;                // = Items.getRandom(theQuest.questRand);
                bool ret       = true;
                int  loopcount = 0;
                do
                {
                    loopcount++;
                    item = Items.getRandom(theQuest.questRand);
                    Enchantment ench = GameRegistry.GetEnchantmentByItem(item);
                    //Debug.Log("Trying... " + ench.name);
                    if (ench == null)
                    {
                        continue;
                    }
                    if (newRelic.enchants.Count > 0)
                    {
                        bool maxed = false;
                        if (newRelic.enchants.Contains(ench))
                        {
                            int count = 0;
                            foreach (Enchantment ench1 in newRelic.enchants)
                            {
                                if (ench1 == ench)
                                {
                                    count++;
                                }
                            }
                            maxed = count >= ench.maxConcurrent;
                        }
                        if (maxed || newRelic.relicData == null || newRelic.relicData.Count < newRelic.enchants.Count)
                        {
                            //Debug.Log("This item is maxed out already. Weird.");
                            goto baditem;
                        }
                    }
                    else if ((newRelic.item.equipType & ench.enchantSlotRestriction) > 0)
                    {
                        //Debug.Log("Applied!");
                        newRelic.applyEnchantment(ench);
                        ret = false;
                    }
                } while(ret && loopcount < 30);                 //shouldn't need to try *30* times.
                if (loopcount >= 30)
                {
                    goto baditem;
                }

                if (!theQuest.inventory.Contains(newRelic))
                {
                    theQuest.inventory.Add(newRelic);
                }
                //allRelics.Add(newRelic);
                //availableRelics.Add(newRelic);
                StatisticsTracker.relicsMade.addValue(1);
                if (StatisticsTracker.relicsMade.value == 1)
                {
                    StatisticsTracker.maxQuestDifficulty.addValue(1);
                }
                if (!StatisticsTracker.relicFromGenie.isAchieved())
                {
                    StatisticsTracker.relicFromGenie.setAchieved();
                }
                return;

baditem:
                ChallengeTypes.Loot.AddRareResource(theQuest);
                ChallengeTypes.Loot.AddRareResource(theQuest);
            }
            else
            {
                ChallengeTypes.Loot.AddRareResource(theQuest);
                ChallengeTypes.Loot.AddRareResource(theQuest);
            }
        }
コード例 #7
0
        private void Bless(Quest theQuest)
        {
            ItemStack newRelic = theQuest.determineRelic();

            if (newRelic != null)
            {
                //Debug.Log("Enchanting a(n) " + newRelic.item.name);
                Item item;                // = Items.getRandom(theQuest.questRand);
                bool ret       = true;
                int  loopcount = 0;
                do
                {
                    loopcount++;
                    item = Items.getRandom(theQuest.questRand);
                    Enchantment ench = GameRegistry.GetEnchantmentByItem(item);
                    //Debug.Log("Trying... " + ench.name);
                    if (ench == null)
                    {
                        continue;
                    }
                    if (newRelic.enchants.Count > 0)
                    {
                        bool maxed = false;
                        if (newRelic.enchants.Contains(ench))
                        {
                            int count = 0;
                            foreach (Enchantment ench1 in newRelic.enchants)
                            {
                                if (ench1 == ench)
                                {
                                    count++;
                                }
                            }
                            maxed = count >= ench.maxConcurrent;
                        }
                        if (maxed || newRelic.relicData == null || newRelic.relicData.Count < newRelic.enchants.Count)
                        {
                            goto baditem;
                        }
                    }
                    else if ((newRelic.item.equipType & ench.enchantSlotRestriction) > 0)
                    {
                        newRelic.applyEnchantment(ench);
                        ret = false;
                    }
                } while(ret && loopcount < 30);                 //shouldn't need to try *30* times.
                if (loopcount >= 30)
                {
                    goto baditem;
                }

                if (!theQuest.inventory.Contains(newRelic))
                {
                    theQuest.inventory.Add(newRelic);
                }
                return;

baditem:
                ChallengeTypes.Loot.AddRareResource(theQuest);
                ChallengeTypes.Loot.AddRareResource(theQuest);
            }
            else
            {
                ChallengeTypes.Loot.AddRareResource(theQuest);
                ChallengeTypes.Loot.AddRareResource(theQuest);
            }
        }
コード例 #8
0
 public int addItemToInventory(ItemStack stack)
 {
     if (stack == null)
     {
         return(-1);
     }
     stack.wasAddedByJourneyman = false;
     if (Main.instance.player.miscInventory.Contains(stack))
     {
         return(-1);
     }
     if (Main.instance.player.unidentifiedRelics.Contains(stack))
     {
         if (stack.isIDedByPlayer)
         {
             Main.instance.player.unidentifiedRelics.Remove(stack);
         }
         else
         {
             return(-1);
         }
     }
     if (stack.relicData == null)
     {
         foreach (ItemStack s in miscInventory)
         {
             if (s.item == stack.item && s.relicData == null && stack.relicData == null)
             {
                 if (s.enchants.Count == 0 && stack.enchants.Count == 0)
                 {
                     s.stackSize += stack.stackSize;
                     if (!StatisticsTracker.unlockedEnchanting.isAchieved())
                     {
                         Enchantment ench = GameRegistry.GetEnchantmentByItem(s.item);
                         if (ench != null && s.stackSize >= ench.ingredientQuantity)
                         {
                             //Debug.Log("Unlocked enchanting with " + s.getDisplayName() + "," + s.stackSize);
                             StatisticsTracker.unlockedEnchanting.setAchieved();
                             GuiManager.instance.enchantTab.GetComponent <UnityEngine.UI.Button>().interactable = true;
                         }
                     }
                     return(s.stackSize);
                 }
                 else
                 {
                     bool match = true;
                     for (int e = 0; e < s.enchants.Count && match; e++)
                     {
                         if (s.enchants.Count != stack.enchants.Count || s.enchants[e] != stack.enchants[e])
                         {
                             match = false;
                         }
                     }
                     if (match)
                     {
                         s.stackSize += stack.stackSize;
                         return(s.stackSize);
                     }
                 }
             }
         }
     }
     else
     {
         stack.addedToInvenTime = DateTime.Now;
     }
     miscInventory.Add(stack);
     miscInventory.Sort((x, y) => y.getDisplayIndex().CompareTo(x.getDisplayIndex()));
     if (miscInventory.Count(x => x.relicData != null && x.isIDedByPlayer) >= 20)
     {
         StatisticsTracker.relicHoarder.setAchieved();
     }
     return(stack.stackSize);
 }
コード例 #9
0
        public static void setupUI()
        {
            inputImg1.sprite = GuiManager.instance.gray_square;
            inputImg2.sprite = GuiManager.instance.gray_square;
            outputImg.sprite = GuiManager.instance.gray_square;
            //selectedIndustry = null;
            //selectedStack = null;
            inputStack1 = null;
            inputStack2 = null;
            outputStack = null;
            doOutput();
            int i = 0;

            /*for(i = 0; i < inventoryList1.childCount; i++) {
             *      Main.Destroy(inventoryList1.GetChild(i).gameObject);
             * }
             * for(i = 0; i < inventoryList3.childCount; i++) {
             *      Main.Destroy(inventoryList3.GetChild(i).gameObject);
             * }
             * for(i = 0; i < inventoryList3.childCount; i++) {
             *      Main.Destroy(inventoryList3.GetChild(i).gameObject);
             * }
             * i = 0;*/
            List <ItemStack> toRemove = new List <ItemStack>();

            foreach (ItemStack st in enchantMiscInvenList.Keys)
            {
                GameObject go;
                enchantMiscInvenList.TryGetValue(st, out go);
                if (Main.instance.player.miscInventory.Contains(st))
                {
                    if (go != null)
                    {
                        Main.Destroy(go);
                    }
                    toRemove.Add(st);
                }
            }
            foreach (ItemStack st in toRemove)
            {
                enchantMiscInvenList.Remove(st);
            }

            foreach (Industry ind in Main.instance.player.builtItems)
            {
                Industry newInd = ind;
                if (!ind.industryItem.isConsumable && ind.industryItem.canBeGivenToQuests)
                {
                    GameObject go;
                    enchantInvenList.TryGetValue(ind, out go);
                    if (go == null)
                    {
                        go = Main.Instantiate(PrefabManager.instance.INVEN_GUI_LISTITEM, inventoryList1) as GameObject;
                        //go.transform.SetParent(inventoryList1);
                        enchantInvenList.Add(newInd, go);
                    }
                    go.transform.localPosition = new Vector3(6, (i * -125) - 5, 0);
                    //ind.enchantInvenListObj = go;
                    go.name = ind.saveName;
                    go.transform.Find("Title").GetComponent <Text>().text    = Main.ToTitleCase(Localization.translateToLocal(ind.unlocalizedName));
                    go.transform.Find("Quantity").GetComponent <Text>().text = Main.AsCurrency(ind.quantityStored) + " / " + Main.AsCurrency(10000);
                    go.transform.Find("Img").GetComponent <Image>().sprite   = SpriteLoader.getSpriteForResource("items/" + ind.saveName);
                    int  req_num = 1;
                    long ty      = (long)ind.industryItem.getAllReqs();
                    //if(ind == Industries.LEATHER) {
                    //Debug.Log("All types:" + ind.industryItem.getAllReqs());
                    //}
                    bool abort = false;
                    for (int r = 1; r <= 5; r++)
                    {
                        if (ty == 0)
                        {
                            abort = true;
                        }
                        while ((ty & 1) == 0 && ty > 0)
                        {
                            req_num++;
                            ty = ty >> 1;
                            if (ty == 0)
                            {
                                abort = true;
                            }
                        }
                        if (abort)
                        {
                            go.transform.Find("Req" + r).gameObject.SetActive(false);
                        }
                        else
                        {
                            //if(ind == Industries.LEATHER) {
                            //Debug.Log("   :" + req_num);
                            //Debug.Log("   :" + ((RequirementType)(1L << req_num)));
                            //}
                            go.transform.Find("Req" + r).GetComponent <Image>().sprite = GuiManager.instance.req_icons[req_num - 1];
                            ty = ty >> 1;
                            ty = ty << 1;
                        }
                    }
                    go.GetComponent <Button>().onClick.AddListener(delegate { /*SelectItem(newInd);*/ addInput1(newInd); });
                    i++;
                }
            }
            ((RectTransform)inventoryList1).SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, i * 126 + 5);
            inventoryList1.transform.localPosition = Vector3.zero;
            i = 0;
            int j = 0;

            //TODO: if item is an enchanted thingy, needs to be in the other list, or something.
            //It definitely needs to be placable in the *other* input slot
            foreach (ItemStack stack in Main.instance.player.miscInventory)
            {
                ItemStack  s = stack;
                GameObject go;
                enchantMiscInvenList.TryGetValue(stack, out go);
                Enchantment ench = GameRegistry.GetEnchantmentByItem(stack.item);
                if (go == null)
                {
                    if (ench != null)
                    {
                        go = Main.Instantiate(PrefabManager.instance.INGRED_GUI_LISTITEM, inventoryList2) as GameObject;
                        //go.transform.SetParent(inventoryList2);
                        enchantMiscInvenList.Add(s, go);
                    }
                    else
                    {
                        if (s.relicData != null && !s.isIDedByPlayer)
                        {
                            continue;
                        }
                        //Debug.Log(s.getDisplayName() + ":" + (s.relicData == null ? 0 : s.relicData.Count));
                        go = Main.Instantiate(PrefabManager.instance.INVEN_GUI_LISTITEM, inventoryList3) as GameObject;
                        //go.transform.SetParent(inventoryList2);
                        enchantMiscInvenList.Add(s, go);
                    }
                }
                //UnityEngine.Debug.Log(stack.getDisplayName() + ": " +new Vector3(6, (j * -125) - 5, 0));
                go.transform.localPosition = new Vector3(6, (j * -125) - 5, 0);
                //ind.invenListObj = go;
                go.name = stack.item.name;
                go.transform.Find("Title").GetComponent <Text>().text  = Main.ToTitleCase(stack.getDisplayName());
                go.transform.Find("Img").GetComponent <Image>().sprite = SpriteLoader.getSpriteForResource("items/" + stack.item.name);

                int  req_num = 1;
                long ty      = (long)stack.getAllReqs();
                bool abort   = false;
                if (ench != null)
                {
                    ty |= (long)ench.reqTypes;
                    go.transform.Find("Quantity").GetComponent <Text>().text = Main.AsCurrency(stack.stackSize) + " / " + ench.ingredientQuantity;
                    go.GetComponent <Button>().onClick.AddListener(delegate { addInput2(s); });
                    int slot = (int)ench.enchantSlotRestriction;

                    for (int r = 1; r <= 5; r++)
                    {
                        if (slot == 0)
                        {
                            abort = true;
                        }
                        while ((slot & 1) == 0 && slot > 0)
                        {
                            req_num++;
                            slot = slot >> 1;
                            if (slot == 0)
                            {
                                abort = true;
                            }
                        }
                        if (abort)
                        {
                            go.transform.Find("Equip" + r).gameObject.SetActive(false);
                        }
                        else
                        {
                            go.transform.Find("Equip" + r).GetComponent <Image>().sprite = GuiManager.instance.equip_icons[req_num - 1];
                            slot = slot >> 1;
                            slot = slot << 1;
                        }
                    }
                }
                else
                {
                    go.transform.Find("Quantity").GetComponent <Text>().text = Main.AsCurrency(stack.stackSize);
                    if ((stack.enchants.Count > 0 || stack.relicData != null) && stack.isIDedByPlayer)
                    {
                        //go.transform.SetParent(inventoryList3);
                        go.transform.localPosition = new Vector3(6, (i * -125) - 5, 0);
                        go.GetComponent <Button>().onClick.AddListener(delegate { /*SelectItem(s);*/ addInput1(s); });
                        i++;
                        j--;
                    }
                    else
                    {
                        j--;
                        enchantMiscInvenList.Remove(stack);
                        Main.Destroy(go);
                    }
                }
                //Debug.Log(stack.getDisplayName() + ":" + (quests.requirement.RequirementType)ty);
                abort   = false;
                req_num = 1;
                for (int r = 1; r <= 5; r++)
                {
                    if (ty == 0)
                    {
                        abort = true;
                    }
                    while ((ty & 1) == 0 && ty > 0)
                    {
                        req_num++;
                        ty = ty >> 1;
                        if (ty == 0)
                        {
                            abort = true;
                        }
                    }
                    if (abort)
                    {
                        go.transform.Find("Req" + r).gameObject.SetActive(false);
                    }
                    else
                    {
                        go.transform.Find("Req" + r).GetComponent <Image>().sprite = GuiManager.instance.req_icons[req_num - 1];
                        ty = ty >> 1;
                        ty = ty << 1;
                    }
                }

                j++;
            }
            FieldInfo[] allEnchants = typeof(Enchantments).GetFields();
            foreach (FieldInfo enchField in allEnchants)
            {
                Enchantment enchant = (Enchantment)enchField.GetValue(null);
                if (enchant.ingredient.industry != null && enchant.ingredient.industry.level > 0)
                {
                    int       v     = (enchant.ingredient.industry.quantityStored > int.MaxValue ? 999999999 : BigInteger.ToInt32(enchant.ingredient.industry.quantityStored));
                    ItemStack stack = new ItemStack(enchant.ingredient.industry, v);

                    GameObject go;
                    enchantIngredList.TryGetValue(enchant.ingredient.industry, out go);
                    if (go == null)
                    {
                        go = Main.Instantiate(PrefabManager.instance.INGRED_GUI_LISTITEM, inventoryList2) as GameObject;
                        //go.transform.SetParent(inventoryList2);
                        enchantIngredList.Add(enchant.ingredient.industry, go);
                    }
                    go.transform.localPosition = new Vector3(6, (j * -125) - 5, 0);
                    //ind.invenListObj = go;
                    go.name = stack.item.name;
                    go.transform.Find("Title").GetComponent <Text>().text  = Main.ToTitleCase(stack.getDisplayName());
                    go.transform.Find("Img").GetComponent <Image>().sprite = SpriteLoader.getSpriteForResource("items/" + stack.item.name);
                    Enchantment ench    = GameRegistry.GetEnchantmentByItem(stack.item);
                    int         req_num = 1;
                    long        ty      = (long)ench.reqTypes;
                    go.transform.Find("Quantity").GetComponent <Text>().text = Main.AsCurrency(stack.stackSize) + " / " + ench.ingredientQuantity;

                    go.GetComponent <Button>().onClick.AddListener(delegate { /*SelectItem(s);*/ addInput2(stack); });

                    //Debug.Log(stack.getDisplayName() + ":" + (quests.requirement.RequirementType)ty);
                    bool abort = false;
                    for (int r = 1; r <= 5; r++)
                    {
                        if (ty == 0)
                        {
                            abort = true;
                        }
                        while ((ty & 1) == 0 && ty > 0)
                        {
                            req_num++;
                            ty = ty >> 1;
                            if (ty == 0)
                            {
                                abort = true;
                            }
                        }
                        if (abort)
                        {
                            go.transform.Find("Req" + r).gameObject.SetActive(false);
                        }
                        else
                        {
                            go.transform.Find("Req" + r).GetComponent <Image>().sprite = GuiManager.instance.req_icons[req_num - 1];
                            ty = ty >> 1;
                            ty = ty << 1;
                        }
                    }

                    int slot = (int)ench.enchantSlotRestriction;
                    abort   = false;
                    req_num = 1;
                    for (int r = 1; r <= 5; r++)
                    {
                        if (slot == 0)
                        {
                            abort = true;
                        }
                        while ((slot & 1) == 0 && slot > 0)
                        {
                            req_num++;
                            slot = slot >> 1;
                            if (slot == 0)
                            {
                                abort = true;
                            }
                        }
                        if (abort)
                        {
                            go.transform.Find("Equip" + r).gameObject.SetActive(false);
                        }
                        else
                        {
                            go.transform.Find("Equip" + r).GetComponent <Image>().sprite = GuiManager.instance.equip_icons[req_num - 1];
                            slot = slot >> 1;
                            slot = slot << 1;
                        }
                    }

                    j++;
                }
            }

            ((RectTransform)inventoryList2).SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, j * 126 + 5);
            inventoryList2.transform.localPosition = Vector3.zero;
            ((RectTransform)inventoryList3).SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, i * 126 + 5);
            inventoryList1.transform.localPosition = Vector3.zero;

            sortIngredientList();
        }
コード例 #10
0
        private static void doOutput()
        {
            if (inputStack1 != null && inputStack2 != null)
            {
                Enchantment ench = GameRegistry.GetEnchantmentByItem(preSelectedStack.item);
                //Debug.Log(inputStack1.item.name + "[" + inputStack1.enchants.Count + "], " + inputStack2.item.name + " → " + (ench!=null? ench.name:"null"));
                if (inputStack1.enchants.Count > 0)
                {
                    bool maxed = false;
                    if (inputStack1.enchants.Contains(ench))
                    {
                        int count = 0;
                        foreach (Enchantment ench1 in inputStack1.enchants)
                        {
                            if (ench1 == ench)
                            {
                                count++;
                            }
                        }
                        maxed = count >= ench.maxConcurrent;
                    }
                    if ((maxed || inputStack1.relicData == null || inputStack1.relicData.Count < inputStack1.enchants.Count) || !((inputStack1.item.equipType & ench.enchantSlotRestriction) > 0))
                    {
                        outputImg.sprite = GuiManager.instance.gray_square;
                        outputImg.color  = Color.white;
                        outputStack      = null;
                        outputName.text  = "";
                    }
                    else if (inputStack2.stackSize <= preSelectedStack.stackSize)
                    {
                        outputStack           = inputStack1.clone();
                        outputStack.stackSize = 1;
                        outputStack.applyEnchantment(ench);
                        outputName.text = outputStack.getDisplayName();
                        if (outputStack.relicData != null)
                        {
                            outputName.text = ench.name + " " + outputName.text;
                        }
                        outputImg.sprite = inputImg1.sprite;
                    }
                    else
                    {
                        outputStack           = inputStack1.clone();
                        outputStack.stackSize = 1;
                        outputStack.applyEnchantment(ench);
                        outputName.text = outputStack.getDisplayName();
                        if (outputStack.relicData != null)
                        {
                            outputName.text = ench.name + " " + outputName.text;
                        }
                        outputImg.sprite = inputImg1.sprite;
                        outputImg.color  = Color.red;
                    }
                }
                else if ((inputStack1.item.equipType & ench.enchantSlotRestriction) > 0)
                {
                    outputStack           = inputStack1.clone();
                    outputStack.stackSize = 1;
                    outputStack.applyEnchantment(ench);
                    outputName.text = outputStack.getDisplayName();
                    if (outputStack.relicData != null)
                    {
                        outputName.text = ench.name + " " + outputName.text;
                    }
                    outputImg.sprite = inputImg1.sprite;
                    if (preSelectedIndustry != null)
                    {
                        //Debug.Log(inputStack1.stackSize + " <= " + preSelectedIndustry.quantityStored);
                        //Debug.Log(inputStack2.stackSize + " <= " + preSelectedStack.stackSize);
                        if (inputStack1.stackSize <= preSelectedIndustry.quantityStored && inputStack2.stackSize <= preSelectedStack.stackSize)
                        {
                            //Debug.Log(inputStack1.stackSize +" >= "+ preSelectedIndustry.quantityStored + " && " + inputStack2.stackSize + " >= " + preSelectedStack.stackSize);
                            outputImg.color = Color.white;
                        }
                        else
                        {
                            outputImg.color = Color.red;
                        }
                    }

                    if (inputStack2.stackSize <= preSelectedStack.stackSize)
                    {
                        outputImg.color = Color.white;
                    }
                    else
                    {
                        outputImg.color = Color.red;
                    }
                }
                else
                {
                    outputImg.sprite = GuiManager.instance.gray_square;
                    outputImg.color  = Color.white;
                    outputStack      = null;
                    outputName.text  = "";
                }
            }
            else
            {
                outputImg.sprite = GuiManager.instance.gray_square;
                outputImg.color  = Color.white;
                outputStack      = null;
                outputName.text  = "";
            }
            if (inputStack1 != null)
            {
                FilterEnchantIngredients((int)inputStack1.item.equipType);
            }
            else if (inputStack2 != null)
            {
                Enchantment ench = GameRegistry.GetEnchantmentByItem(preSelectedStack.item);
                FilterEnchantables((int)ench.enchantSlotRestriction);
            }
            else
            {
                FilterEnchantIngredients(-1);
                FilterEnchantables(-1);
            }
        }