//IEnumerable FindTheMovmentType(string drct)
    //{
    //    JourneyBuffer jb = new JourneyBuffer();
    //    jb.startPosX = LastJB.endPosX;
    //    jb.startPosZ = LastJB.endPosZ;
    //    Debug.Log("Giren : " + jb.startPosX + "GirenZ : " + LastJB.endPosZ);
    //    List<Vector3> tempPuzzleGOsList_v3 = new List<Vector3>();

    //    tempPuzzleGOsList_v3 = gameManager.PuzzleGOsList_v3.Where(x => x.z == jb.startPosZ && x.x > jb.startPosX).ToList().OrderByDescending(p => p.x).ToList();
    //    if (tempPuzzleGOsList_v3.Count > 0)
    //        jb.endPosX = tempPuzzleGOsList_v3.LastOrDefault().x - 1f;
    //    else
    //        jb.endPosX = gameManager.PlaneGOsList_v3.Where(x => x.z == jb.startPosZ && x.x >= jb.startPosX).OrderByDescending(p => p.x).FirstOrDefault().x;

    //    jb.direction = "Right";
    //    LastJB.endPosX = jb.endPosX;
    //    Debug.Log("Giden : " + jb.startPosX + " : " + jb.endPosX);
    //    jbList.Add(jb);
    //    if (jbList.Count > 0 && isMoving == false)
    //        StartCoroutine(PlayerMoving());
    //    yield return true;
    //}

    IEnumerator PlayerMoving()
    {
        activeCoroutine = true;
        while (jbList.Count > 0)
        {
            yield return(new WaitForFixedUpdate());

            SmoothLerpFactor = 0;
            isMoving         = true;

            activeJB = new JourneyBuffer();
            activeJB = jbList.FirstOrDefault();


            while (isMoving == true && gameManager.isGameRunning)
            {
                if (activeJB.direction == SwipeManager.SwipeType.Right || activeJB.direction == SwipeManager.SwipeType.Left)
                {
                    SmoothLerpFactor       += gameManager.playerSpeed * Time.deltaTime;
                    this.transform.position = new Vector3(Mathf.Lerp(activeJB.startPosX, activeJB.endPosX, SmoothLerpFactor), this.transform.position.y, this.transform.position.z);
                    if (this.transform.position.x == activeJB.endPosX)
                    {
                        isMoving = false;
                    }
                }
                else if (activeJB.direction != SwipeManager.SwipeType.None)
                {
                    SmoothLerpFactor       += gameManager.playerSpeed * Time.deltaTime;
                    this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, Mathf.Lerp(activeJB.startPosZ, activeJB.endPosZ, SmoothLerpFactor));
                    if (this.transform.position.z == activeJB.endPosZ)
                    {
                        isMoving = false;
                    }
                }
                yield return(null);
            }
            jbList.Remove(activeJB);
            SmoothLerpFactor = 0;
            yield return(null);
        }
        activeCoroutine = false;
        yield return(true);
    }
    private void Engine()
    {
        if (!gameManager.isGameRunning)
        {
            return;
        }

        if (SwipeManager.instance.currentSwipe == SwipeManager.SwipeType.Right)
        {
            JourneyBuffer jb = new JourneyBuffer();
            jb.startPosX = LastJB.endPosX;
            jb.startPosZ = LastJB.endPosZ;

            List <Vector3> tempPuzzleGOsList_v3 = new List <Vector3>();

            tempPuzzleGOsList_v3 = gameManager.PuzzleGOsList_v3.Where(x => x.z == jb.startPosZ && x.x > jb.startPosX).ToList().OrderByDescending(p => p.x).ToList();
            if (tempPuzzleGOsList_v3.Count > 0)
            {
                jb.endPosX = tempPuzzleGOsList_v3.LastOrDefault().x - 1f;
            }
            else
            {
                jb.endPosX = gameManager.PlaneGOsList_v3.Where(x => x.z == jb.startPosZ && x.x >= jb.startPosX).OrderByDescending(p => p.x).FirstOrDefault().x;
            }

            jb.direction   = SwipeManager.SwipeType.Right;
            LastJB.endPosX = jb.endPosX;

            jbList.Add(jb);
        }
        if (SwipeManager.instance.currentSwipe == SwipeManager.SwipeType.Left)
        {
            JourneyBuffer jb = new JourneyBuffer();
            jb.startPosX = LastJB.endPosX;
            jb.startPosZ = LastJB.endPosZ;

            List <Vector3> tempPuzzleGOsList_v3 = new List <Vector3>();

            tempPuzzleGOsList_v3 = gameManager.PuzzleGOsList_v3.Where(x => x.z == jb.startPosZ && x.x < jb.startPosX).ToList().OrderByDescending(p => p.x).ToList();
            if (tempPuzzleGOsList_v3.Count > 0)
            {
                jb.endPosX = tempPuzzleGOsList_v3.LastOrDefault().x + 1f;
            }
            else
            {
                jb.endPosX = gameManager.PlaneGOsList_v3.Where(x => x.z == jb.startPosZ && x.x <= jb.startPosX).OrderByDescending(p => p.x).LastOrDefault().x;
            }

            jb.direction   = SwipeManager.SwipeType.Left;
            LastJB.endPosX = jb.endPosX;
            jbList.Add(jb);
        }
        if (SwipeManager.instance.currentSwipe == SwipeManager.SwipeType.Up)
        {
            JourneyBuffer jb = new JourneyBuffer();
            jb.startPosX = LastJB.endPosX;
            jb.startPosZ = LastJB.endPosZ;

            List <Vector3> tempPuzzleGOsList_v3 = new List <Vector3>();

            tempPuzzleGOsList_v3 = gameManager.PuzzleGOsList_v3.Where(x => x.x == jb.startPosX && x.z > jb.startPosZ).ToList().OrderByDescending(p => p.z).ToList();
            if (tempPuzzleGOsList_v3.Count > 0)
            {
                jb.endPosZ = tempPuzzleGOsList_v3.LastOrDefault().z - 1f;
            }
            else
            {
                jb.endPosZ = gameManager.PlaneGOsList_v3.Where(x => x.x == jb.startPosX && x.z >= jb.startPosZ).OrderByDescending(p => p.z).FirstOrDefault().z;
            }

            jb.direction   = SwipeManager.SwipeType.Up;
            LastJB.endPosZ = jb.endPosZ;
            jbList.Add(jb);
        }
        if (SwipeManager.instance.currentSwipe == SwipeManager.SwipeType.Down)
        {
            JourneyBuffer jb = new JourneyBuffer();
            jb.startPosX = LastJB.endPosX;
            jb.startPosZ = LastJB.endPosZ;

            List <Vector3> tempPuzzleGOsList_v3 = new List <Vector3>();

            tempPuzzleGOsList_v3 = gameManager.PuzzleGOsList_v3.Where(x => x.x == jb.startPosX && x.z < jb.startPosZ).ToList().OrderByDescending(p => p.z).ToList();
            if (tempPuzzleGOsList_v3.Count > 0)
            {
                jb.endPosZ = tempPuzzleGOsList_v3.LastOrDefault().z + 1f;
            }
            else
            {
                jb.endPosZ = gameManager.PlaneGOsList_v3.Where(x => x.x == jb.startPosX && x.z <= jb.startPosZ).OrderByDescending(p => p.z).LastOrDefault().z;
            }

            jb.direction   = SwipeManager.SwipeType.Down;
            LastJB.endPosZ = jb.endPosZ;
            jbList.Add(jb);
        }


        if (SwipeManager.instance.currentSwipe != SwipeManager.SwipeType.None && jbList.Count > 0 && isMoving == false && !activeCoroutine)
        {
            StartCoroutine(PlayerMoving());
        }
    }