Beispiel #1
0
    private void OnCollisionExit(Collision collision)
    {
        MusicCube musicCube = collision.gameObject.GetComponent <MusicCube>();

        if (linkedCube == musicCube)
        {
            linkedCube.linked           = false;
            linkedCube.gameObject.layer = LayerMask.NameToLayer("MusicCube");
            linkedCube = null;
        }
    }
Beispiel #2
0
    void OnTap(int finger, Vector2 pos)
    {
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit))
        {
            GameObject go = hit.transform.gameObject;
            MusicCube  mc = go.GetComponent <MusicCube> ();
            if (mc != null)
            {
                mc.Play();
                mc.finger = finger;
                cubes.Add(mc);
            }
        }
    }
Beispiel #3
0
    void OnUp(int finger, Vector2 pos, float timeHeld)
    {
        MusicCube toberemoved = null;

        foreach (MusicCube mc in cubes)
        {
            if (mc.finger == finger)
            {
                toberemoved = mc;
                break;
            }
        }
        if (toberemoved != null)
        {
            toberemoved.Stop();
            cubes.Remove(toberemoved);
        }
    }
Beispiel #4
0
    private void OnCollisionEnter(Collision collision)
    {
        MusicCube musicCube = collision.gameObject.GetComponent <MusicCube>();

        if (musicCube != null && linkedCube == null && !musicCube.linked)
        {
            linkedCube                  = musicCube;
            linkedCube.linked           = true;
            linkedCube.gameObject.layer = LayerMask.NameToLayer("MusicCubeLinked");

            /*else
             * {
             *  Debug.Log("Force application");
             *  musicCube.gameObject.GetComponent<Rigidbody>().AddForce(
             *      new Vector3(Random.Range(-500f, 500f), Random.Range(300f, 500f), Random.Range(-500f, 500f))
             *      );
             * }*/
        }
    }
Beispiel #5
0
    private void OnCollisionStay(Collision collision)
    {
        MusicCube musicCube = collision.gameObject.GetComponent <MusicCube>();

        if (linkedCube == musicCube)
        {
            collision.gameObject.transform.position = Vector3.Lerp(collision.gameObject.transform.position,
                                                                   new Vector3(
                                                                       gameObject.transform.position.x,
                                                                       collision.gameObject.transform.position.y,
                                                                       gameObject.transform.position.z),
                                                                   0.1f);

            /*collision.gameObject.transform.localEulerAngles = Vector3.Lerp(
             *  collision.gameObject.transform.localEulerAngles,
             *  Vector3.zero, 0.1f);*/

            collision.gameObject.transform.eulerAngles = Vector3.left * 90f;
        }
    }