Example #1
0
    public void AddStartJar()
    {
        List <StoreObjectReference> containerObjects = db.GetProducts(StoreObjectReference.productType.container);
        GameObject jar       = Instantiate(containerObjects[1].gameObject_);
        ProductGO  productGO = jar.GetComponent <ProductGO>();

        productGO.objectID = containerObjects[1].objectID;
        StorageJar storageJar = new StorageJar(containerObjects[1], jar);

        storageJar.uniqueID              = Dispensary.GetUniqueProductID();
        storageJar.objectID              = containerObjects[1].objectID;
        productGO.product                = storageJar;
        productGO.canHighlight           = true;
        jar.GetComponent <Jar>().product = storageJar;
        List <Bud> toAdd = new List <Bud>();
        Strain     toUse = db.GetRandomStrain();

        for (int i = 0; i < 28; i++)
        {
            GameObject bud    = new GameObject("Bud");
            Bud        newBud = bud.AddComponent <Bud>();
            newBud.strain = toUse;
            newBud.weight = UnityEngine.Random.Range(.65f, 1.35f);
            newBud.weight = Mathf.Round(newBud.weight * 100f) / 100f; // Round to 2 decimal places
            jar.GetComponent <Jar>().AddBud(bud);
            bud.transform.position = Vector3.zero;
            toAdd.Add(newBud);
        }
        storageJar.AddBud(toAdd);
        ShelfPosition jarPosition = dm.dispensary.Storage_cs[0].GetRandomStorageLocation(storageJar);

        jar.transform.position = jarPosition.transform.position;
        jar.transform.parent   = jarPosition.transform;
        jarPosition.shelf.parentShelf.AddProduct(storageJar);
    }
Example #2
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);
    }
Example #3
0
 public ShelfPosition GetRandomStorageLocation(Product product) // the parameter is used to narrow the possible locations
 {
     try
     {
         List <StoreObjectFunction_DisplayShelf> storageShelves = GetStorageShelves();
         List <ShelfPosition> starterPositions = new List <ShelfPosition>();
         if (storageShelves.Count > 0)
         {
             foreach (StoreObjectFunction_DisplayShelf displayShelf in storageShelves)
             {
                 if (displayShelf.shelves.Count > 0)
                 {
                     foreach (Shelf shelf_ in displayShelf.shelves)
                     {
                         if (shelf_.starterPositions.Count > 0)
                         {
                             foreach (ShelfPosition starterPosition in shelf_.starterPositions)
                             {
                                 starterPosition.shelf = shelf_;
                                 starterPositions.Add(starterPosition);
                             }
                         }
                     }
                 }
             }
             int           randomPosition = UnityEngine.Random.Range(0, starterPositions.Count - 1);
             ShelfPosition shelfPosition  = starterPositions[randomPosition];
             Shelf         shelf          = shelfPosition.shelf;
             ProductGO     productGO      = product.productGO.GetComponent <ProductGO>();
             if (shelf.Fits(productGO, shelfPosition.transform.position))
             {
                 return(shelfPosition);
             }
             else
             {
                 return(GetRandomStorageLocation(product));
             }
         }
         else
         {
             dm.notificationManager.AddToQueue("No storage shelves", NotificationManager.NotificationType.problem);
             return(null);
         }
     }
     catch (NullReferenceException)
     {
         dm.notificationManager.AddToQueue("No storage positions", NotificationManager.NotificationType.problem);
         return(null);
     }
 }
Example #4
0
    public ShelfPosition GetRandomPosition(ProductGO product)
    {
        if (presetPositions.Count > 0)
        {
            int           rand           = UnityEngine.Random.Range(0, presetPositions.Count);
            ShelfPosition randomPosition = presetPositions[rand];
            Shelf         shelf          = GetShelf(randomPosition.shelfLayer);
            if (shelf.Fits(product, randomPosition.transform.position))
            {
                return(randomPosition);
            }
            else
            {
                GetRandomPosition(product);
            }
        }
        return(null);

        /*
         * if (shelf.Fits())*/
    }