Beispiel #1
0
 private static IEnumerator FillWithLiquidAfterDelay(GameObject gameObject, float delay) {
     PillBottle pillBottle = gameObject.GetComponent<PillBottle>();
     if (pillBottle.liquidPrepared) {
         yield return new WaitForSeconds(delay);
         pillBottle.fillLiquid();
     }
 }
Beispiel #2
0
 public void run(bool reverse) {
     if (!reverse) {
         Singleton<SingletonInstance>.Instance.StartCoroutine (FillWithLiquidAfterDelay(gameObject, 1f));
     } else {
         PillBottle pillBottle = gameObject.GetComponent<PillBottle>();
         pillBottle.emptyLiquid();
     }
 }
Beispiel #3
0
    private void assignProppertiesBasedOnBagContentProperties(BagContentProperties bagContentProperties)
    {
        // Assign paper material
        Material[] materials = paperMaterialObject.GetComponent <Renderer>().materials;
        materials[0] = ItsRandom.pickRandom(paperMaterials);
        paperMaterialObject.GetComponent <Renderer>().materials = materials;


        // Medicine name
        string displayName     = bagContentProperties.displayName;
        string pillName        = displayName.Substring("Bottle of \"".Length);
        string medicineNameStr = pillName.Substring(0, pillName.Length - 1);

        medicineName.text = " - " + medicineNameStr;

        // Person name
        Person person         = BagHandler.instance.currentBagInspect.bagDefinition.person;
        string patientNameStr = person.personName;

        patientName.text = patientNameStr;

        // Doctor name
        // TODO - Real logic ("real"/fake names)
        string doctorNameStr = ItsRandom.pickRandom(new List <string>()
        {
            "Nick Riviera",
            "Julius Hibbert",
            "Hannibal Lecter",
            "Saw U Apart",
            "Genital Fondler",
            "Pepper"
        });

        doctorName.text      = "Dr. " + doctorNameStr;
        doctorSignature.font = ItsRandom.pickRandom(signatureFonts);
        doctorSignature.text = doctorNameStr;

        PillBottle pillBottle = bagContentProperties.gameObject.GetComponent <PillBottle>();

        Debug.Log("Color 1: " + pillBottle.colorHalf1.ToString());
        Debug.Log("Color 2: " + pillBottle.colorHalf2.ToString());
        pillColorHalf1.color = pillBottle.colorHalf1;
        pillColorHalf2.color = pillBottle.colorHalf2;
    }
    public IEnumerator fillLiquidBottles(BagProperties bag)
    {
        bool hadAnyLiquidBottles = false;

        foreach (BagContentProperties bagContentPropertiese in bag.bagContents)
        {
            // TODO - More types to fill?
            PillBottle pillBottle = bagContentPropertiese.GetComponent <PillBottle>();
            if (!System.Object.ReferenceEquals(pillBottle, null))
            {
                bool willFillLiquid = pillBottle.fillLiquid();
                if (willFillLiquid)
                {
                    hadAnyLiquidBottles = true;
                }
            }
        }

        if (hadAnyLiquidBottles)
        {
            yield return(new WaitForSeconds(1.2f));
        }
    }
    public void assign(PillBottle pillBottle, PerRendererShaderTexture objectWithMaterial, int materialIndex,
                       GameObject pillsContainer, GameObject pillsContainerXray, GameObject liquidContainer,
                       GameObject liquidContainerXray, Material organicMaterialXray)
    {
        objectWithMaterial.texture       = texture;
        objectWithMaterial.materialIndex = materialIndex;

        // Set the name (and label - for inspect) on the pill bottle
        pillBottle.gameObject.name = "Bottle of '" + pillLabel + "'";
        pillBottle.gameObject.GetComponent <BagContentProperties>().displayName = "Bottle of '" + pillLabel + "'";

        liquid  = specifiedAsLiquid;
        amount  = specifiedAmount;
        organic = specifiedAsOrganic;

        // Random "wrongness" - pill type
        int randomType = ItsRandom.randomRange(0, 100);

        if (randomType <= FACTOR_FOR_WRONG_PILL_TYPE)
        {
            bool wrongSubstanceLiquid = ItsRandom.randomBool();
            if (wrongSubstanceLiquid && !specifiedAsLiquid)
            {
                amount = 0;
                liquid = true;
            }
            else if (wrongSubstanceLiquid && specifiedAsLiquid)
            {
                liquid = false;
            }
            else
            {
                organic = !specifiedAsOrganic;
            }
        }

        // Random "wrongness" - amount of pills
        int randomAmount = ItsRandom.randomRange(0, 100);

        if (!liquid && (randomAmount <= FACTOR_FOR_WRONG_PILL_AMOUNT || specifiedAsLiquid))
        {
            amount = ItsRandom.randomRange(1, (!specifiedAsLiquid ? specifiedAmount : RANDOM_BASE_AMOUNT_PILLS) + 3);
        }

        if (liquid)
        {
            amount = 0;
        }

        if (amount > 0)
        {
            // Decide color pair for pills
            Color[] chosenColor = organic ?
                                  new[] { ORGANIC_PILL_COLOR } :
            ItsRandom.pickRandom(NON_ORGANIC_PILL_COLORS);

            for (int i = amount; i < pillsContainer.transform.childCount; i++)
            {
                pillsContainer.transform.GetChild(i).gameObject.SetActive(false);
                pillsContainerXray.transform.GetChild(i).gameObject.SetActive(false);
            }

            // TODO - Maybe make > some < of the pills organic (if wrong that should be detected)
            for (int i = 0; i < amount; i++)
            {
                if (organic)
                {
                    Material[] organicMaterials = new [] { organicMaterialXray, organicMaterialXray };
                    // Debug.Log(pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials.Length);
                    // Debug.Log(organicMaterialXray.name);
                    // Debug.Log(pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials[0].name);
                    // Debug.Log(pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials[1].name);
                    // pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials[0] = organicMaterialXray;
                    // pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials[1] = organicMaterialXray;
                    pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent <Renderer>().materials = organicMaterials;
                    // Debug.Log(pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials[0].name);
                    // Debug.Log(pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials[1].name);
                }
                PerRendererShader[] perRendererShaders = pillsContainer.transform.GetChild(i).GetChild(0).GetComponents <PerRendererShader>();
                // Debug.Log("Colors: " + chosenColor[0].ToString() + ", " + (chosenColor.Length > 1 ? chosenColor[1] : chosenColor[0]).ToString());
                perRendererShaders[0].color   = chosenColor[0];
                perRendererShaders[1].color   = chosenColor.Length > 1 ? chosenColor[1] : chosenColor[0];
                perRendererShaders[0].enabled = true;
                perRendererShaders[1].enabled = true;

                pillBottle.colorHalf1 = chosenColor[0];
                pillBottle.colorHalf2 = chosenColor.Length > 1 ? chosenColor[1] : chosenColor[0];
            }

            // Remove liquid from gameObject
            GameObject.Destroy(liquidContainer);
            GameObject.Destroy(liquidContainerXray);
        }
        else
        {
            // // Show the liquid container
            // liquidContainer.SetActive(true);
            // liquidContainerXray.SetActive(true);

            // Remove pills from gameObject
            GameObject.Destroy(pillsContainer);
            GameObject.Destroy(pillsContainerXray);

            pillBottle.liquidPrepared = true;
            // // Fill bottle with liquid
            // pillBottle.fillLiquid();
        }
    }