示例#1
0
    //show item at model(preview)
    private void OnItemPressed(GameObject item)
    {
        var itemCFG = item.GetComponent <ItemDisplay>().itemConfig;

        activeVariant = previewingClothesConfig?.GetActiveVariant(itemCFG);

        GetComponent <SkinsManager>().PutOnItem(itemCFG, activeVariant);

        /*
         * var bodyPart = transform.Find(itemCFG.bodyPart.ToString());
         * previewingBodyPart = bodyPart.GetComponent<SkinnedMeshRenderer>();
         * previewingBodyPart.sharedMesh = itemCFG.mesh;
         *
         * previewingBodyPart.material.color = previewingClothesConfig.ItemIsInConfig(itemCFG) == true ?
         * previewingClothesConfig.GetActiveVariant(itemCFG).color :  itemCFG.variants[0].color;
         */
        itemPreviewing = itemCFG;
    }
示例#2
0
    public void PutOnClothes(ClothesConfig config)
    {
        //PUT ON CLOTHES FROM CONFIG
        if (config != null)
        {
            foreach (string dirtyPair in config.pickedItemsAndVariants)
            {
                string[] strs = dirtyPair.Split('+');
                var      item = ScriptableList <ItemConfig> .instance.GetItemByID(strs[0]);

                if (item != null)
                {
                    PutOnItem(item, config.GetActiveVariant(item));
                }
            }
        }

        if (photon != null && photon.IsMine && photon.Owner != null)
        {
            ExitGames.Client.Photon.Hashtable customProperties = new ExitGames.Client.Photon.Hashtable();
            customProperties.Add("skin" + _gameMode.ToString(), JsonConvert.SerializeObject(config));
            photon.Owner.SetCustomProperties(customProperties);
        }
    }
示例#3
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>());
    }