예제 #1
0
        void OnTriggerEnter(Collider other)
        {
            UCE_Chemical otherChemical = other.GetComponent <UCE_Chemical>();

            // if two chemical collide
            if (otherChemical)
            {
                List <UCE_Engine.ChemicalAmount> reactants = new List <UCE_Engine.ChemicalAmount>();
                reactants.Add(chemicalAmount);
                reactants.Add(otherChemical.chemicalAmount);

                // invoke ChemicalEngine to get reaction result
                UCE_Animation.Animation result = UCE_Engine.React(reactants);

                // use animation to perform result
                UCE_Animation.Perform(gameObject, result);
            }
        }
예제 #2
0
        public override void StartUsing(VRTK_InteractUse usingObject)
        {
            base.StartUsing(usingObject);

            if (inTube)
            {
                hasWater = true;
                newName  = tubeWaterGo.GetComponent <ShowNameOnTouch>().showName;
                type     = tubeWaterGo.GetComponent <TubeWater>().type;

                GameObject go = transform.Find("water").gameObject;
                go.SetActive(true);
                go.GetComponent <Renderer>().material = tubeWaterGo.GetComponent <Renderer>().material;
            }
            else if (hasWater)
            {
                GameObject waterGo = transform.Find("water").gameObject;
                waterGo.SetActive(false);
                hasWater = false;
                Debug.Log("hasWater");
                if (inBeaker)
                {
                    // The beakerWaterGo has to be set false and then set true again
                    // beacuase this is the only way to call UCE_Chemical.OnTriggerEnter()
                    // again to check if reaction is possible now
                    beakerWaterGo.SetActive(false);

                    UCE_Chemical chemical = beakerWaterGo.GetComponent <UCE_Chemical>();
                    chemical.chemicalAmount.type   = type;
                    chemical.chemicalAmount.amount = 1;
                    beakerWaterGo.GetComponent <Renderer>().material = waterGo.GetComponent <Renderer>().material;

                    ShowNameOnTouch snot = beakerWaterGo.GetComponent <ShowNameOnTouch>();
                    snot.ChangeName(newName);

                    beakerWaterGo.SetActive(true);
                }
                else
                {
                    transform.Find("drop").gameObject.SetActive(true);
                    Debug.Log("drop!");
                }
            }
        }