Exemple #1
0
    public void SetupDesired()
    {
        // The outcomes of the first number generators affects the outcome of later ones (ex. chance for bongs goes down if theres already a desired bong, although it is possible to desire 2 bongs)
        smokeLounge = (UnityEngine.Random.value < .15) ? true : false;
        float wantWeed = UnityEngine.Random.value;

        if (wantWeed > .225f)                                            // 22.5% chance to not want to buy weed
        {
            Strain        desiredStrain          = db.GetRandomStrain(); // If the strain they want is high thc content, they might want less of it
            DesiredStrain desiredStrainReference = new DesiredStrain(desiredStrain);
            desiredStrains.Add(desiredStrainReference);
        }
        bool extras = (UnityEngine.Random.value < .5) ? true : false; // If they decide to get extras, they might want less weed

        if (extras)
        {
            int randMax = UnityEngine.Random.Range(1, 6);
            int rand    = UnityEngine.Random.Range(1, randMax);
            for (int i = 0; i < rand; i++)
            {
                Product.type_ random         = Product.GetRandomType();
                Product       desiredProduct = null;
                switch (random)
                {
                case Product.type_.rollingPaper:
                    desiredProduct = new DesiredPaper();
                    break;

                case Product.type_.glassBong:
                case Product.type_.acrylicBong:
                    desiredProduct = new DesiredGlass(random);
                    break;

                case Product.type_.glassPipe:
                case Product.type_.acrylicPipe:
                    desiredProduct = new DesiredGlass(random);
                    break;

                case Product.type_.edible:
                    desiredProduct = new DesiredEdible();
                    break;

                case Product.type_.bowl:
                    //desiredProduct = new DesiredBowl();
                    break;
                }
                if (desiredProduct != null)
                {
                    //print(desiredProduct.GetName());


                    desiredProducts.Add(desiredProduct);
                }
            }
        }
    }
Exemple #2
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);
    }