Beispiel #1
0
    public BoxProductReturnResults BoxPackagedProduct(Order.Order_Product productOrder)
    {
        int singleWeight       = productOrder.GetProduct().boxWeight;
        int productOrderWeight = productOrder.GetQuantity() * singleWeight;
        Box currentBox         = CreateBox(productOrderWeight);

        Box.PackagedProduct newPackagedProduct = new Box.PackagedProduct(currentBox, productOrder.GetProduct(), productOrder.GetQuantity());
        //currentBox.AddProduct(newPackagedProduct);
        float randomRed   = UnityEngine.Random.value;
        float randomGreen = UnityEngine.Random.value;
        float randomBlue  = UnityEngine.Random.value;

        if (productOrderWeight > currentBox.maxWeight)
        {
            int difference = currentBox.maxWeight - productOrderWeight;
            int val        = difference / singleWeight;
            val = Mathf.Abs(val);

            Order.Order_Product leftoverOrder = new Order.Order_Product(val, newPackagedProduct.productReference);
            newPackagedProduct.quantity -= val;
            currentBox.AddProduct(newPackagedProduct);
            return(new BoxProductReturnResults(currentBox, leftoverOrder));
        }
        else
        {
            currentBox.AddProduct(newPackagedProduct);
            return(new BoxProductReturnResults(currentBox, null));
        }
    }
Beispiel #2
0
 public void ProductPlacedInBox(Cube cube, Box BoxToAddTo)
 {
     if (!BoxToAddTo.IsFull())
     {
         BoxToAddTo.AddProduct(cube.product);
         ResetCube(cube);
         StartPackingBox(BoxToAddTo);
     }
 }
Beispiel #3
0
    public void AddStartBox()
    {
        List <StoreObjectReference> boxModels = db.GetProducts(StoreObjectReference.productType.box);
        GameObject box       = Instantiate(boxModels[1].gameObject_);
        ProductGO  productGO = box.GetComponent <ProductGO>();

        productGO.objectID = boxModels[1].objectID;
        StorageBox storageBox = new StorageBox(boxModels[1], box);

        storageBox.uniqueID              = Dispensary.GetUniqueProductID();
        storageBox.objectID              = boxModels[1].objectID;
        productGO.product                = storageBox;
        productGO.canHighlight           = true;
        box.GetComponent <Box>().product = storageBox;
        List <Product> toAdd = new List <Product>();
        List <StoreObjectReference> bongs = db.GetProducts(StoreObjectReference.productType.glassBong);

        // Add bongs to box

        /*for (int i = 0; i < 4; i++)
         * {
         *  GameObject bongGO = Instantiate(bongs[0].gameObject_);
         *  bongGO.GetComponent<Glass>().height = 16f;
         *  ProductGO productGO_ = bongGO.GetComponent<ProductGO>();
         *  productGO_.objectID = bongs[0].objectID;
         *  Bong newBong = new Bong(bongGO);
         *  newBong.parentProduct = storageBox;
         *  newBong.objectID = bongs[0].objectID;
         *  productGO_.product = newBong;
         *  productGO_.canHighlight = false;
         *  bongGO.gameObject.SetActive(false);
         *  toAdd.Add(newBong);
         *  box.GetComponent<Box>().AddProduct(newBong);
         * }
         * storageBox.AddProducts(toAdd);*/
        Box parentBox = box.GetComponent <Box>();

        Box.PackagedProduct newPackagedProduct = new Box.PackagedProduct(parentBox, bongs[4], 8);
        parentBox.AddProduct(newPackagedProduct);

        Strain toUse = db.GetStrain("Trainwreck");

        // Temp add bud to starting box.  eventually will contain pipes, bowls, and rolling papers to start
        Box.PackagedBud newBud = new Box.PackagedBud(parentBox, toUse, 88);
        parentBox.AddBud(newBud);

        ShelfPosition boxPosition = dm.dispensary.Storage_cs[0].GetRandomStorageLocation(storageBox);

        box.transform.position = boxPosition.transform.position;
        box.transform.parent   = boxPosition.transform;
        boxPosition.shelf.parentShelf.AddProduct(storageBox);
    }