// Start is called before the first frame update
    void Start()
    {
        rig = this.GetComponent <Rigidbody2D>();
        switch (moveDirection)
        {
        case MoveDir.leftToRight:
            curMove  = moveRight;
            nextMove = moveLeft;

            rig.constraints = RigidbodyConstraints2D.FreezePositionY + 4;
            break;

        case MoveDir.rightToLeft:
            curMove         = moveLeft;
            nextMove        = moveRight;
            rig.constraints = RigidbodyConstraints2D.FreezePositionY + 4;
            break;

        case MoveDir.topToDown:
            curMove         = moveDown;
            nextMove        = moveUp;
            rig.constraints = RigidbodyConstraints2D.FreezePositionX + 4;
            break;

        case MoveDir.DownToTop:
            curMove         = moveUp;
            nextMove        = moveDown;
            rig.constraints = RigidbodyConstraints2D.FreezePositionX + 4;
            break;
        }
    }
 // Update is called once per frame
 void Update()
 {
     frequeceTimer += Time.deltaTime;
     if (frequeceTimer >= changeDirFrequece)
     {
         frequeceTimer = 0;
         moveDele temp = curMove;
         curMove  = nextMove;
         nextMove = temp;
     }
     curMove();
 }