//show item at model(preview) private void OnItemPressed(GameObject item) { ObjectsPreviewing.Clear(); var itemCFG = item.GetComponent <RoomItemDisplay>().itemConfig; activeVariant = currentRoomConf?.GetActiveVariant(itemCFG); foreach (GameObject it in roomItems) { if (it.name == itemCFG.furnitureType.ToString()) { camMov.target = it.transform; ObjectsPreviewing.Add(it); if (itemCFG.mesh != null) { it.GetComponent <MeshFilter>().mesh = itemCFG.mesh; } var itemRenderer = it.GetComponent <MeshRenderer>(); itemRenderer.material = itemCFG.material; itemRenderer.material.color = currentRoomConf?.ItemIsInConfig(itemCFG) == true? currentRoomConf.GetActiveVariant(itemCFG).color : itemCFG.variants[0].color; } } itemPreviewing = itemCFG; }
private bool CheckIfItemIsActive(RoomItemConfig cfg) { RoomConfig activeClothes = SaveManager.Instance.LoadRoomSet(); if (activeClothes == null) { return(false); } if (activeClothes.ItemIsInConfig(cfg)) { return(true); } else { return(false); } }
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>()); }