コード例 #1
0
    public void addNewToList(RandomItemGenerator createdItem)
    {
        GameObject inheritedItem = Instantiate(toInstatiate);

        inheritedItem.transform.SetParent(GameObject.FindGameObjectWithTag("_inventoryList").transform, false);
        inheritedItem.transform.SetAsFirstSibling();
        inheritedItem.GetComponent <ItemManagement>().setRandomItem(createdItem);
        Color myColor = new Color();

        ColorUtility.TryParseHtmlString(createdItem.getQuality(), out myColor);
        //child.GetComponent<Image>().color = myColor;
        //inheritedItem.GetComponent<RectTransform>().anchoredPosition = new Vector3(120, -30 - 43500 / Screen.height * pickedItemList.Count, 0);
        foreach (Transform child in inheritedItem.transform)
        {
            //Debug.Log(child.name);
            switch (child.name)
            {
            case "ItemImage":
                break;

            case "GradientFrame":
                child.GetComponent <Image>().color = myColor;
                break;

            case "ItemName":
                child.GetComponent <Text>().text  = createdItem.getFullName();
                child.GetComponent <Text>().color = new Vector4(myColor.r + 0.2f, myColor.g + 0.2f, myColor.b + 0.2f, 1);
                break;

            case "ItemDesc":
                child.GetComponent <Text>().text  = createdItem.getItemTypeDescription();
                child.GetComponent <Text>().color = new Vector4(myColor.r + 0.2f, myColor.g + 0.2f, myColor.b + 0.2f, 1);
                break;

            case "ItemStrength":
                child.GetComponent <Text>().text  = string.Format("{0}", createdItem.getItemStrength());
                child.GetComponent <Text>().color = new Vector4(myColor.r + 0.2f, myColor.g + 0.2f, myColor.b + 0.2f, 1);
                break;

            default:
                break;
            }
        }
        //pickedItemList.Insert(0, inheritedItem);
        inventoryList.Insert(0, createdItem);
        //allItemsPicked.Insert(0,createdItem);
        if (transform.childCount > 9)
        {
            GetComponent <RectTransform>().sizeDelta = new Vector2(240, 60 * transform.childCount);
        }
        GameObject.FindGameObjectWithTag("_inventoryScroll").GetComponent <ScrollRect>().normalizedPosition = new Vector2(0, 1);
    }
コード例 #2
0
    public void addNewToList(RandomItemGenerator createdItem)
    {
        GameObject inheritedItem = Instantiate(pickedTemplate);

        inheritedItem.transform.SetParent(GameObject.FindGameObjectWithTag("_pickedList").transform, false);
        inheritedItem.transform.SetAsFirstSibling();
        //inheritedItem.GetComponent<RectTransform>().anchoredPosition = new Vector3(0, 5 + 20000/Screen.height * pickedItemList.Count, 0);
        Color myColor = new Color();

        ColorUtility.TryParseHtmlString(createdItem.getQuality(), out myColor);
        inheritedItem.GetComponent <Text>().color            = myColor;
        inheritedItem.GetComponent <Text>().text             = createdItem.getFullName();
        inheritedItem.GetComponentInChildren <Image>().color = myColor;
        pickedItemList.Add(inheritedItem);
        GameObject.FindGameObjectWithTag("_xpBar").GetComponent <ExperienceBarView>().addExperience(45);
    }
コード例 #3
0
 string getInfo()
 {
     return(randomItem.getFullName());
 }