Example #1
0
    /* <summary>
     * Update is called once per frame
     * </summary>
     */
    void Update()
    {
        // If movement not on, i do not care about position
        if (!isMovementEnabled)
        {
            return;
        }

        // Looking to the nearest skelpos
        KinectBodySkeleton skel = MagicOrchestraUtils.GetNearestSkeleton();

        if (skel == null)
        {
            Debug.Log("No MagicRoomKinectV2Manager founded");
            return;
        }

        Vector3 skelpos = skel.SpineBase;

        // Computing new Vector3 position
        //tr.position = new Vector3(skelpos.x * 8 * _AdapterRoomSize.x + shiftX, gameObject.transform.position.y, (-6 + shiftY) * -_AdapterRoomSize.y - skelpos.z * 3.5f * _AdapterRoomSize.y);
        tr.position = new Vector3(multX * skelpos.x * 8 * _AdapterRoomSize.x + shiftX, gameObject.transform.position.y, (-6 + shiftY) * -_AdapterRoomSize.y * multY - skelpos.z * 3.5f * _AdapterRoomSize.y * multY);

        // Moving pillar on the game
        gameObject.transform.position = tr.position;
    }
    // Update is called once for frame
    void Update()
    {
        if (this.isRaycasterEnabled)
        {
            // Looking to the nearest skelpos
            KinectBodySkeleton skel = MagicOrchestraUtils.GetNearestSkeleton();

            if (skel == null)
            {
                Debug.Log("No MagicRoomKinectV2Manager founded");
                return;
            }

            // Computing new Vector3 position
            this.tr.position = new Vector3(multX * skel.HandLeft.x * _AdapterRoomSize.x + shiftX, gameObject.transform.position.y, multZ * skel.HandLeft.y + shiftZ);

            // Moving cursor on the game
            gameObject.transform.position = tr.position;

            // Select the object to drag
            if (skel.isLeftHandClosed())
            {
                gameObject.GetComponent <SpriteRenderer>().sprite = spritesHands[1];

                if (!this.isDrag)
                {
                    RaycastHit hitInfo;
                    this.target = GetHitTargetObject(out hitInfo);
                    //this.oldScale = this.target.transform.localScale;

                    if (Game1Parameters.ConfirmSound)
                    {
                        this.transform.parent.gameObject.transform.parent.gameObject.GetComponent <AudioSource>().Play();
                    }
                }

                if (this.target != null)
                {
                    this.isDrag = true;
                    this.CallTargetScript();
                    this.target.transform.position = new Vector3(this.target.transform.position.x, 1.5f, this.target.transform.position.z);

                    //this.target.transform.localScale = this.dragScale;
                }
            }

            if (!skel.isLeftHandClosed())
            {
                gameObject.GetComponent <SpriteRenderer>().sprite = spritesHands[0];

                this.isDrag = false;

                if (this.target != null)
                {
                    this.target.transform.position = new Vector3(this.target.transform.position.x, 0, this.target.transform.position.z);
                    //this.target.transform.localScale = this.oldScale;
                }
            }

            // Dragging the object
            if (this.isDrag)
            {
                if (this.target == null)
                {
                    Debug.Log("Something strange");
                }
                else
                {
                    this.target.transform.position = new Vector3(tr.position.x, this.target.transform.position.y, tr.position.z);
                }
            }

            // Moving cursor on the game
            // gameObject.transform.position = tr.position;
        }
    }