示例#1
0
        private void Crafted_PopulateInfo(ItemLocation src)
        {
            if ((src is CraftedItem) == false)
            {
                return;
            }
            //
            CraftedItem topop = src as CraftedItem;

            //
            if (topop.Skill == null)
            {
                topop.Skill = "Unknown";
            }
            //if (topop.Level == null) { topop.Level = 0; }
            if (topop.SpellName == null)
            {
                topop.SpellName = "";
            }
            //if (topop.Bind == null) { topop.Bind = BindsOn.BoE; }
            // Points Type and Cost
            TB_Crafted_Name.Text     = topop.Skill;
            TB_Crafted_Money_1.Value = topop.Level;
            // Token Map Cost (TODO)
            TB_Crafted_Token_1.Text          = topop.SpellName;
            TB_Crafted_Token_2.SelectedIndex = (int)topop.Bind;
            //
            isChanging = false;
            Crafted_InfoChanged();
            isChanging = true;
        }
示例#2
0
    // Schritt 3--------------------------------------------------------------------------------

    public void ProcessRecipeResources()
    {
        CraftItem1UI.GetComponent <Image>().sprite            = SlotItem;
        CraftItem2UI.GetComponent <Image>().sprite            = SlotItem;
        CraftItem3UI.GetComponent <Image>().sprite            = SlotItem;
        CraftItem4UI.GetComponent <Image>().sprite            = SlotItem;
        CraftItem1UI.GetComponentsInChildren <Text>()[0].text = "0";
        CraftItem2UI.GetComponentsInChildren <Text>()[0].text = "0";
        CraftItem3UI.GetComponentsInChildren <Text>()[0].text = "0";
        CraftItem4UI.GetComponentsInChildren <Text>()[0].text = "0";


        if (Res1 != null)
        {
            Sprite Sprite1 = Resources.Load("Grau/" + Res1 + "_grey", typeof(Sprite)) as Sprite;
            CraftItem1UI.GetComponent <Image>().sprite = Sprite1;
        }
        if (Res2 != null)
        {
            Sprite Sprite2 = Resources.Load("Grau/" + Res2 + "_grey", typeof(Sprite)) as Sprite;
            CraftItem2UI.GetComponent <Image>().sprite = Sprite2;
        }
        if (Res3 != null)
        {
            Sprite Sprite3 = Resources.Load("Grau/" + Res3 + "_grey", typeof(Sprite)) as Sprite;
            CraftItem3UI.GetComponent <Image>().sprite = Sprite3;
        }
        if (Res4 != null)
        {
            Sprite Sprite4 = Resources.Load("Grau/" + Res4 + "_grey", typeof(Sprite)) as Sprite;
            CraftItem4UI.GetComponent <Image>().sprite = Sprite4;
        }
        if (rescount1 != 0)
        {
            CraftItem1UI.GetComponentsInChildren <Text>()[0].text = rescount1.ToString();
        }
        if (rescount2 != 0)
        {
            CraftItem2UI.GetComponentsInChildren <Text>()[0].text = rescount2.ToString();
        }
        if (rescount3 != 0)
        {
            CraftItem3UI.GetComponentsInChildren <Text>()[0].text = rescount3.ToString();
        }
        if (rescount4 != 0)
        {
            CraftItem4UI.GetComponentsInChildren <Text>()[0].text = rescount4.ToString();
        }
        if (description != null)
        {
            Description.GetComponent <Text>().text = description;
        }

        // Rezept dem Crafted Item zuweisen
        Sprite CraftedSprite = Resources.Load("Crafted/" + TextofButton, typeof(Sprite)) as Sprite;

        CraftedItem.gameObject.GetComponent <Image>().sprite = CraftedSprite;
        CraftedItem.GetComponentsInChildren <Text>()[0].text = readamount.ToString();
    }
示例#3
0
    public void MinusCraft()
    {
        Text readamounttxt = CraftedItem.GetComponentsInChildren <Text>()[0];

        readamount = int.Parse(readamounttxt.text);
        if (readamount > 1)
        {
            readamount--;
            SelectRecipe();
            ProcessRecipeResources();
        }
        string readamountstring = readamount.ToString();

        CraftedItem.GetComponentsInChildren <Text>()[0].text = readamountstring;
    }
示例#4
0
    void RecipeAxe()
    {
        ResourceItem1.GetComponent <Image>().sprite = Gras;
        ResourceItem2.GetComponent <Image>().sprite = Stein;
        ResourceItem3.GetComponent <Image>().sprite = Ast;
        CraftedItem.GetComponent <Image>().sprite   = Axe;
        Description.GetComponent <Text>().text      = "Mit der Axt können Bäume gefällt werden und " +
                                                      "Logs in Scheite aufgespalten werden. Zur Herstellung " +
                                                      "benötigt 1xGras,1xStein,1xAst.";



        print("Alles ist drin");
        Instantiate(Axt, new Vector3(0, 0, 0), Quaternion.identity);
        Axt.transform.SetParent(Rightarm.transform);
        Axt.transform.localPosition = new Vector3(0, 0, 0);
    }
示例#5
0
    void RecipePickaxe()
    {
        ResourceItem1.GetComponent <Image>().sprite = Gras;
        ResourceItem2.GetComponent <Image>().sprite = Stein;
        ResourceItem3.GetComponent <Image>().sprite = Ast;
        CraftedItem.GetComponent <Image>().sprite   = Axe;
        Description.GetComponent <Text>().text      = "Mit der Pickaxe können Steine abgebaut werden " +
                                                      "Zur Herstellung benötigt 1xGras,1xStein,1xAst.";



        print("Alles ist drin");
        Instantiate(Axt, new Vector3(0, 0, 0), Quaternion.identity);
        Spitzhacke.transform.SetParent(Rightarm.transform);
        Spitzhacke.transform.localPosition = new Vector3(0, 0, 0);



        print("Es fehlt was");
    }
示例#6
0
    //Add an item to the tabs
    public void AddCraftingItem(int ID)
    {
        CraftedItem item = database.FindCraftItem(ID);

        if (craftingTabs.Count > 0)
        {
            int counter = 0;
            for (int j = 0; j < craftingTabs.Count; j++)
            {
                if (craftingTabs[j].tabType == item.baseType)
                {
                    if (craftingTabs[j].items == null)
                    {
                        craftingTabs[j].items = new List <CraftedItem>();
                    }
                    craftingTabs[j].items.Add(item);
                    counter++;
                }
                if (j == craftingTabs.Count - 1 && counter == 0)
                {
                    GameObject      tempTab = Instantiate(tabPrefab) as GameObject;
                    uGUICraftingTab tab     = tempTab.AddComponent <uGUICraftingTab>();
                    tab.transform.SetParent(tabsObj.transform);
                    tab.GetComponent <RectTransform>().localScale = Vector3.one;
                    tab.tabType = item.baseType;
                    if (tab.tabType == CraftingTabType.armor)
                    {
                        tab.GetComponent <Image>().sprite = armorTab;
                    }
                    else if (tab.tabType == CraftingTabType.weapon)
                    {
                        tab.GetComponent <Image>().sprite = weaponTab;
                    }
                    craftingTabs.Add(tab);
                    tabsObj.GetComponent <RectTransform>().sizeDelta = new Vector3(tabWidth, tabHeight * craftingTabs.Count);
                }
            }
        }
    }
示例#7
0
 //Add a crafting item to the list
 public void AddCraftItem(CraftedItem item)
 {
     craftItems.Add(item);
 }
示例#8
0
 public override string ToString() => CraftedItem.ToString();
示例#9
0
 void CreateCraftedItem(CraftedItem ci)
 {
     craftedItems.Add(ci);
 }
示例#10
0
    // Use this for initialization
    void Start()
    {
        //Find the player
        player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
        //Find the inventory
        inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent <uGUIInventory>();

        craftingTabs = new List <uGUICraftingTab>();
        selectedItem = new CraftedItem();

        //Run through all the craft item IDs
        for (int i = 0; i < craftAbleItemIDs.Count; i++)
        {
            //Find the item in the item database
            CraftedItem item = database.FindCraftItem(craftAbleItemIDs[i]);
            //If there is already any crafting tabs
            if (craftingTabs.Count > 0)
            {
                int counter = 0;
                //Run through all the crafting tabs
                for (int j = 0; j < craftingTabs.Count; j++)
                {
                    //If the item base type is = to the tabtype of the crafting tab then add the item to the list
                    if (craftingTabs[j].tabType == item.baseType)
                    {
                        if (craftingTabs[j].items == null)
                        {
                            craftingTabs[j].items = new List <CraftedItem>();
                        }
                        craftingTabs[j].items.Add(item);
                        counter++;
                    }
                    //If we're at the end of the list and there's no tab with the current item type already
                    //Instantiate the tab and add the item to the list of items in the tab
                    if (j == craftingTabs.Count - 1 && counter == 0)
                    {
                        GameObject      tempTab = Instantiate(tabPrefab) as GameObject;
                        uGUICraftingTab tab     = tempTab.AddComponent <uGUICraftingTab>();
                        tab.transform.SetParent(tabsObj.transform);
                        tab.GetComponent <RectTransform>().localScale = Vector3.one;
                        tab.tabType = item.baseType;
                        if (tab.tabType == CraftingTabType.armor)
                        {
                            tab.GetComponent <Image>().sprite = armorTab;
                        }
                        else if (tab.tabType == CraftingTabType.weapon)
                        {
                            tab.GetComponent <Image>().sprite = weaponTab;
                        }
                        craftingTabs.Add(tab);
                        tabsObj.GetComponent <RectTransform>().sizeDelta = new Vector3(tabWidth, tabHeight * craftingTabs.Count);
                    }
                }
            }
            //There isn't any tabs
            //Instantiate the tab and add the item
            else
            {
                GameObject      tempTab = Instantiate(tabPrefab) as GameObject;
                uGUICraftingTab tab     = tempTab.AddComponent <uGUICraftingTab>();
                tab.transform.SetParent(tabsObj.transform);
                tab.GetComponent <RectTransform>().localScale = Vector3.one;
                tab.tabType = item.baseType;
                if (tab.tabType == CraftingTabType.armor)
                {
                    tab.GetComponent <Image>().sprite = armorTab;
                }
                else if (tab.tabType == CraftingTabType.weapon)
                {
                    tab.GetComponent <Image>().sprite = weaponTab;
                }
                craftingTabs.Add(tab);
                craftingTabs[craftingTabs.IndexOf(tab)].items = new List <CraftedItem>();
                craftingTabs[craftingTabs.IndexOf(tab)].items.Add(item);
                tabsObj.GetComponent <RectTransform>().sizeDelta =
                    new Vector3(tabWidth, tabHeight * craftingTabs.Count);
            }
        }
        //Set the current selected tab to the first instance of the tabs
        selectedTab = craftingTabs[0];

        //Set the color of all the tabs to inactive
        for (int i = 0; i < craftingTabs.Count; i++)
        {
            craftingTabs[i].GetComponent <Image>().color = tabInactiveColor;
        }
        //Set the selected tabs color to active
        selectedTab.GetComponent <Image>().color = tabActiveColor;

        //Run through all the items in the selected tab and instantiate them
        for (int i = 0; i < selectedTab.items.Count; i++)
        {
            uGUICraftingButton item = Instantiate(craftingItemPrefab) as uGUICraftingButton;
            item.transform.SetParent(scrollContent.transform);
            item.transform.localScale   = Vector3.one;
            selectedTab.items[i].button = item;
            if (!string.IsNullOrEmpty(selectedTab.items[i].ID))
            {
                item.item = database.FindCraftItem(int.Parse(selectedTab.items[i].ID));
            }

            item.transform.name = i.ToString();
        }

        //Close the crafting window
        OpenCloseWindow(false);
    }
示例#11
0
    //Change the selected crafting item
    public void ChangeCraftingItem(uGUICraftingButton item)
    {
        //Position the selected highlight on top of the selected item
        buttonHighlight.transform.position = item.transform.position;

        selectedItem = item.item;

        //Instantiate all the materials
        materialAmounts = new List <int>();
        for (int i = 0; i < item.item.materials.Count; i++)
        {
            if (materials.Count == 0)
            {
                for (int j = 0; j < item.item.materials.Count; j++)
                {
                    uGUICraftingMaterial material = Instantiate(materialPrefab) as uGUICraftingMaterial;
                    materials.Add(material);
                }
            }
        }
        //Position all the materials
        for (int j = 0; j < materials.Count; j++)
        {
            bool avaliable = false;
            materials[j].transform.SetParent(materialsListGameObject.transform);
            materials[j].transform.localScale = Vector3.one;
            materials[j].icon.sprite          = item.item.materials[j].icon;
            materials[j].item = item.item.materials[j];
            int count = 0;
            for (int k = 0; k < inventory.items.Count; k++)
            {
                if (inventory.items[k].item.itemName == item.item.materials[j].itemName)
                {
                    count += inventory.items[inventory.items[k].itemStartNumber].item.stackSize;
                }
            }
            if (count < item.item.materialRequiredAmount[j])
            {
                materials[j].text.color = Color.red;
                Stop();
                avaliable = false;
            }
            else
            {
                materials[j].text.color   = Color.white;
                acceptButton.interactable = true;
            }
            if (!avaliable)
            {
                acceptButton.interactable = false;
            }
            materials[j].text.text = count.ToString() + "/" + item.item.materialRequiredAmount[j];
            materialAmounts.Add(count / item.item.materialRequiredAmount[j]);
        }
        craftingItemImage.sprite = item.item.item.icon;
        craftingItemImage.rectTransform.sizeDelta =
            new Vector2(item.item.item.width *
                        iconSlotSize, item.item.item.height * iconSlotSize);
        selectedItemNameText.text = item.item.item.itemName;
        craftCostLabel.text       = (selectedItem.craftCost * amountToCraft).ToString();
        craftCostLabel.rectTransform.sizeDelta = new Vector2(craftCostLabel.preferredWidth, craftCostLabel.rectTransform.sizeDelta.y);
    }