Beispiel #1
0
 private void Start()
 {
     if (EquipmentCrafting_Controller.instance.FetchItemsForProfession(Player_Skills_Script.ConvertStringToSkill(transform.name)) == null)
     {
         GetComponent <Image>().color = new Color(.2f, .2f, .2f);
     }
 }
    // Use this for initialization
    void Awake()
    {
        if (GameObject.FindGameObjectsWithTag(transform.tag).Length > 1)
        {
            Destroy(gameObject);
            return;
        }

        EquipmentScript    = GetComponent <Player_Equipment_Script>();
        SkillsScript       = GetComponent <Player_Skills_Script>();
        InventoryScript    = GetComponent <Player_Inventory_Script>();
        ControllerScript   = GetComponent <Player_Controller_Script>();
        DetailsScript      = GetComponent <Player_Details_Script>();
        ReputationScript   = GetComponent <Player_Reputation_Script>();
        AbilitiesInterface = GameObject.Find("Interface/Abilities").GetComponent <Abilities_Interface>();
        DialogInterface    = GameObject.Find("Interface/Dialog").GetComponent <Dialog_Interface>();
    }
Beispiel #3
0
 public void PopulateItemList()
 {
     ClearItemList();
     CraftableItem[] itemArray = craftingController.FetchItemsForProfession(Player_Skills_Script.ConvertStringToSkill(selectedProfession));
     selectedItems = itemArray;
     if (itemArray != null)
     {
         for (int i = 0; i < itemArray.Length; i++)
         {
             GameObject obj = Instantiate(ItemListingPrefab, ItemListGroup.Find("Categories"), false);
             obj.GetComponent <Crafting_Select_Interface>().Ind       = i;
             obj.transform.Find("Name").GetComponent <Text>().text    = itemArray[i].ItemName;
             obj.transform.Find("Level").GetComponent <Text>().text   = itemArray[i].RequiredProfLevel.ToString();
             obj.transform.Find("Icon").GetComponent <Image>().sprite = itemArray[i].Icon;
         }
     }
 }
    // Update is called once per frame
    private void Update()
    {
        if (RecipeCrafter.IsUsingInput)
        {
            return;
        }

        if (selectedWeapon == null && setDefault)
        {
            selectedWeapon = Player_Accessor_Script.EquipmentScript.FetchItemSlot(0);
            setDefault     = false;
        }
        for (int i = 0; i < 4; i++)
        {
            Weapon temp = Player_Accessor_Script.EquipmentScript.FetchItemSlot(i);
            if (temp == null)
            {
                continue;
            }


            //Fetches the sprite for the weapon with a look-up table.
            weaponParent.transform.GetChild(i).GetComponent <Image>().sprite = temp.Icon;
        }

        if (selectedWeapon != null)
        {
            for (int j = 0; j < 4; j++)
            {
                if (selectedWeapon.SkillSet[j] != null)
                {
                    abilityParent.GetChild(j).GetComponent <Image>().sprite = selectedWeapon.SkillSet[j].skillIcon;
                }
                else
                {
                    abilityParent.GetChild(j).GetComponent <Image>().sprite = defaultIcon;
                }
            }

            List <Ability> tempList = AbilityLibrary.FetchSkillList(selectedWeapon.Type.ToString());
            if (abilitySlotParent.childCount == 0 && selectedWeapon != null)
            {
                for (int i = 0; i < tempList.Count; i++)
                {
                    GameObject temp = Instantiate(AbilitySlotPrefab, abilitySlotParent);
                }
            }

            //Sorting Abilities by level requirement
            tempList.Sort((q1, q2) => q1.SkillLevelRequirement.CompareTo(q2.SkillLevelRequirement));

            //Describing Header
            Transform skillHeader = transform.Find("Window/Header/SkillSection");
            skillHeader.Find("WeaponIcon").GetComponent <Image>().sprite = selectedWeapon.Icon;
            skillHeader.Find("Weapon").GetComponent <Text>().text        = selectedWeapon.ItemName;
            skillHeader.Find("SkillName").GetComponent <Text>().text     = selectedWeapon.SkillRequired;
            Skills skillref = Player_Skills_Script.ConvertStringToSkill(selectedWeapon.SkillRequired);
            skillHeader.Find("Level").GetComponent <Text>().text = "Lv.\n" + Player_Accessor_Script.SkillsScript.SkillDetails.skillList[skillref].maxLevel;

            for (int i = 0; i < tempList.Count; i++)
            {
                Transform cardEntry = abilitySlotParent.GetChild(i);
                cardEntry.name = tempList[i].abilityName;
                cardEntry.GetComponent <CanvasGroup>().interactable         = Player_Accessor_Script.SkillsScript.GetSkill(tempList[i].SkillRequired).currLevel >= tempList[i].SkillLevelRequirement;
                cardEntry.Find("BG/Icon").GetComponent <Image>().sprite     = tempList[i].skillIcon;
                cardEntry.Find("BG/TextBG/Text").GetComponent <Text>().text = tempList[i].abilityName;

                //Description Stuff
                cardEntry.Find("Description/TextBG/Text").GetComponent <Text>().text = tempList[i].SkillDescription;
                if (tempList[i].ModifiedByStats)
                {
                    cardEntry.Find("Description/MightScale/Might").GetComponent <Text>().text               = (tempList[i].MightRatio * 100).ToString("n1") + "%\n" + (tempList[i].MightRatio * eqRef.Might).ToString("n1");
                    cardEntry.Find("Description/DexterityScale/Dexterity").GetComponent <Text>().text       = (tempList[i].DexterityRatio * 100).ToString("n1") + "%\n" + (tempList[i].DexterityRatio * eqRef.Dexterity).ToString("n1");
                    cardEntry.Find("Description/IntelligenceScale/Intelligence").GetComponent <Text>().text = (tempList[i].IntelligenceRatio * 100).ToString("n1") + "%\n" + (tempList[i].IntelligenceRatio * eqRef.Intelligence).ToString("n1");
                }
                else
                {
                    cardEntry.Find("Description/MightScale/Might").GetComponent <Text>().text               = "N/A";
                    cardEntry.Find("Description/DexterityScale/Dexterity").GetComponent <Text>().text       = "N/A";
                    cardEntry.Find("Description/IntelligenceScale/Intelligence").GetComponent <Text>().text = "N/A";
                }
                cardEntry.Find("Description/LevelReq/Text").GetComponent <Text>().text = "Lv.\n" + tempList[i].SkillLevelRequirement;
            }
        }
        else
        {
            for (int j = 0; j < 4; j++)
            {
                abilityParent.GetChild(j).GetComponent <Image>().sprite = defaultIcon;
            }
        }

        if (ind != prevInd)
        {
            selectedWeapon = Player_Accessor_Script.EquipmentScript.FetchItemSlot(ind);
            //for (int i = 0; i < abilitySlotParent.childCount; i++)
            while (abilitySlotParent.childCount > 0)
            {
                DestroyImmediate(abilitySlotParent.GetChild(0).gameObject);
            }

            if (selectedWeapon != null)
            {
                List <Ability> tempList = AbilityLibrary.FetchSkillList(selectedWeapon.Type.ToString());
                for (int i = 0; i < tempList.Count; i++)
                {
                    GameObject temp = Instantiate(AbilitySlotPrefab, abilitySlotParent);
                }
            }
            prevInd = ind;
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            canvas.alpha          = 0;
            canvas.blocksRaycasts = false;
            canvas.interactable   = false;
        }

        if (Input.GetKeyDown(KeybindManager.Keybinds[KeybindFunction.I_WEAPON_ABILITIES]))
        {
            canvas.alpha = Mathf.Abs(canvas.alpha - 1);
            if (canvas.alpha == 1)
            {
                Interface_Controller.instance.InterfaceEvents["AbilityInterfaceOpen"].Invoke();
            }
            canvas.interactable   = !canvas.interactable;
            canvas.blocksRaycasts = !canvas.blocksRaycasts;
        }
    }
Beispiel #5
0
 private void Start()
 {
     levelRef   = GameObject.FindGameObjectWithTag("Player").GetComponent <Player_Skills_Script>();
     levelGroup = transform.parent.GetComponent <CanvasGroup>();
     PopulateInterface();
 }
Beispiel #6
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();
    }
Beispiel #7
0
    public void LoadSelectedItem(CraftableItem itemRef)
    {
        if (itemRef != null)
        {
            CraftedEquipment equipRef;
            Transform        mainItemPane = recipeCreatorTransform.Find("ContentBG/ItemTab");
            if (itemRef.MyCraftedItemType == CraftedItemType.ARMOR)
            {
                PopulateEquipmentList();
            }
            else if (itemRef.MyCraftedItemType == CraftedItemType.WEAPON)
            {
                PopulateWeaponList();
            }
            else if (itemRef.MyCraftedItemType == CraftedItemType.REAGENT)
            {
                PopulateReagentList();
            }

            if (itemRef.MyCraftedItemType == CraftedItemType.ARMOR || itemRef.MyCraftedItemType == CraftedItemType.WEAPON)
            {
                equipRef = itemRef as CraftedEquipment;
                currItem = itemRef;
                mainItemPane.Find("Name/Name").GetComponent <InputField>().text = equipRef.baseName;
                if (itemRef.MyCraftedItemType == CraftedItemType.ARMOR || itemRef.MyCraftedItemType == CraftedItemType.WEAPON)
                {
                    mainItemPane.Find("Dexterity/Min").GetComponent <InputField>().text    = equipRef.dexterityMin.ToString();
                    mainItemPane.Find("Dexterity/Max").GetComponent <InputField>().text    = equipRef.dexterityMax.ToString();
                    mainItemPane.Find("Might/Min").GetComponent <InputField>().text        = equipRef.mightMin.ToString();
                    mainItemPane.Find("Might/Max").GetComponent <InputField>().text        = equipRef.mightMax.ToString();
                    mainItemPane.Find("Intelligence/Min").GetComponent <InputField>().text = equipRef.intelligenceMin.ToString();
                    mainItemPane.Find("Intelligence/Max").GetComponent <InputField>().text = equipRef.intelligenceMax.ToString();
                    mainItemPane.Find("LevelRange/Min").GetComponent <InputField>().text   = equipRef.minLevelReq.ToString();
                    mainItemPane.Find("LevelRange/Max").GetComponent <InputField>().text   = equipRef.maxLevelReq.ToString();
                    mainItemPane.Find("Health/Min").GetComponent <InputField>().text       = equipRef.minBonusHealth.ToString();
                    mainItemPane.Find("Health/Max").GetComponent <InputField>().text       = equipRef.maxBonusHealth.ToString();

                    mainItemPane.Find("Dexterity/Min").GetComponent <InputField>().interactable    = true;
                    mainItemPane.Find("Dexterity/Max").GetComponent <InputField>().interactable    = true;
                    mainItemPane.Find("Might/Min").GetComponent <InputField>().interactable        = true;
                    mainItemPane.Find("Might/Max").GetComponent <InputField>().interactable        = true;
                    mainItemPane.Find("Intelligence/Min").GetComponent <InputField>().interactable = true;
                    mainItemPane.Find("Intelligence/Max").GetComponent <InputField>().interactable = true;
                    mainItemPane.Find("LevelRange/Min").GetComponent <InputField>().interactable   = true;
                    mainItemPane.Find("LevelRange/Max").GetComponent <InputField>().interactable   = true;
                    mainItemPane.Find("Health/Min").GetComponent <InputField>().interactable       = true;
                    mainItemPane.Find("Health/Max").GetComponent <InputField>().interactable       = true;

                    FetchPerkList();

                    int      val    = 0;
                    Dropdown tempdd = mainItemPane.Find("ItemType").GetComponent <Dropdown>();
                    if (itemRef.MyCraftedItemType == CraftedItemType.WEAPON)
                    {
                        for (int i = 0; i < System.Enum.GetNames(typeof(WeaponType)).Length; i++)
                        {
                            if (tempdd.options[i].text.ToLower() == (itemRef as CraftedWeapon).tarType.ToString().ToLower())
                            {
                                val = i;
                                break;
                            }
                        }
                    }
                    else if (itemRef.MyCraftedItemType == CraftedItemType.ARMOR)
                    {
                        for (int i = 0; i < System.Enum.GetNames(typeof(ArmorType)).Length; i++)
                        {
                            if (tempdd.options[i].text.ToLower() == (itemRef as CraftedArmor).tarType.ToString().ToLower())
                            {
                                val = i;
                                break;
                            }
                        }
                    }
                    tempdd.value = val;

                    for (int i = 0; i < perkListTransform.childCount; i++)
                    {
                        Toggle t = perkListTransform.GetChild(i).GetComponentInChildren <Toggle>();
                        if (equipRef.perks.Contains(Perks.ConvertTextToPerk(perkListTransform.GetChild(i).GetChild(0).GetComponent <Text>().text)))
                        {
                            t.isOn = true;
                        }
                        else
                        {
                            t.isOn = false;
                        }
                    }
                    print(itemRef.ItemName);
                }
            }
            else if (itemRef.MyCraftedItemType == CraftedItemType.REAGENT)
            {
                mainItemPane = recipeCreatorTransform.Find("ReagentBG/ItemTab");
                mainItemPane.Find("Name/Name").GetComponent <InputField>().text             = itemRef.ItemName;
                mainItemPane.Find("SpriteIcon/BG/Image").GetComponent <Image>().sprite      = Resources.Load <Sprite>("ItemIcons/ResourceIcons/" + itemRef.SpritePath);
                mainItemPane.Find("SpriteIcon/InputField").GetComponent <InputField>().text = itemRef.SpritePath;
                currItem = itemRef;
            }

            Dropdown tempDD = mainItemPane.Find("ProfGroup/ProfessionType").GetComponent <Dropdown>();
            for (int i = 0; i < tempDD.options.Count; i++)
            {
                if (Player_Skills_Script.ConvertStringToSkill(tempDD.options[i].text) == itemRef.RequiredProfession)
                {
                    tempDD.value = i;
                    break;
                }
            }
            mainItemPane.Find("ProfGroup/RequiredLevel").GetComponent <InputField>().text = itemRef.RequiredProfLevel.ToString();
            mainItemPane.Find("ProfGroup/RewardedExp").GetComponent <InputField>().text   = itemRef.RewardedExp.ToString();

            reagentController.LoadReagentList();
        }
    }
Beispiel #8
0
    public void LoadDesignList()
    {
        craftingController.LoadRecipes();
        reagentController.LoadAvailableReagentList();
        for (int i = currentRecipeTransform.GetChild(0).childCount - 1; i >= 0; i--)
        {
            Destroy(currentRecipeTransform.GetChild(0).GetChild(i).gameObject);
        }
        currentRecipeTransform.GetChild(0).GetComponent <Scrollbar_Controller>().ResetBar();
        //string strRef = currentRecipeTransform.parent.Find("Profession/InputField").GetComponent<InputField>().text;
        Dropdown dd     = currentRecipeTransform.parent.Find("Profession/ProfessionType").GetComponent <Dropdown>();
        string   strRef = dd.options[dd.value].text;

        for (int i = 0; i < craftingController.CraftableItems.Count; i++)
        {
            if (craftingController.CraftableItems[i] != null && craftingController.CraftableItems[i].RequiredProfession == Player_Skills_Script.ConvertStringToSkill(strRef))
            {
                GameObject obj = Instantiate(currentRecipePrefab, currentRecipeTransform.GetChild(0), false);
                obj.transform.GetChild(0).GetComponent <Text>().text = craftingController.CraftableItems[i].ItemName;
                obj.GetComponent <RecipeReference>().itemRef         = craftingController.CraftableItems[i];
                obj.GetComponent <RecipeReference>().recipeCrafter   = this;
            }
        }

        for (int i = 0; i < craftingController.CraftableReagents.Count; i++)
        {
            if (craftingController.CraftableReagents[i] != null && craftingController.CraftableReagents[i].RequiredProfession == Player_Skills_Script.ConvertStringToSkill(strRef))
            {
                GameObject obj = Instantiate(currentRecipePrefab, currentRecipeTransform.GetChild(0), false);
                obj.transform.GetChild(0).GetComponent <Text>().text = craftingController.CraftableReagents[i].ItemName;
                obj.GetComponent <RecipeReference>().itemRef         = craftingController.CraftableReagents[i];
                obj.GetComponent <RecipeReference>().recipeCrafter   = this;
            }
        }
    }