示例#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);
    }
    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);
    }
示例#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);
    }
示例#4
0
    public void SortStack(Vector3 pos, bool activate, bool removePlaceholder)
    {
        if (uniqueID == -1)
        {
            uniqueID = Dispensary.GetUniqueProductID();
        }
        List <Box> noDuplicates = boxList.Distinct(new BoxComparer()).ToList();

        boxList = noDuplicates;
        if (activate)
        {
            ShowStack();
        }
        else
        {
            HideStack();
        }
        if (removePlaceholder)
        {
            Destroy(placeholderStack.gameObject);
        }
        boxList.Sort(SortBoxes);
        int counter = 0;

        foreach (Box box in boxList)
        {
            box.transform.SetParent(transform);
            if (counter == 0)
            {
                if (handTruck != null)
                {
                    SetStackOrigin(true);
                    transform.position          = pos;
                    box.transform.localPosition = new Vector3(0, 0, 0);
                }
                else
                {
                    SetStackOrigin(false);
                    transform.position          = pos;
                    box.transform.localPosition = new Vector3(0, 0, 0);
                }
            }
            else
            {
                box.transform.position = boxList[counter - 1].stackAttachPoint.transform.position;
            }
            counter++;
        }
    }
示例#5
0
    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>());
    }
示例#6
0
    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 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);
    }
示例#8
0
 public PackagedProduct(Box box, StoreObjectReference reference, int quantity_) : base(type_.packagedProduct, box)
 {
     productReference = reference;
     quantity         = quantity_;
     uniqueID         = Dispensary.GetUniqueProductID();
 }
示例#9
0
 public PackagedBud(Box box, Strain strain_, float weight_) : base(type_.packagedBud, box)
 {
     strain   = strain_;
     weight   = weight_;
     uniqueID = Dispensary.GetUniqueProductID();
 }