public static GameObject[] SliceInstantiate(this GameObject obj, Plane pl, TextureRegion cuttingRegion, Material crossSectionMaterial = null)
        {
            _Sliced slice = Slicer.Slice(obj, pl, cuttingRegion, crossSectionMaterial);

            if (slice == null)
            {
                return(null);
            }

            GameObject upperHull = slice.CreateUpperHull(obj, crossSectionMaterial);
            GameObject lowerHull = slice.CreateLowerHull(obj, crossSectionMaterial);

            if (upperHull != null && lowerHull != null)
            {
                return(new GameObject[] { upperHull, lowerHull });
            }

            // otherwise return only the upper hull
            if (upperHull != null)
            {
                return(new GameObject[] { upperHull });
            }

            // otherwise return only the lower hull
            if (lowerHull != null)
            {
                return(new GameObject[] { lowerHull });
            }

            // nothing to return, so return nothing!
            return(null);
        }
Example #2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.name == "Box")
        {
            //if (game.inCube)
            //return;

            Vector3 test = trackedHand.GetPointVelocity(transform.TransformPoint(other.transform.position));
            //if (device.velocity.x > 0.25 || device.velocity.y > 0.25 || device.velocity.z > 0.25 || device.angularVelocity.x > 0.25 || device.angularVelocity.y > 0.25 || device.angularVelocity.z > 0.25)
            //{
            game.inCube = true;

            _Sliced hull = other.gameObject.Slice(obg.transform.position, obg.transform.up, crossMat);

            if (hull != null)
            {
                hull.CreateLowerHull(other.gameObject, crossMat);
                hull.CreateUpperHull(other.gameObject, crossMat);
            }

            game.Hit.Play();
            game.Vibrate(Controller, device);

            //GameObject _explosion;
            game.streak   += 1;
            game.hitTotal += 1;
            game.points   += 50 * game.multiplier;
            //myMaterial = GetComponent<Renderer>().material;
            //myMaterial.SetColor("_EmissionColor", greenGrey);
            //parent.GetComponent<CubeScript>().notePosition;

            /*_explosion = Instantiate(Resources.Load("Prefabs/Spark" + parentName) as GameObject);
             * _explosion.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
             * _explosion.transform.position = transform.position;
             * _explosion.name = "Spark" + parentName;
             * _explosion.AddComponent<Trash>();*/
            Destroy(other.gameObject.transform.parent.gameObject);
            // }

            /*else
             * {
             *  GameObject temp = Instantiate(noForece);
             *  temp.transform.SetParent(GameObject.Find("gameText").transform);
             *  temp.transform.localPosition = new Vector3(0, 0, 0);
             *  temp.SetActive(true);
             *  game.streak = 0;
             *  temp.AddComponent<Trash>();
             *  temp.GetComponent<Trash>().isFloatingText = true;
             * }*/
        }
    }
Example #3
0
    void OnTriggerEnter(Collider other)
    {
        if (other.name == "Box")
        {
            velocityEstimator.BeginEstimatingVelocity();
            hitNote = null;

            mainManager.Vibrate(Controller, device);

            _Sliced hull = other.gameObject.Slice(cutPlane.transform.position, cutPlane.transform.up, crossMat);

            if (hull != null)
            {
                hull.CreateLowerHull(other.gameObject, crossMat);
                hull.CreateUpperHull(other.gameObject, crossMat);
            }

            Component[] objs = other.gameObject.transform.parent.GetComponents(typeof(Component)); //Remove Scripts
            foreach (Component comp in objs)
            {
                if (comp.GetType() == typeof(NoteJump))
                {
                    hitNote = comp as NoteJump;

                    if (hitNote.note._type == handColor)
                    {
                        hitSpeed = velocityEstimator.speed;

                        if (correctHit(hitNote.note._cutDirection))
                        {
                            mainManager.gameManager.UpdateScore(false);
                        }
                        else
                        {
                            //Play a wrong hit sound here
                            mainManager.gameManager.UpdateScore(true);
                        }
                    }
                    else
                    {
                        //Play a wrong hit sound here
                        mainManager.gameManager.UpdateScore(true);
                    }

                    hitNote.gameObject.SetActive(false);
                }
            }
        }
    }