コード例 #1
0
    private void ManipulateDisplayingInfo(ItemVariant var)
    {
        if (shopManager.CheckIfItemIsBought(itemCFG, var) /* || var.cost == 0*/)
        {
            buyButton.SetActive(false);
            itemBoughtTab.SetActive(true);
            // donebutton on
            doneButton.SetActive(true);
        }
        else
        {
            buyButton.SetActive(true);
            itemBoughtTab.SetActive(false);
            //donebutton off
            doneButton.SetActive(false);
        }



        if (currentRoomConfig.ItemAndVarIsInConfig(itemCFG, var))
        {
            doneButton.SetActive(false);
        }


        variantCostText.text = var.cost.ToString();

        variantCurrencyIMG.sprite = var.currencyType == CurrencyType.HARD ? hardCurrencySprite
            : softCurrencySprite;

        variantNameIDtext.text  = var.ConfigId;
        varDescriptionText.text = var.description;
    }
コード例 #2
0
    private void DisplayItem(GameObject itemGO)
    {
        currentRoomConfig = SaveManager.Instance.LoadRoomSet();
        variantSlider.SetActive(true); //activate it just in case


        //display item description
        itemCFG = itemGO.GetComponent <RoomItemDisplay>().itemConfig;
        rightPanel.SetActive(true);
        itemDisplaying = Instantiate(itemGO, rightPanel.transform.position, Quaternion.identity);
        itemDisplaying.transform.SetParent(parentForItem);
        itemDisplaying.GetComponent <RectTransform>().ResetTransform();
        itemDisplaying.GetComponent <RectTransform>().sizeDelta = itemDisplaySize;
        if (shopManager.CheckIfItemIsBought(itemCFG, currentRoomConfig.GetActiveVariant(itemCFG)))
        {
            buyButton.SetActive(false);
        }
        else
        {
            buyButton.SetActive(true);
        }


        //clear all variants
        var children = parentForVariants.GetComponentsInChildren <Transform>();

        foreach (Transform child in children)
        {
            if (child != parentForVariants.transform)
            {
                Destroy(child.gameObject);
            }
        }


        // spawn variants in RightSlider
        if (itemCFG.variants.Count > 1)
        {
            foreach (ItemVariant V in itemCFG.variants)
            {
                var varGroup = parentForVariants.GetComponent <VariantGroup>();
                var variant  = Instantiate(variantPrefab);
                variant.transform.SetParent(parentForVariants);
                var varTab = variant.GetComponent <VariantTab>();
                varTab.group   = varGroup;
                varTab.variant = V;
                varTab.group.Subscribe(varTab);
                varTab.tabBackground.color = V.color;
                bool hasActiveVar;
                if (currentRoomConfig.ItemIsInConfig(itemCFG))
                {
                    hasActiveVar = currentRoomConfig.GetActiveVariant(itemCFG) == V ? true : false;
/*                    Debug.Log("Item: " + itemCFG + ", active variant :" + currentRoomConfig.GetActiveVariant(itemCFG));*/
                }
                else
                {
                    hasActiveVar = V == itemCFG.variants[0] ? true : false;
                }
                varTab.activeIMG.gameObject.SetActive(hasActiveVar);

                bool isActive = currentRoomConfig.ItemAndVarIsInConfig(itemCFG, V) == true ? true : false;
                varTab.activeTick.SetActive(isActive);

                bool isBought = shopManager.CheckIfItemIsBought(itemCFG, V) /* || V.cost == 0*/ == true ? false : true;
                varTab.lockIMG.gameObject.SetActive(isBought);
            }
            ManipulateDisplayingInfo(currentRoomConfig.GetActiveVariant(itemCFG));
        }
        else
        {
            variantSlider.SetActive(false);
            ManipulateDisplayingInfo(itemCFG.variants[0]);
        }

        Destroy(itemDisplaying.GetComponent <ItemClick>());
    }