public void Open(StoreObjectReference storeObjectReference) { mainPanel.gameObject.SetActive(true); currentScreenshot = storeObjectReference.objectScreenshot; screenshotImage.sprite = currentScreenshot; nameText.text = storeObjectReference.productName + " Preview"; }
public void IncreaseQuantity(StoreObjectReference product) { int quantity = 0; switch (quantityMode) { case QuantityMode.state1: quantity = 1; break; case QuantityMode.state2: quantity = 10; break; case QuantityMode.state3: quantity = 15; break; } if (quantity > 0) { currentOrder.IncreaseQuantity(product, quantity); } else { currentOrder.IncreaseQuantity(product, 1); } UpdateList(); }
// Triggers and events public void SetupMouseEnterScreenshotTrigger(EventTrigger trigger, StoreObjectReference reference, float arrowYPos) { EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerEnter; entry.callback.AddListener((eventData) => { MouseEnterScreenshot(reference, arrowYPos); }); trigger.triggers.Add(entry); }
public void DecreaseQuantity(StoreObjectReference product) { int quantity = 0; switch (quantityMode) { case QuantityMode.state1: quantity = 1; break; case QuantityMode.state2: quantity = 10; break; case QuantityMode.state3: quantity = 15; break; } currentOrder.DecreaseQuantity(product, quantity); Order.Order_Product productOrder = currentOrder.GetProduct(product); if (productOrder.GetQuantity() <= 0) { currentOrder.RemoveProduct(productOrder); } UpdateList(); }
public void CreateFloorTileList() { if (db == null) { Start(); } ClearItems(); scroll.value = 1; List <StoreObjectReference> tiles = db.GetFloorTiles(); RectTransform rectTransform = contentPanel.GetComponent <RectTransform>(); float prefabWidth = itemPrefab.gameObject.GetComponent <RectTransform>().rect.width; float contentPanelWidth = tiles.Count * prefabWidth + (prefabWidth * .5f); rectTransform.sizeDelta = new Vector2(contentPanelWidth, contentPanel.rectTransform.sizeDelta.y); for (int i = 0; i < tiles.Count; i++) { Image newItem = Instantiate(itemPrefab); newItem.gameObject.SetActive(true); Text[] textComponents = newItem.GetComponentsInChildren <Text>(); Button[] buttonComponents = newItem.GetComponentsInChildren <Button>(); Image[] imageComponents = newItem.GetComponentsInChildren <Image>(); imageComponents[1].sprite = tiles[i].objectScreenshot; textComponents[0].text = tiles[i].productName; textComponents[1].text = tiles[i].objectID.ToString(); StoreObjectReference reference = tiles[i]; buttonComponents[0].onClick.AddListener(() => dm.ReplaceFloorTile(reference.objectID)); newItem.transform.SetParent(contentPanel.transform.parent, false); newItem.rectTransform.anchoredPosition = new Vector2(prefabWidth * i, 0); displayedItems.Add(newItem); } }
public Product(StoreObjectReference reference, GameObject createdObject, type_ type__) { productReference = reference; productGO = createdObject; productType = type__; DetermineCategory(); }
public void CloseChooseContainerPanel() { GameSettings settings = db.settings; try { if (placeholder.parentProduct.currentContainer == null) { BeingMoved(true, "No Container Selected", "Press '" + settings.GetOpenChooseContainerPanel().ToLower() + "' to choose"); } else { Box.PackagedBud packagedBud = placeholder.parentProduct.GetPackagedBud(); if (packagedBud != null) { string topString = "Moving " + packagedBud.weight + "g of " + packagedBud.strain.name; StoreObjectReference container = placeholder.parentProduct.currentContainer; string bottomString = "Container - " + container.boxWeight + "g Capacity"; BeingMoved(false, topString, bottomString); } else { print("No packaged bud"); } } } catch (System.NullReferenceException) { BeingMoved(true, "No Container Selected", "Press '" + settings.GetOpenChooseContainerPanel().ToLower() + "' to choose"); } chooseContainerPanel = null; }
public StoreObjectReference GetContainer(int ID) { List <ContainerReference> newList = new List <ContainerReference>(); StoreObjectReference toReturn = null; bool useNewList = false; foreach (ContainerReference reference in containersInStorage) { if (reference.container.objectID == ID) { if (reference.quantity <= 1) { toReturn = reference.container; useNewList = true; } else if (reference.quantity > 1) { toReturn = reference.container; useNewList = false; reference.quantity--; } } else { newList.Add(reference); } } if (useNewList) { containersInStorage = newList; } return(toReturn); }
public void LoadItemIntoSlot(StoreObjectReference product) { mainImg.sprite = enabledSprite; screenshotImg.sprite = product.objectScreenshot; screenshotImg.enabled = true; item = product; }
public StoreObjectReference RemoveStoreObjectAddon(int ID, int subID) { List <StoredStoreObjectReference> newList = new List <StoredStoreObjectReference>(); StoreObjectReference toReturn = null; bool useNewList = false; foreach (StoredStoreObjectReference storeObject in storeObjectsInStorage) { if (storeObject.objectType == StoredStoreObjectReference.StoredReferenceType.addon) { if (storeObject.storeObject.objectID == ID && storeObject.storeObject.subID == subID) { if (storeObject.quantity > 1) { storeObject.quantity--; useNewList = false; } else if (storeObject.quantity <= 1) { useNewList = true; } toReturn = storeObject.storeObject; } else { newList.Add(storeObject); } } } if (useNewList) { storeObjectsInStorage = newList; } return(toReturn); }
public Product CreateProduct(StoreObjectReference container, Box.PackagedBud bud) { // Create a container and put packaged bud into it GameObject newContainer = Instantiate(container.gameObject_); newContainer.transform.position = bud.parentBox.transform.position; ProductGO productGO = newContainer.GetComponent <ProductGO>(); if (container.proType == StoreObjectReference.productType.jar) { StorageJar storageJar = new StorageJar(container, newContainer); storageJar.uniqueID = Dispensary.GetUniqueProductID(); productGO.product = storageJar; float incrementValue = 1; List <Bud> newBuds = new List <Bud>(); while (bud.weight > 0) { if (bud.weight - 1 < 0) { incrementValue = bud.weight; } GameObject budGO = new GameObject(bud.strain.name + " Nug"); budGO.transform.SetParent(newContainer.transform); budGO.transform.localPosition = Vector3.zero; Bud newBud = budGO.AddComponent <Bud>(); newBud.strain = bud.strain; newBud.weight = incrementValue; newBuds.Add(newBud); bud.weight -= incrementValue; } print("Adding buds"); storageJar.AddBud(newBuds); return(storageJar); } return(null); }
public void AddItemToOrder(StoreObjectReference newItem, int quantity) { if (orderFormPanel.currentOrder != null) { orderFormPanel.currentOrder.AddProduct(newItem, quantity); orderFormPanel.UpdateList(); } }
public void OpenPackagedBudPlacementPanel(StoreObjectReference container, Box.PackagedBud bud) { packagedBudPlacementPanel = uiManager.OpenPackagedBudPlacementPanel(bud); QuantityInputField inputField = packagedBudPlacementPanel.inputField; packagedBudPlacementPanel.confirmButton.onClick.RemoveAllListeners(); //packagedBudPlacementPanel.confirmButton.onClick.AddListener(() => productManager.ConfirmPlacement(inputField.amount)); packagedBudPlacementPanel.OnLoad(container, bud); }
public void DecreaseQuantity(StoreObjectReference product, int quantity) { for (int i = 0; i < productList.Count; i++) { if (productList[i].GetProduct().productName.Equals(product.productName)) { productList[i].DecreaseQuantity(quantity); } } }
public bool CheckAgainstList(List <StoreObjectReference> list, StoreObjectReference item) { foreach (StoreObjectReference reference in list) { if (item.objectID == reference.objectID && item.subID == reference.subID) { return(true); } } return(false); }
public Order_Product GetProduct(StoreObjectReference reference) { foreach (Order_Product product in productList) { if (product.GetProduct().productName == reference.productName) { return(product); } } return(null); }
// Callbacks public void MouseEnterScreenshot(StoreObjectReference reference, float arrowYPos) { objectSelectionPanel.screenshotViewingPanel.Open(reference); float thisHeight = gameObject.GetComponent <RectTransform>().rect.height; if (panelType == ModifierPanelType.addons) { thisHeight = thisHeight + (thisHeight / 2); } else if (panelType == ModifierPanelType.models) { thisHeight = thisHeight * 3; } objectSelectionPanel.screenshotViewingPanel.PositionArrow(arrowYPos + thisHeight); }
public int CheckAgainstList(StoreObjectReference reference) { int toReturn = -1; for (int i = 0; i < products.Count; i++) { Box.PackagedProduct packagedProduct = products[i]; if (packagedProduct.productReference.objectID == reference.objectID) { int tempIndex = i; return(tempIndex); } } return(toReturn); }
public void DisplayCurrentIndex() { if (db == null) { Start(); } if (dropdownOpen) { DropdownToggle(); } if (objectList.Count == 0) { switch (mode) { case CurrentExtrasMode.none: extrasParentPanel.gameObject.SetActive(false); return; case CurrentExtrasMode.Sub_Models: objectList = db.GetSubModels(reference.objectID, reference.subID); break; case CurrentExtrasMode.Addons: objectList = db.GetStoreObjectAddons(reference.objectID, reference.subID); break; } currentExtraIndex = 0; } if (objectList.Count > 0) { StoreObjectReference onDisplay = objectList[currentExtraIndex]; extraScreenshot.sprite = onDisplay.objectScreenshot; string toDisplay = (mode == CurrentExtrasMode.Sub_Models) ? (onDisplay.subID + 1).ToString() : (currentExtraIndex + 1).ToString(); toDisplay += "/" + ((mode == CurrentExtrasMode.Sub_Models) ? (objectList.Count + 1).ToString() : objectList.Count.ToString()); currentDisplayedText.text = onDisplay.productName; currentExtraIndexText.text = toDisplay; if (objectList.Count == 1) { previousButton.interactable = false; nextButton.interactable = false; } else { previousButton.interactable = true; nextButton.interactable = true; } } }
public bool BuildActivatedShelves() // returns false if no shelves were active { Database db = GameObject.Find("Database").GetComponent <Database>(); foreach (Shelf shelf in shelves) { Destroy(shelf.gameObject); } shelves.Clear(); bool atleastOneActivated = false; foreach (ShelfList shelfList in shelfLists) { foreach (ShelfLayoutPosition position in shelfList.shelfLayoutPositions) { if (position.editable) { position.activated = false; if (position.activated) { atleastOneActivated = true; if (position.currentShelf == string.Empty) { position.currentShelf = position.availableShelves[0]; } int index = position.defaultAvailableShelfIndex; StoreObjectReference reference = db.GetStoreObject(position.availableShelves[index]); GameObject newShelf = Instantiate(reference.gameObject_); position.shelfID = reference.objectID; position.subID = reference.subID; newShelf.transform.SetParent(position.transform); newShelf.transform.localPosition = new Vector3(0, 0, 0); Shelf shelf = newShelf.GetComponent <Shelf>(); position.shelf = shelf; shelf.shelfLayoutPosition = position; shelves.Add(shelf); } } } } if (!atleastOneActivated) { return(false); } return(true); }
public void AddStoreObjectAddon(StoreObjectReference storeObject) { bool inList = false; foreach (StoredStoreObjectReference objectReference in storeObjectsInStorage) { if (objectReference.storeObject.objectID == storeObject.objectID && objectReference.storeObject.subID == storeObject.subID) { objectReference.quantity++; inList = true; } } if (!inList) { StoredStoreObjectReference newReference = new StoredStoreObjectReference(storeObject, StoredStoreObjectReference.StoredReferenceType.addon); storeObjectsInStorage.Add(newReference); } }
public void AddContainer(StoreObjectReference container) { bool inList = false; foreach (ContainerReference reference in containersInStorage) { if (reference.container.objectID == container.objectID) { reference.quantity++; inList = true; } } if (!inList) { ContainerReference newReference = new ContainerReference(container); containersInStorage.Add(newReference); } }
public Box CreateBox(int orderWeight) { StoreObjectReference currentBoxReference = GetBox(orderWeight); GameObject newProductBox = Instantiate(currentBoxReference.gameObject_); ProductGO productGO = newProductBox.GetComponent <ProductGO>(); productGO.objectID = currentBoxReference.objectID; StorageBox storageBox = new StorageBox(currentBoxReference, newProductBox); storageBox.objectID = currentBoxReference.objectID; storageBox.uniqueID = Dispensary.GetUniqueProductID(); productGO.product = storageBox; productGO.canHighlight = true; newProductBox.GetComponent <Box>().product = storageBox; newProductBox.GetComponent <Box>().currentWeight = 0; newProductBox.GetComponent <Box>().maxWeight = currentBoxReference.boxWeight; return(newProductBox.GetComponent <Box>()); }
public void SelectContainer(int index) { if (selectedSlot != null) { //DeselectContainer(); } foreach (ContainerSlot slot in slots) { //print(slot.index + "\nParam: " + index); if (slot.index == index) { confirmButton.interactable = true; selectedSlot = slot; //selectedImage.gameObject.SetActive(true); //selectedImage.transform.SetParent(selectedSlot.transform); //selectedImage.rectTransform.anchoredPosition = Vector2.zero; //InfoPanelOnScreen(); /* * if (itemSelected != null) * { * float newMax = itemSelected.boxWeight; * inputField.NewMaximum(newMax); * confirmButton.onClick.AddListener(() => productManager.ChooseContainer(itemSelected/ *, itemToBePlaced* /)); * Text[] texts = contentInfoPanel.GetComponentsInChildren<Text>(); * texts[0].text = itemSelected.productName; * texts[1].text = itemSelected.boxWeight + "g Capacity"; * texts[2].text = 420.ToString(); * }*/ try { StoreObjectReference itemSelected = selectedSlot.item; confirmButton.onClick.RemoveAllListeners(); //confirmButton.onClick.AddListener(() => productManager.ChooseContainer(itemSelected, true)); indicator.CreateTitlePanel(false, itemSelected.productName, itemSelected.boxWeight + "g Capacity"); } catch (System.NullReferenceException) { // empty slot selected } } } }
public void LoadOrderFormPreset(OrderPreset preset) { Order newOrder = new Order(vendor, this); newOrder.orderName = preset.presetName; foreach (ProductOrder_s product_s in preset.productList) { StoreObjectReference reference = database.GetProduct(product_s.ID); newOrder.AddProduct(reference, product_s.quantity); } foreach (BudOrder_s bud_s in preset.budList) { Strain strain = database.GetStrain(bud_s.name); newOrder.AddBud(strain, bud_s.weight); } orderFormPanel.deleteOrderPresetButton.onClick.RemoveAllListeners(); orderFormPanel.deleteOrderPresetButton.onClick.AddListener(() => DeletePreset(preset)); OpenOrderForm(newOrder); }
public void AddProduct(StoreObjectReference newReference) { print("Adding reference"); int checkValue = CheckAgainstList(newReference); if (checkValue == -1) { PackagedProduct newPackagedProduct = new PackagedProduct(this, newReference, 1); newPackagedProduct.uniqueID = Dispensary.GetUniqueProductID(); products.Add(newPackagedProduct); } else if (checkValue >= 0) { products[checkValue].AddProduct(); } currentWeight += product.boxWeight; StorageBox storageBox = (StorageBox)product; storageBox.products = products; }
public void AddProduct(StoreObjectReference newProduct, int quantity) { Order_Product newOrderProduct = new Order_Product(this, quantity, newProduct); if (CheckAgainstList(newOrderProduct)) { IncreaseQuantity(newProduct, quantity); } else { try { productList.Add(newOrderProduct); } catch (System.NullReferenceException) { // Order doesnt technically exist yet, so dont add items } } }
public void CreateNewAddonsList() // panel 2 { foreach (Image img in currentNewAddonsList) { Destroy(img.gameObject); } currentNewAddonsList.Clear(); List <string> availableAddons = storeObject.modifierHandler.GetAddonsModifier().availableAddons; RectTransform rectTransform = panel2Content.GetComponent <RectTransform>(); float prefabHeight = newAddonPrefab.gameObject.GetComponent <RectTransform>().rect.height; float contentPanelHeight = availableAddons.Count * prefabHeight; rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, contentPanelHeight); for (int i = 0; i < availableAddons.Count; i++) { StoreObjectReference reference = storeObject.dm.database.GetStoreObject(availableAddons[i]); int quantity = storeObject.modifierHandler.GetAddonsModifier().inventory.GetQuantityOwned(reference.objectID, reference.subID); Image newAddonGO = Instantiate(newAddonPrefab); Image[] imgComponents = newAddonGO.GetComponentsInChildren <Image>(); imgComponents[1].sprite = reference.objectScreenshot; //Button[] buttonComponents = newVendorDisplayGO.GetComponentsInChildren<Button>(); //Vendor vendor = vendors[i]; //buttonComponents[0].onClick.AddListener(() => ViewSelection(vendor)); //buttonComponents[1].onClick.AddListener(() => HireVendor(vendor)); Text[] textComponents = newAddonGO.GetComponentsInChildren <Text>(); textComponents[0].text = reference.ToString(); textComponents[1].text = quantity.ToString() + " Owned"; textComponents[2].text = "$" + reference.price.ToString(); newAddonGO.transform.SetParent(panel2Content.transform.parent, false); newAddonGO.gameObject.SetActive(true); newAddonGO.rectTransform.anchoredPosition = new Vector2(0, -prefabHeight * i); currentNewAddonsList.Add(newAddonGO); newAddonGO.transform.SetParent(panel2Content.transform); // Event Triggers float yPos = newAddonGO.transform.position.y; EventTrigger trigger = imgComponents[1].GetComponent <EventTrigger>(); SetupMouseEnterScreenshotTrigger(trigger, reference, yPos); SetupMouseExitScreenshotTrigger(trigger); } }
public void OnSubModelClick(StoreObjectReference reference) { if (reference.subID != storeObject.subID) { StoreObject obj = objectSelectionPanel.selectedObject; objectSelectionPanel.actionManager.StartNewAction(obj, reference.subID, reference.price); } else { ActionManager.DispensaryAction currentAction = objectSelectionPanel.actionManager.currentAction; ActionManager.ChangeStoreObjectModel changeStoreObjectModelAction = (ActionManager.ChangeStoreObjectModel)currentAction; if (changeStoreObjectModelAction != null) { if (!changeStoreObjectModelAction.OriginalActive()) { objectSelectionPanel.actionManager.CancelAction(true); } } } CreateModelsList(); }
public int CheckAgainstList(StoreObjectReference reference) { int toReturn = -1; for (int i = 0; i < products.Count; i++) { PackagedProduct packagedProduct = products[i]; try { if (packagedProduct.productReference.objectID == reference.objectID) { int tempIndex = i; return(tempIndex); } } catch (NullReferenceException) { print("Something went wrong"); } } return(toReturn); }