// Update is called once per frame
    void Update()
    {
        var body     = GetComponent <Rigidbody2D>();
        var movement = GetComponent <NonLinearMovement>();

        if (movement != null)
        {
            // clean up "dead" flows
            FlowPassages = FlowPassages.Where(f => f.isActiveAndEnabled).ToList();
            movement.Move(
                ref body,
                FollowPlayer
                                        ? new Vector2(-1.0f, 0.5f * (float)GetVectorComponentForPlayer().y)
                                        : Vector2.left,
                FlowPassages
                );
        }
        else
        {
            Debug.Log("No movement script attached");
        }

        var gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();

        if (gameManager == null)
        {
            return;
        }

        var rect         = GameManager.GetFieldRectForObject(GetComponent <BoxCollider2D>());
        var containsBody = rect.Contains(body.position);

        if (!_hasBeenOnField)
        {
            if (containsBody)
            {
                _hasBeenOnField = true;
            }
        }
        else
        {
            if (rect.xMin > body.position.x + 2 * GetComponent <BoxCollider2D>().bounds.size.x)
            {
                Destroy(gameObject);
            }

            if ((rect.yMin > body.position.y && movement.Velocity.y < 0) || (rect.yMax < body.position.y && movement.Velocity.y > 0))
            {
                movement.Velocity.y *= -1;
            }
        }
    }
    private void FixedUpdate()
    {
        var player = GetComponent <Rigidbody2D>();

        var directionX = CheckKeyDirectionX();
        var directionY = CheckKeysDirectionY();

        var nonLinearMovement = GetComponent <NonLinearMovement>();

        // clean up "dead" flows
        FlowPassages = FlowPassages.Where(f => f.isActiveAndEnabled).ToList();
        nonLinearMovement.Move(ref player, new Vector2((int)directionX, (int)directionY), FlowPassages);

        var aspect = (float)Screen.width / (float)Screen.height;

        var rect = GameManager.GetFieldRectForObject(GetComponent <BoxCollider2D>());

        player.position = new Vector2(
            Mathf.Clamp(player.position.x, rect.xMin, rect.xMax),
            Mathf.Clamp(player.position.y, rect.yMin, rect.yMax)
            );
    }