Beispiel #1
0
    public void SaveDesign()
    {
        int ind = craftingController.CraftableItems.IndexOf(currItem);

        if (displayAltPane && currItem != null)
        {
            currItem.MyCraftedItemType = CraftedItemType.REAGENT;
        }

        if (!displayAltPane || (currItem != null && (currItem.MyCraftedItemType == CraftedItemType.WEAPON || currItem.MyCraftedItemType == CraftedItemType.ARMOR)))
        {
            Transform mainItemPane = recipeCreatorTransform.Find("ContentBG/ItemTab");
            if (mainItemPane.Find("Name/Name").GetComponent <InputField>().text == "")
            {
                return;
            }

            CraftedEquipment itemRecipe = null;
            if (currItem == null)
            {
                itemRecipe = new CraftedEquipment();
            }
            else
            {
                if (currItem.MyCraftedItemType == CraftedItemType.WEAPON)
                {
                    itemRecipe = currItem as CraftedWeapon;
                }
                else if (currItem.MyCraftedItemType == CraftedItemType.ARMOR)
                {
                    itemRecipe = currItem as CraftedArmor;
                }
            }

            Dropdown dropList = mainItemPane.Find("ItemType").GetComponent <Dropdown>();
            if (dropList.GetComponent <UI_WeaponType_Controller>().displayingWeapons)
            {
                itemRecipe.MyCraftedItemType = CraftedItemType.WEAPON;
            }
            else
            {
                itemRecipe.MyCraftedItemType = CraftedItemType.ARMOR;
            }

            if (itemRecipe.MyCraftedItemType == CraftedItemType.ARMOR)
            {
                itemRecipe = new CraftedArmor();
                (itemRecipe as CraftedArmor).tarType = ArmorTypeParse(dropList.options[dropList.value].text);
            }
            else if (itemRecipe.MyCraftedItemType == CraftedItemType.WEAPON)
            {
                itemRecipe = new CraftedWeapon();
                (itemRecipe as CraftedWeapon).tarType = WeaponTypeParse(dropList.options[dropList.value].text);
            }

            itemRecipe.ItemName        = mainItemPane.Find("Name/Name").GetComponent <InputField>().text;
            itemRecipe.baseName        = mainItemPane.Find("Name/Name").GetComponent <InputField>().text;
            itemRecipe.dexterityMin    = int.Parse(mainItemPane.Find("Dexterity/Min").GetComponent <InputField>().text);
            itemRecipe.dexterityMax    = int.Parse(mainItemPane.Find("Dexterity/Max").GetComponent <InputField>().text);
            itemRecipe.mightMin        = int.Parse(mainItemPane.Find("Might/Min").GetComponent <InputField>().text);
            itemRecipe.mightMax        = int.Parse(mainItemPane.Find("Might/Max").GetComponent <InputField>().text);
            itemRecipe.intelligenceMin = int.Parse(mainItemPane.Find("Intelligence/Min").GetComponent <InputField>().text);
            itemRecipe.intelligenceMax = int.Parse(mainItemPane.Find("Intelligence/Max").GetComponent <InputField>().text);
            itemRecipe.minLevelReq     = int.Parse(mainItemPane.Find("LevelRange/Min").GetComponent <InputField>().text);
            itemRecipe.maxLevelReq     = int.Parse(mainItemPane.Find("LevelRange/Max").GetComponent <InputField>().text);
            itemRecipe.minBonusHealth  = int.Parse(mainItemPane.Find("Health/Min").GetComponent <InputField>().text);
            itemRecipe.maxBonusHealth  = int.Parse(mainItemPane.Find("Health/Max").GetComponent <InputField>().text);

            dropList = mainItemPane.Find("ProfGroup/ProfessionType").GetComponent <Dropdown>();
            itemRecipe.RequiredProfession = Player_Skills_Script.ConvertStringToSkill(dropList.options[dropList.value].text);
            if (itemRecipe.RequiredProfession == Skills.None)
            {
                print("Failed to find skill for: " + itemRecipe.ItemName);
            }
            itemRecipe.RequiredProfLevel = int.Parse(mainItemPane.Find("ProfGroup/RequiredLevel").GetComponent <InputField>().text);
            itemRecipe.RewardedExp       = int.Parse(mainItemPane.Find("ProfGroup/RewardedExp").GetComponent <InputField>().text);
            reagentController.SaveReagentList();
            itemRecipe.RequiredReagents = new List <Reagent>();
            itemRecipe.RequiredReagents = reagentController.reagentList;
            itemRecipe.perks            = activePerks;
            currItem = itemRecipe;
        }
        else if (displayAltPane || currItem.MyCraftedItemType == CraftedItemType.REAGENT)
        {
            Transform        mainItemPane = recipeCreatorTransform.Find("ReagentBG/ItemTab");
            CraftableReagent tempReagent  = new CraftableReagent();

            tempReagent.ItemName          = mainItemPane.Find("Name/Name").GetComponent <InputField>().text;
            tempReagent.RewardedExp       = int.Parse(mainItemPane.Find("ProfGroup/RewardedExp").GetComponent <InputField>().text);
            tempReagent.RequiredProfLevel = int.Parse(mainItemPane.Find("ProfGroup/RequiredLevel").GetComponent <InputField>().text);

            Dropdown dropList = mainItemPane.Find("ProfGroup/ProfessionType").GetComponent <Dropdown>();
            tempReagent.RequiredProfession = Player_Skills_Script.ConvertStringToSkill(dropList.options[dropList.value].text);

            tempReagent.SpritePath = mainItemPane.Find("SpriteIcon/InputField").GetComponent <InputField>().text;
            reagentController.availableReagents.Add(tempReagent);
            tempReagent.RequiredReagents = reagentController.reagentList;
            currItem = tempReagent;
            reagentController.SaveReagentList();
        }

        if (ind == -1)
        {
            if (currItem.MyCraftedItemType != CraftedItemType.REAGENT)
            {
                craftingController.CraftableItems.Add(currItem);
            }
            else
            {
                if (!craftingController.CraftableReagents.Contains(currItem as CraftableReagent))
                {
                    craftingController.CraftableReagents.Add(currItem as CraftableReagent);
                }
            }
        }
        else
        {
            craftingController.CraftableItems[ind] = currItem;
        }
        craftingController.SaveRecipes();
        LoadDesignList();
        ClearTemplate();
    }