private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "PlayerBullet")
        {
            Destroy(collision.gameObject);
            sr.material = matWhite;
            if (genEnemy.health <= 0)
            {
                gameObject.GetComponent <CircleCollider2D>().enabled = false;
                currentState = SlimeStates.Death;
            }
            else
            {
                counter      = TimeToGetHit;
                currentState = SlimeStates.Hit;
                Invoke("ResetMaterial", 0.1f); //jak dlugo ma byc bialy
            }
        }

        if (collision.tag == "Player")
        {
            if (canDealDamageIfCollides)
            {
                if (SAYController.instance.isInvincible == false)
                {
                    CameraShaker.ShakeStrong(.20f, .35f);
                    SAYPlayerHealthController.instance.DamagePlayer();
                    Destroy(gameObject);
                }
            }
        }
    }
    void Update()
    {
        if (Player.transform.position.x > transform.position.x)
        {
            sr.flipX = true;
        }
        else
        {
            sr.flipX = false;
        }

        if (!theRoom.roomActive)
        {
            return;
        }

        if (counterToStart > 0)
        {
            counterToStart -= Time.deltaTime;
            return;
        }
        else
        {
            switch (currentState)
            {
            case SlimeStates.Idle:
                ChangeAnimationState("SmallRedSlime_idle");

                if (Vector2.Distance(transform.position, Player.position) < MaxDistance && genEnemy.health != 0)
                {
                    currentState = SlimeStates.Jump;
                }
                break;

            case SlimeStates.Jump:
                if (genEnemy.health != 0)
                {
                    if (counter > 0)
                    {
                        Jump();
                        counter -= Time.deltaTime;

                        if (jumpShootsCounter > 0)
                        {
                            jumpShootsCounter -= Time.deltaTime;
                        }
                        else
                        {
                            Instantiate(projectile, transform.position, Quaternion.identity);

                            jumpShootsCounter = jumpShootsBreaks;
                        }
                    }
                    else
                    {
                        jumpShootsCounter = jumpShootsBreaks;

                        counter      = TImeToLand;
                        currentState = SlimeStates.Land;
                    }
                }

                break;

            case SlimeStates.Land:
            {
                if (genEnemy.health != 0)
                {
                    ChangeAnimationState("SmallRedSlime_landing");

                    if (counter > 0)
                    {
                        counter -= Time.deltaTime;

                        if (canShoot && genEnemy.health != 0 && Vector2.Distance(transform.position, Player.position) > 0.1f)        //&& Vector2.Distance(transform.position , Player.position) > 1)
                        {
                            canShoot = false;
                        }
                    }
                    else
                    {
                        canShoot     = true;
                        counter      = TimeToStayStill;
                        currentState = SlimeStates.Stay;
                    }
                }
            }
            break;

            case SlimeStates.Stay:
                if (genEnemy.health != 0)
                {
                    if (counter > 0)
                    {
                        ChangeAnimationState("SmallRedSlime_preperingToJump");
                        counter -= Time.deltaTime;
                    }
                    else
                    {
                        counter      = TimeToMove;
                        currentState = SlimeStates.Jump;
                    }
                }

                break;

            case SlimeStates.Hit:
                ChangeAnimationState("SmallRedSlime_TakingDamage");
                if (counter > 0)
                {
                    counter -= Time.deltaTime;
                    Vector3 moveDirection = transform.position - Player.transform.position;
                    moveDirection.Normalize();
                    rb.velocity = moveDirection * speedWhenHit;
                }
                else
                {
                    rb.velocity  = Vector2.zero;
                    counter      = TimeToStayStill;
                    currentState = SlimeStates.Stay;
                }
                break;

            case SlimeStates.Death:
            {
                Invoke("ResetMaterial", 0.1f);         //jak dlugo ma byc bialy
                ChangeAnimationState("SmallRedSlime_TakingDamage");
                Vector3 movingWay = transform.position - Player.transform.position;
                movingWay.Normalize();
                rb.velocity = movingWay * speedWhenDie;
                Invoke("KillSelf", howLongAwayAfterDestroyed);
                CameraShaker.ShakeStrong(.20f, .25f);
                currentState = SlimeStates.PostMortem;
            }
            break;

            case SlimeStates.PostMortem:
                break;
            }
        }
    }
    void Update()
    {
        if (Player.transform.position.x > transform.position.x)
        {
            sr.flipX = true;
        }
        else
        {
            sr.flipX = false;
        }

        if (!theRoom.roomActive)
        {
            return;
        }


        if (counterToStart > 0)
        {
            counterToStart -= Time.deltaTime;
            return;
        }
        else
        {
            switch (currentState)
            {
            case SlimeStates.Idle:
                ChangeAnimationState("BigRedSlime_Idle");

                if (Vector2.Distance(transform.position, Player.position) < MaxDistance && genEnemy.health != 0)
                {
                    currentState = SlimeStates.Jump;
                }
                break;

            case SlimeStates.Jump:
                if (genEnemy.health != 0)
                {
                    if (counter > 0)
                    {
                        Jump();
                        counter -= Time.deltaTime;

                        if (jumpShootsCounter > 0)
                        {
                            jumpShootsCounter -= Time.deltaTime;
                        }
                        else
                        {
                            Instantiate(projectile, transform.position, Quaternion.identity);

                            jumpShootsCounter = jumpShootsBreaks;
                        }
                    }
                    else
                    {
                        jumpShootsCounter = jumpShootsBreaks;

                        counter      = TImeToLand;
                        currentState = SlimeStates.Land;
                    }
                }

                break;

            case SlimeStates.Land:
            {
                if (genEnemy.health != 0)
                {
                    ChangeAnimationState("BigRedSlime_Landing");

                    if (counter > 0)
                    {
                        counter -= Time.deltaTime;

                        if (canShoot && genEnemy.health != 0 && Vector2.Distance(transform.position, Player.position) > 0.1f)
                        {
                            foreach (Transform t in allFirePoints)
                            {
                                Instantiate(bulleWhenLanding, t.position, t.rotation);
                            }

                            canShoot = false;
                        }
                    }
                    else
                    {
                        canShoot     = true;
                        counter      = TimeToStayStill;
                        currentState = SlimeStates.Stay;
                    }
                }
            }
            break;

            case SlimeStates.Stay:
                if (genEnemy.health != 0)
                {
                    if (counter > 0)
                    {
                        ChangeAnimationState("BigRedSlime_prepereToJump");
                        counter -= Time.deltaTime;
                    }
                    else
                    {
                        counter      = TimeToMove;
                        currentState = SlimeStates.Jump;
                    }
                }

                break;

            case SlimeStates.Death:
            {
                Invoke("ResetMaterial", 0.1f);         //jak dlugo ma byc bialy
                ChangeAnimationState("BigRedSlime_TakingDamage");
                Vector3 movingWay = transform.position - Player.transform.position;
                movingWay.Normalize();
                rb.velocity = movingWay * speedWhenDie;
                Invoke("KillSelf", howLongAwayAfterDestroyed);
                //CinemachineShake.instance.ShakeCamera(ShakeLevel.Two, 0.2f);
                currentState = SlimeStates.PostMortem;
            }
            break;

            case SlimeStates.PostMortem:
                break;
            }
        }
    }