コード例 #1
0
    private bool CheckIfItemIsActive(ItemConfig cfg)
    {
        ClothesConfig activeClothes = SaveManager.Instance.LoadClothesSet(characterGender.ToString() + currentMode.ToString());

        if (activeClothes.ItemIsInConfig(cfg))
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #2
0
    private void DisplayItem(GameObject itemGO)
    {
        currentClothesConfig = SaveManager.Instance.LoadClothesSet(previewManager.GetCurrentKey());
        variantSlider.SetActive(true); //activate it just in case


        //display item description
        itemCFG = itemGO.GetComponent <ItemDisplay>().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, currentClothesConfig.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 (currentClothesConfig.ItemIsInConfig(itemCFG))
                {
                    hasActiveVar = currentClothesConfig.GetActiveVariant(itemCFG) == V ? true : false;
/*                    Debug.Log("Item: " + itemCFG + ", active variant :" + currentClothesConfig.GetActiveVariant(itemCFG));*/
                }
                else
                {
                    hasActiveVar = V == itemCFG.variants[0] ? true : false;
                }
                varTab.activeIMG.gameObject.SetActive(hasActiveVar);

                bool isActive = currentClothesConfig.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(currentClothesConfig.GetActiveVariant(itemCFG));
        }
        else
        {
            variantSlider.SetActive(false);
            ManipulateDisplayingInfo(itemCFG.variants[0]);
        }

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