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 string GetProductInfo(Product product)
    {
        switch (product.productType)
        {
        case Product.type_.storageJar:
            StorageJar jar = (StorageJar)product;
            return("Strain: " + jar.GetStrain().name);

        case Product.type_.glassBong:
        case Product.type_.acrylicBong:
            Bong bong = (Bong)product;
            return("Height: " + bong.height);

        case Product.type_.glassPipe:
        case Product.type_.acrylicPipe:
            Pipe pipe = (Pipe)product;
            return("Length: " + pipe.length);

        case Product.type_.rollingPaper:
            RollingPaper paper = (RollingPaper)product;
            return(paper.paperType.ToString());

        case Product.type_.edible:
            Edible edible = (Edible)product;
            return(edible.edibleType.ToString());

        case Product.type_.box:
            StorageBox box = (StorageBox)product;
            return("Products: " + box.products.Count);
        }
        return("ProductType");
    }
Esempio n. 3
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);
    }
Esempio n. 4
0
 public StorageJar_s(StorageJar jar) : base(Product.type_.storageJar, jar.uniqueID, jar.objectID, jar.subID, jar.GetName(), jar.productGO.transform.position, jar.productGO.transform.eulerAngles)
 {
     strain = jar.GetStrain();
     foreach (Bud bud in jar.buds)
     {
         buds.Add(bud.MakeSerializable());
     }
 }
Esempio n. 5
0
 public Strain GetStrain()
 {
     if (product != null)
     {
         StorageJar storageJar = (StorageJar)product;
         return(storageJar.GetStrain());
     }
     return(new Strain());
 }
Esempio n. 6
0
    public float GenerateInterest(Product product)
    {
        float interestValue = 50;

        if (desiredProducts.Count > 0)
        {
            foreach (Product desiredProduct in desiredProducts)
            {
                if (product.productType == desiredProduct.referenceType)
                {
                    interestValue += 20;
                    switch (product.productType)
                    {
                    case Product.type_.glassPipe:
                    case Product.type_.acrylicPipe:
                        Pipe         pipe             = (Pipe)product;
                        DesiredGlass glassPipe        = (DesiredGlass)desiredProduct;
                        float        inspectingLength = pipe.length;
                        float        desiredLength    = glassPipe.height;
                        float        lengthDifference = Mathf.Abs(inspectingLength - desiredLength);
                        int          pipeInterest     = (int)MapValue(0, 25, 30, 0, lengthDifference); // Take a difference of 0-25 and convert it respectively to a range of 30-0
                        interestValue += pipeInterest;
                        break;

                    case Product.type_.glassBong:
                    case Product.type_.acrylicBong:
                        Bong         bong             = (Bong)product;
                        DesiredGlass glassBong        = (DesiredGlass)desiredProduct;
                        float        inspectingHeight = bong.height;
                        float        desiredHeight    = glassBong.height;
                        float        heightDifference = Mathf.Abs(inspectingHeight - desiredHeight);
                        int          bongInterest     = (int)MapValue(0, 22, 30, 0, heightDifference); // Take a difference of 0-22 and convert it respectively to a range of 30-0
                        interestValue += bongInterest;
                        break;

                    case Product.type_.edible:
                        Edible        edible        = (Edible)product;
                        DesiredEdible desiredEdible = (DesiredEdible)desiredProduct;
                        if (edible.edibleType == desiredEdible.desiredType)
                        {
                            float thcDifference  = Mathf.Abs(edible.THCpercent - desiredEdible.desiredTHC);
                            int   edibleInterest = (int)MapValue(0, 250, 30, 0, thcDifference);   // Take a difference of 0-250 and convert it respectively to a range of 30-0
                            interestValue += edibleInterest;
                        }
                        break;

                    case Product.type_.rollingPaper:
                        RollingPaper paper        = (RollingPaper)product;
                        DesiredPaper desiredPaper = (DesiredPaper)desiredProduct;
                        if (paper.paperType == desiredPaper.desiredType)
                        {
                            interestValue += 30;
                        }
                        break;
                    }
                }
            }
        }
        if (desiredStrains.Count > 0 && product.GetProductType() == Product.type_.storageJar)
        {
            interestValue += 10;
            StorageJar jar            = (StorageJar)product;
            Strain     bestMatch      = null;
            float      bestMatchValue = 50;
            foreach (DesiredStrain strain in desiredStrains)
            {
                float matchValue = StrainTypeMatch(strain.strain, jar.GetStrain());
                if (matchValue > bestMatchValue)
                {
                    bestMatch      = strain.strain;
                    bestMatchValue = matchValue;
                }
            }
            if (bestMatch != null)
            {
                int strainInterest = (int)MapValue(0, 100, 0, 40, bestMatchValue);
                interestValue += strainInterest;
            }
        }
        print(customerName + ": " + product.GetName() + " " + interestValue);
        return(interestValue);
    }
    public Product CreateProduct(StoreObjectReference toCreate, Vector3 pos)
    {
        GameObject newProductGameObject = Instantiate(toCreate.gameObject_);
        ProductGO  newProductGO         = newProductGameObject.GetComponent <ProductGO>();

        newProductGO.transform.position = pos;
        newProductGO.gameObject.SetActive(false);
        if (toCreate.color.colorIsAssigned)
        {
            newProductGameObject = ApplyColor(newProductGameObject, toCreate.color.color);
        }

        /*if (newProductGO.colorable)
         * {
         *  if (toCreate.randomColor != null)
         *  {
         *      newProductGameObject = ApplyColor(newProductGameObject, toCreate.randomColor);
         *  }
         *  else
         *  {
         *      newProductGameObject = ApplyRandomColor(newProductGameObject);
         *  }
         * }*/
        Product.type_ productType;
        switch (toCreate.proType)
        {
        case StoreObjectReference.productType.jar:
            productType = Product.type_.storageJar;
            break;

        case StoreObjectReference.productType.glassBong:
            productType = Product.type_.glassBong;
            break;

        case StoreObjectReference.productType.acrylicBong:
            productType = Product.type_.acrylicBong;
            break;

        case StoreObjectReference.productType.glassPipe:
            productType = Product.type_.glassPipe;
            break;

        case StoreObjectReference.productType.acrylicPipe:
            productType = Product.type_.acrylicPipe;
            break;

        case StoreObjectReference.productType.rollingPaper:
            productType = Product.type_.rollingPaper;
            break;

        case StoreObjectReference.productType.edible:
            productType = Product.type_.edible;
            break;

        case StoreObjectReference.productType.bowl:
            productType = Product.type_.bowl;
            break;

        case StoreObjectReference.productType.grinder:
            productType = Product.type_.grinder;
            break;

        default:
            productType = Product.type_.reference;
            break;
        }
        newProductGO.objectID = toCreate.objectID;
        switch (productType)
        {
        case Product.type_.glassBong:
        case Product.type_.acrylicBong:
            Bong newBong = new Bong(toCreate, newProductGameObject);
            newBong.uniqueID     = Dispensary.GetUniqueProductID();
            newBong.objectID     = toCreate.objectID;
            newBong.boxWeight    = toCreate.boxWeight;
            newProductGO.product = newBong;
            return(newBong);

        case Product.type_.glassPipe:
        case Product.type_.acrylicPipe:
            Pipe newPipe = new Pipe(toCreate, newProductGameObject);
            newPipe.uniqueID     = Dispensary.GetUniqueProductID();
            newPipe.objectID     = toCreate.objectID;
            newPipe.boxWeight    = toCreate.boxWeight;
            newProductGO.product = newPipe;
            return(newPipe);

        case Product.type_.storageJar:
            StorageJar newJar = new StorageJar(toCreate, newProductGameObject);
            newJar.uniqueID      = Dispensary.GetUniqueProductID();
            newJar.objectID      = toCreate.objectID;
            newJar.boxWeight     = toCreate.boxWeight;
            newProductGO.product = newJar;
            return(newJar);

        case Product.type_.bowl:
            Bowl newBowl = new Bowl(toCreate, newProductGameObject);
            newBowl.uniqueID     = Dispensary.GetUniqueProductID();
            newBowl.objectID     = toCreate.objectID;
            newBowl.boxWeight    = toCreate.boxWeight;
            newProductGO.product = newBowl;
            //newBowl = (Bowl)ApplyRandomColor(newBowl);
            return(newBowl);

        case Product.type_.grinder:
            Grinder newGrinder = new Grinder(toCreate, newProductGameObject);
            newGrinder.uniqueID  = Dispensary.GetUniqueProductID();
            newGrinder.objectID  = toCreate.objectID;
            newGrinder.boxWeight = toCreate.boxWeight;
            newProductGO.product = newGrinder;
            //newGrinder = (Grinder)ApplyRandomColor(newGrinder);
            return(newGrinder);
        }
        return(null);
    }