public Product_s(Product.type_ type, int productObjectID_, int productSubID_, string productName_) { // For boxed products productName = productName_; productType = type; productObjectID = productObjectID_; productSubID = productSubID_; }
public void SetupDesired() { // The outcomes of the first number generators affects the outcome of later ones (ex. chance for bongs goes down if theres already a desired bong, although it is possible to desire 2 bongs) smokeLounge = (UnityEngine.Random.value < .15) ? true : false; float wantWeed = UnityEngine.Random.value; if (wantWeed > .225f) // 22.5% chance to not want to buy weed { Strain desiredStrain = db.GetRandomStrain(); // If the strain they want is high thc content, they might want less of it DesiredStrain desiredStrainReference = new DesiredStrain(desiredStrain); desiredStrains.Add(desiredStrainReference); } bool extras = (UnityEngine.Random.value < .5) ? true : false; // If they decide to get extras, they might want less weed if (extras) { int randMax = UnityEngine.Random.Range(1, 6); int rand = UnityEngine.Random.Range(1, randMax); for (int i = 0; i < rand; i++) { Product.type_ random = Product.GetRandomType(); Product desiredProduct = null; switch (random) { case Product.type_.rollingPaper: desiredProduct = new DesiredPaper(); break; case Product.type_.glassBong: case Product.type_.acrylicBong: desiredProduct = new DesiredGlass(random); break; case Product.type_.glassPipe: case Product.type_.acrylicPipe: desiredProduct = new DesiredGlass(random); break; case Product.type_.edible: desiredProduct = new DesiredEdible(); break; case Product.type_.bowl: //desiredProduct = new DesiredBowl(); break; } if (desiredProduct != null) { //print(desiredProduct.GetName()); desiredProducts.Add(desiredProduct); } } } }
public Product_s(Product.type_ type, int uniqueID_, int productObjectID_, int productSubID_, string productName_, Vector3 productPos, Vector3 productEuler) { productName = productName_; uniqueID = uniqueID_; productObjectID = productObjectID_; productSubID = productSubID_; productType = type; posX = productPos.x; posY = productPos.y; posZ = productPos.z; rotX = productEuler.x; rotY = productEuler.y; rotZ = productEuler.z; }
public CategorySubType GetSubType(Product.type_ typeIn) { foreach (Category category in categories) { foreach (CategorySubType subType in category.subCategories) { if (subType.productType == typeIn) { return(subType); } } } return(null); }
public VisibleState visibleState; // cant be mixed. if read as mixed, will override to visible public CategorySubType(Product.type_ type) { // Startup constructor, default settings productType = type; visibleState = VisibleState.notVisible; }
public List <CategoryDisplayObject> CreateProductCategoriesList(Inventory.ProductCategoryVisibleData visibleData) { scrollbar.value = 1; List <CategoryDisplayObject> newList = new List <CategoryDisplayObject>(); List <Product.ProductCategory> categories = Product.GetProductCategories(); int counter = 0; Vector2 previousContentPanelSize = Vector2.zero; Vector2 previousPos = Vector2.zero; float previousCategoryObjectHeight = 0; foreach (Product.ProductCategory category in categories) { List <Product.type_> categoryTypes = Product.GetProductsInCategory(category); Inventory.ProductCategoryVisibleData.Category categoryData = visibleData.GetCategory(category); // Create category panel CategoryDisplayObject categoryDisplayObject = Instantiate(categoryPrefab); categoryDisplayObject.categoryReference = categoryData; categoryDisplayObject.parentPanel = inventoryUIPanel; categoryDisplayObject.gameObject.SetActive(true); categoryDisplayObject.transform.SetParent(contentPanel.transform.parent, false); categoryDisplayObject.titlePanel.SetText(category.ToString()); categoryDisplayObject.SetVisibility(categoryData.visibleState, true); // Size new panel float titlePanelHeight = categoryDisplayObject.titlePanel.mainImage.rectTransform.rect.height; float titlePanelWidth = categoryDisplayObject.titlePanel.mainImage.rectTransform.rect.width; float subItemHeight = categoryItemPrefab.GetComponent <Image>().rectTransform.rect.height; RectTransform containerRectTransform = categoryDisplayObject.containerPanel.rectTransform; Vector2 newContainerSize = new Vector2(titlePanelWidth, subItemHeight * categoryTypes.Count); categoryDisplayObject.containerPanel.rectTransform.sizeDelta = newContainerSize; categoryDisplayObject.maskImage.rectTransform.sizeDelta = newContainerSize; Vector2 newContainerPos = new Vector2(0, -newContainerSize.y / 2); categoryDisplayObject.containerPanel.rectTransform.anchoredPosition = newContainerPos; categoryDisplayObject.maskImage.rectTransform.anchoredPosition = newContainerPos; Vector2 newCategoryObjectPos = new Vector2(previousPos.x, previousPos.y - previousCategoryObjectHeight); if (previousContentPanelSize == Vector2.zero) { newCategoryObjectPos = Vector2.zero; } categoryDisplayObject.GetComponent <RectTransform>().anchoredPosition = newCategoryObjectPos; newList.Add(categoryDisplayObject); //Setup previous info previousPos = newCategoryObjectPos; previousCategoryObjectHeight = (titlePanelHeight + newContainerSize.y); // Resize content panel if (previousContentPanelSize == Vector2.zero) { contentPanel.rectTransform.sizeDelta = new Vector2(titlePanelWidth, previousCategoryObjectHeight); } else { contentPanel.rectTransform.sizeDelta = new Vector2(previousContentPanelSize.x, previousContentPanelSize.y + previousCategoryObjectHeight); } previousContentPanelSize = contentPanel.rectTransform.sizeDelta; // Create sub panels for (int i = 0; i < categoryTypes.Count; i++) { Product.type_ type = categoryTypes[i]; Inventory.ProductCategoryVisibleData.CategorySubType subData = visibleData.GetSubType(type); // Create product types inside category panel CategoryDisplayItem categoryDisplayItem = Instantiate(categoryItemPrefab); categoryDisplayItem.categorySubTypeReference = subData; categoryDisplayItem.parentDisplayObject = categoryDisplayObject; categoryDisplayItem.textString = Product.ProductTypeToString(type, true); categoryDisplayItem.gameObject.SetActive(true); categoryDisplayItem.transform.SetParent(categoryDisplayObject.maskImage.transform, false); categoryDisplayItem.typeText.text = categoryDisplayItem.textString; categoryDisplayItem.SetVisibility(subData.visibleState, false); RectTransform categoryDisplayItemRectTransform = categoryDisplayItem.GetComponent <RectTransform>(); Vector2 newPos = new Vector2(0, (-i * subItemHeight) - subItemHeight / 2); categoryDisplayItemRectTransform.anchoredPosition = newPos; categoryDisplayObject.displayedItems.Add(categoryDisplayItem); categoryDisplayItem.transform.SetParent(categoryDisplayObject.maskImage.transform, true); categoryDisplayItemRectTransform.sizeDelta = new Vector2(titlePanelWidth, subItemHeight); } if (categoryData.collapsed) { //categoryDisplayObject.Collapse(); //previousContentPanelSize = new Vector2(titlePanelWidth, titlePanelHeight); } // Increase category object counter counter++; } foreach (CategoryDisplayObject obj in newList) { obj.transform.SetParent(contentPanel.transform, true); } return(newList); }