/// Finds potential matches

    private IEnumerator CheckPotentialMatches()
    {
        yield return(new WaitForSeconds(ConstantsVariable_4.WaitBeforePotentialMatchesCheck));

        potentialMatches = GameUtilities_4.GetPotentialMatches(shapes);
        if (potentialMatches != null)
        {
            while (true)
            {
                AnimatePotentialMatchesCoroutine = GameUtilities_4.AnimatePotentialMatches(potentialMatches);
                StartCoroutine(AnimatePotentialMatchesCoroutine);
                yield return(new WaitForSeconds(ConstantsVariable_4.WaitBeforePotentialMatchesCheck));
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Gameover == false)
        {
            if (state == GameState_4.None)
            {
                //user has clicked or touched
                if (Input.GetMouseButton(0))
                {
                    //get the hit position
                    var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                    if (hit.collider != null) //we have a hit!!!
                    {
                        hitGo = hit.collider.gameObject;
                        state = GameState_4.SelectionStarted;
                    }
                }
            }
            else if (state == GameState_4.SelectionStarted)
            {
                //user dragged
                if (Input.GetMouseButton(0))
                {
                    var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                    //we have a hit
                    if (hit.collider != null && hitGo != hit.collider.gameObject)
                    {
                        //user did a hit, no need to show him hints
                        StopCheckForPotentialMatches();

                        //if the two shapes are diagonally aligned (different row and column), just return
                        if (!GameUtilities_4.AreVerticalOrHorizontalNeighbors(hitGo.GetComponent <Shape_4>(),
                                                                              hit.collider.gameObject.GetComponent <Shape_4>()))
                        {
                            state = GameState_4.None;
                        }
                        else
                        {
                            state = GameState_4.Animating;
                            FixSortingLayer(hitGo, hit.collider.gameObject);

                            StartCoroutine(FindMatchesAndCollapse(hit));
                        }
                    }
                }
            }
            //Touch touch = Input.GetTouch(0);

            //if (state == GameState.None)
            //{
            //    //user has clicked or touched
            //    if (Input.touchCount > 0)
            //    {
            //        //get the hit position
            //        var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(touch.position), Vector2.zero);
            //        if (hit.collider != null) //we have a hit!!!
            //        {
            //            hitGo = hit.collider.gameObject;
            //            state = GameState.SelectionStarted;
            //        }

            //    }
            //}
            //else if (state == GameState.SelectionStarted)
            //{
            //    //user dragged
            //    if (Input.touchCount > 0)
            //    {


            //        var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(touch.position), Vector2.zero);
            //        //we have a hit
            //        if (hit.collider != null && hitGo != hit.collider.gameObject)
            //        {

            //            //user did a hit, no need to show him hints
            //            StopCheckForPotentialMatches();

            //            //if the two shapes are diagonally aligned (different row and column), just return
            //            if (!GameUtilities.AreVerticalOrHorizontalNeighbors(hitGo.GetComponent<Shape>(),
            //                hit.collider.gameObject.GetComponent<Shape>()))
            //            {
            //                state = GameState.None;
            //            }
            //            else
            //            {
            //                state = GameState.Animating;
            //                FixSortingLayer(hitGo, hit.collider.gameObject);
            //                StartCoroutine(FindMatchesAndCollapse(hit));
            //            }
            //        }
            //    }
            //}
        }
    }