Exemplo n.º 1
0
    private void OnMouseDown()
    {
        if (isDragable)
        {
            if (!followCursor)
            {
                followCursor = true;

                vfxSource.PlayOneShot(openClip);

                DisableHelpers();
            }
            else
            {
                followCursor = false;
                vfxSource.PlayOneShot(closeClip);

                if (objectRb.IsTouching(targetCollider))
                {
                    helpers[0].SetActive(false);
                    helpers[1].SetActive(false);

                    enigmeManager.next();
                }
                else
                {
                    DisableHelpers();
                }
            }
        }
    }
    private void OnMouseDown()
    {
        if (isDragable)
        {
            if (!followCursor)
            {
                followCursor = true;

                DisableHelpers();
            }
            else
            {
                followCursor = false;

                if (objectRb.IsTouching(targetCollider))
                {
                    helpers[0].SetActive(false);
                    helpers[1].SetActive(false);
                    enigmeManager.next();
                }
                else
                {
                    DisableHelpers();
                    enigmeManager.fail();
                }
            }
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (followCursor)
        {
            Vector3 mousePos   = Input.mousePosition;
            Vector3 plannedPos = Camera.main.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, 10));

            progress           = initProgress + plannedPos.x / length;
            transform.rotation = Quaternion.Euler(0, 0, progress * angle);

            if ((soundState == 0 && Mathf.Abs(progress) >= .25f) || (soundState == 1 && Mathf.Abs(progress) >= .50f) || (soundState == 2 && Mathf.Abs(progress) >= .75f))
            {
                int randomId = Random.Range(0, clips.Length);
                vfxSource.PlayOneShot(clips[randomId]);
                soundState++;
            }

            if (Mathf.Abs(progress) >= 1f)
            {
                followCursor       = false;
                initProgress       = progress;
                collider.size      = originalSize;
                transform.rotation = Quaternion.Euler(0, 0, angle);

                helper.SetActive(false);

                enigmeManager.next();
            }
        }
    }