Exemple #1
0
        IEnumerator DispatchMixerEvent(List <GameObject> gameObjects)
        {
            isWaiting = true; // don't dispatch any more until we're done here (prevents repeat dispatches)

            yield return(new WaitForSeconds(1));

            // after selecting specific ids, should still be a count of two
            if (gameObjects
                .Where(x =>
                       x.gameObject.GetComponent <CloudComponent>().cId == "5bb31f90023eb3359042462e" || // aluminum chips
                       x.gameObject.GetComponent <CloudComponent>().cId == "5bb31f99023eb3359042462f")   // iron oxide powder
                .ToList().Count == 2)
            {
                // load in the thermite
                GameObject gameObject = (GameObject)Instantiate(
                    Resources.Load("Bottles/Mesh/Bottle 01", typeof(GameObject)),
                    centre,
                    new Quaternion(0, 0, 0, 1),
                    GameObject.Find("/SceneContent/CloudObjects").transform);

                gameObject.layer = 8; // layer 8 = cloudobjects layer
                gameObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);

                gameObject.name = "Thermite";
                gameObject.AddComponent <ObjectPopupName>(); // show name on focus

                // add various props from the cloudobject that aren't already present
                CloudComponent cloudComponent = gameObject.AddComponent <CloudComponent>();
                cloudComponent.cId          = "5bb425bccc7ed83ee3cfbd8d"; // these values will eventually be from the db
                cloudComponent.cSignificant = true;

                // components required for picking up the object
                HandDraggable draggable = gameObject.AddComponent <HandDraggable>();
                draggable.StartedDragging += () => GameObject.Find("/SceneContent/CloudSession")
                                             .GetComponent <CloudSessionManager>()
                                             .HandleUserSelfGrab(gameObject);
                draggable.StoppedDragging += () => GameObject.Find("/SceneContent/CloudSession")
                                             .GetComponent <CloudSessionManager>()
                                             .HandleUserSelfDrop(gameObject);

                gameObject.AddComponent <Rigidbody>();
                gameObject.AddComponent <BoxCollider>();

                // log the transform event
                TransformEvent transformEvent = this.gameObject.GetComponent <TransformEvent>();
                transformEvent.Trigger(gameObject, gameObjects);

                gameObjects.ForEach(obj =>
                {
                    // remove the objects to replace them with the thermite
                    Destroy(obj);
                });

                isWaiting = false;
            }
        }