// Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.R) || Input.GetKeyDown(KeyCode.L))
        {
            blockCounter = 0;
        }
        //Debug.Log (beingdragged);
        //myswipe = Swiping.mydirection;
        //Debug.Log (levelWonBoard);

        /*if (levelWonBoard == null) {
         *      levelWonBoard = SceneLoading.gamewon;
         * }
         * if (LevelLostBoard == null) {
         *      LevelLostBoard = SceneLoading.gamelost;
         *      LevelLostBoard.SetActive (false);
         * }
         * Debug.Log (TurnBehaviour.turn + "BEHAV");*/
        /*if (transform.position != startingposition && TurnBehaviour.turn == 0) {
         *      TurnBehaviour.turn = 1;
         * }
         * if (TurnBehaviour.turn == 1 && transform.position == startingposition) {
         *      TurnBehaviour.turn = 0;
         * }*/
        if (currenttile == transform.position)
        {
            //Debug.Log (tilescript.myTaker.tag);
            if (lastFragile != null && lastFragile.transform.position == transform.position)
            {
                Debug.Log("UNUL");
                //int nextlevel = LevelManager.levelnum;
                //LevelManager.NextLevel (nextlevel);
            }
            else if (nextaction == null)
            {
                cantakeinput = true;
                canmove      = true;
                isspeeding   = false;
            }
            else if (nextaction == "Goal_Action")
            {
                levelWonBoard.SetActive(true);
                //RatingPopUp.GiveRating ();
                this.enabled = false;
                Debug.Log("Whatsgoingon");
            }
            else if (nextaction == "Hole_Action")
            {
                LevelLostBoard.SetActive(true);
                this.enabled = false;
            }
            else if (nextaction == "Outerwall_Action")
            {
                string element = elementchanger.myelement;
                int    number  = elementchanger.mynumber;
                blockCounter = blockCounter + 1;
                ScoreKeeper.AddBlock(element, number, blockCounter);
                elementchanger.RemoveElement();
                elementchanger.RemoveNumber();
                ScoreKeeper.CheckSameElement(blockCounter);
                ScoreKeeper.CheckSameNumber(blockCounter);
                ScoreKeeper.CheckStraight(blockCounter);
                ScoreKeeper.CheckUniqueElement(blockCounter);
                nextaction = null;
            }
            else if (nextaction == "Left_Action")
            {
                tiletotest = currenttile;
                canmove    = true;
                while (canmove == true)
                {
                    tiletotest += Vector3.left;
                    FindTileTag();
                    ActOnTile();
                    isspeeding = true;
                }
                if (nextaction == "Left_Action")
                {
                    nextaction = null;
                }
            }
            else if (nextaction == "Right_Action")
            {
                tiletotest = currenttile;
                canmove    = true;
                while (canmove == true)
                {
                    tiletotest += Vector3.right;
                    FindTileTag();
                    ActOnTile();
                    isspeeding = true;
                }
                if (nextaction == "Right_Action")
                {
                    nextaction = null;
                }
            }
            else if (nextaction == "Up_Action")
            {
                tiletotest = currenttile;
                canmove    = true;
                while (canmove == true)
                {
                    tiletotest += Vector3.up;
                    FindTileTag();
                    ActOnTile();
                    isspeeding = true;
                }
                if (nextaction == "Up_Action")
                {
                    nextaction = null;
                }
            }
            else if (nextaction == "Down_Action")
            {
                tiletotest = currenttile;
                canmove    = true;
                while (canmove == true)
                {
                    tiletotest += Vector3.down;
                    FindTileTag();
                    ActOnTile();
                    isspeeding = true;
                }
                if (nextaction == "Down_Action")
                {
                    nextaction = null;
                }
            }
        }
        Movement();
    }